Jump to content
Software FX Community

Trouble with Multi Pane Charts


Recommended Posts

When working with multi-pane charts, theoretically this code:

Chart chart = new Chart();for (int i = 0; i < 3; i++){   Pane pane = new Pane();   pane.AxesX.Add(new Axis());   pane.AxesX[0].DataFormat.Format = AxisFormat.Date;   pane.AxesX[0].Labels.Format = AxisFormat.Date;   pane.AxesY.Add(new Axis());   pane.AxesY[0].Min = min;   pane.AxesY[0].Max = max;   pane.AxesY[0].AxisStyle = AxisStyles.ShowEnds | AxisStyles.AutoFirstLabel;   pane.AxesY[0].Labels.Decimals = 2;   SeriesAttributes sa = new SeriesAttributes();   sa.Gallery = Gallery.Line;   sa.ItemsSource = sd.Data;   sa.BindingPath = "Value";   sa.BindingPathX = "Date";   pane.Series.Add(sa);   chart.Panes.Add(pane);}

Should produce the same result as this code:

Chart chart = new Chart();chart.AllSeries.MultiplePanes = true;for (int i = 0; i < 3; i++){   SeriesAttributes sa = new SeriesAttributes();   sa.Gallery = Gallery.Line;   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.AutoFirstLabel;   sa.AxisY.Labels.Decimals = 2;   sa.AxisX = new Axis();   sa.AxisX.DataFormat.Format = AxisFormat.Date;   sa.AxisX.Labels.Format = AxisFormat.Date;   chart.Series.Add(sa);}

However, the first method causes an exception to be thrown from inside the chart.  The second method works fine, but I need to be able to Title each pane and also have HighLow(Open)Close bars on some panes.  If I use the "AllSeries.MultiPanes = true" method, then I can't make a pane HLC or HLOC because I have to pass in multiple series for those galleries.

What am I doing wrong?  Thanks for your help.

Link to comment
Share on other sites

You have to modify the first loop as follows

for (int i = 0; i < 3; i++) {   Pane pane = new Pane();   Axis axisX = new Axis();   axisX.DataFormat.Format = AxisFormat.Date;   axisX.Labels.Format = AxisFormat.Date;   pane.AxesX.Add(axisX);

  Axis axisY = new Axis();   axisY.Min = min;   axisY.Max = max;   axisY.AxisStyle = AxisStyles.ShowEnds | AxisStyles.AutoFirstLabel;   axisY.Labels.Decimals = 2;   pane.AxesY.Add(axisY);   SeriesAttributes sa = new SeriesAttributes();   sa.Gallery = Gallery.Line;   sa.ItemsSource = RandomData(30);   sa.BindingPath = "Value";   sa.BindingPathX = "Date";

  // This is important as the series will not inherit the axes from the pane   sa.AxisX = axisX;   sa.AxisY = axisY;

  pane.Series.Add(sa);   // This is important as some code will loop through the chart series   chart1.Series.Add(sa);




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.

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