Jump to content
Software FX Community

Recommended Posts

Posted

I would like to build a chart with two series. One a bar the other a step. When I try this the chart only shows the step and not the bars. I can display both individually but not together. Here is the code:

chtMain.Series.Clear();

chtMain.AxesY.Clear();

Axis a = new Axis {AutoScale = true, ForceZero = false, Labels = {Decimals = 2}, Title = new Title("value")};

chtMain.AxesY.Add(a);

chtMain.AxisX.Labels.Format = AxisFormat.Time;

chtMain.AxisX.Labels.CustomFormat = "HH:mm";

chtMain.AxisX.Title = new Title("Time");

SeriesAttributes series = new SeriesAttributes("Value");

series.AxisY = a;

series.Content = "My Value";

series.BindingPathX = "Date";

series.Gallery = Gallery.Step;

series.Volume = 100;

series.Marker.Visibility = Visibility.Collapsed;

chtMain.Series.Add(series);

SeriesAttributes series2 = new SeriesAttributes("Value");

series2.AxisY = a;

series2.Content = "My Value2";

series2.BindingPathX = "Date";

series2.Gallery = Gallery.Bar;

series2.Marker.Visibility = Visibility.Collapsed;

chtMain.Series.Add(series2);

series.ItemsSource = GetData();

series2.ItemsSource = GetData();

-------------

XAML

What am I missing?

Posted

You can combine bar with steps (or other connected gallery types such as line, area, etc.) but NOT when you use X values. If your data is equally spaced you might be able to get the chart you need by not setting the Series.BindingPathX property for both series.

Supporting bars with X values is tricky because it is not clear how wide should the bars be. We have some code that tries to support bars with X values but when I tested combining with steps I noticed the first bar was not drawn. If you want to explore this please add this code after you set the second series gallery to bar.

  ChartFX.WPF.Galleries.Bar bar = (ChartFX.WPF.Galleries.Bar) series2.GalleryAttributes;   bar.XValues = true;   bar.XWidth = new TimeSpan(0,10,0); 

JuanC 

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...