Jump to content
Software FX Community

Bar chart not displaying


Coder

Recommended Posts

I am creating a multipanel chart which works fine when displaying each series as a line, but fails to display anything when I change the gallery to a bar chart.  Any suggestions?  Code sample...

DateTime startDate = new DateTime(1999, 1, 1);DateTime endDate = DateTime.Now;Chart chart = new Chart();

chart.AllSeries.MultiplePanes = true;chart.LegendBox.Visibility = Visibility.Collapsed;

foreach (Element element in view.Elements){   TimeSeries ts = element as TimeSeries;

if (ts != null) { SeriesData sd = new SeriesData(ts.SeriesId, symbol.Id);   SeriesAttributes sa = new SeriesAttributes();   double min;   double max;

  sd.GetMinMaxInRange(startDate, endDate,

out min, out max);   sa.Gallery = Gallery.Bar;   sa.Marker.Visibility = Visibility.Hidden;   sa.ItemsSource = sd.Data;   sa.BindingPath = "Value";   sa.BindingPathX = "Date";   sa.AxisY = new Axis();   sa.AxisY.Min = min;   sa.AxisY.Max = max;   sa.AxisY.AxisStyle = AxisStyles.ShowEnds | AxisStyles.ShowIntermediateLogLabels | AxisStyles.AutoFirstLabel;   sa.AxisY.Labels.Decimals = 1;   sa.AxisX = new Axis();   sa.AxisX.DataFormat.Format = AxisFormat.Date;   sa.AxisX.Labels.Format = AxisFormat.Date;   sa.AxisX.FontSize = 14;   sa.AxisX.Title.Content = ts.Title;   sa.AxisX.Title.FontSize = 20;   sa.AxisX.Min = startDate;   sa.AxisX.Max = endDate;

  chart.Series.Add(sa);   }}

Link to comment
Share on other sites

By default our bar chart does not support X values, the main reason for this is that in a line/area chart you can easily connect the points regardless of their spacing in X but a bar chart is typically drawn with all bars having the same width where your data points could be Jan 1, Jan 2, Jan 3, Feb 15.

Is your data "equally spaced" in X?

Regards,

JuanC

Link to comment
Share on other sites

It's not guaranteed to be equally spaced. I need to be able to mix line and bar charts where the line would be distorted by gaps in the data if it is forced into a categorical axis.  For example, I need to create a financial Price/Volume graph where high/low/open/close bars are on the same graph with moving average lines and a second pane with volume information bars.  There can be days where we are missing data and things wouldn't align categorically.  It would be a huge problem to have to "vectorize" the data before displaying it to make sure we fill the gaps.

Didn't previous versions of ChartFX support bars on an X-values axis?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...