buy now
log in
MindFusion

Q: I want to create a scatter chart where scatters are drawn one above the other and one scatter is for compression, the other is for tension. Ideally I would like to show labels for both values.

A: You can use the second X-axis to display one of your measures. Set the X2Data or X2DataPath properties of the LineSeries and the coordinates will be calculated in respect to X2:

 LineSeries series1 = new LineSeries();
 series1.X2Data = new List() { 12, 34, 56, 7 };

Then, you must set the properties of the X2-axis to see it drawn:
 lineChart1.X2AxisSettings.MinValue = 0;
 lineChart1.X2AxisSettings.MaxValue = 60;
 lineChart1.X2AxisSettings.Interval = 5;
 lineChart1.X2AxisSettings.LabelType = LabelType.AutoScale;
 lineChart1.X2AxisSettings.Title = "Compression";
 lineChart1.X2AxisSettings.TitleStroke = new SolidColorBrush(Colors.Red);
 lineChart1.X2AxisSettings.LabelStroke = new SolidColorBrush(Colors.Red);
Here we have made both the division labels and the title label of the axis red. If you want to show only scatters for your line series you must set the ScatterType property and set the LineType property to LineType.None to avoid a line being drawn between the scatters:
 LineSeries series1 = new LineSeries();
 series1.X2Data = new List() { 12, 34, 56, 7 };
 series1.YData = new List() { 23, 14, 56, 78};
 series1.ScatterFills.Add(new SolidColorBrush(Colors.Red));
 series1.ScatterStrokes.Add(new SolidColorBrush(Colors.Red));
 series1.LineType = LineType.None;
 series1.ScatterType = ScatterType.Diamond;
 series1.ScatterSize = 30;
 lineChart1.Series.Add(series1);


If you want the scatters if your two LineSeries to be drawn above each other the solution is simple – just set them the same XData / X2Data but measured in the units of the X or X2 axis.

Copyright © 2001-2024 MindFusion LLC. All rights reserved.
Terms of Use - Contact Us