This project is read-only.
1
Vote

Multiple WPF Sparrow Charts and Shared X-Axis Labels

description

Hi,

I am creating a WPF application with two line charts. I am using the Sparrow Toolkit for creating the charts and CategoryXAxis as the x-axis type for both charts. The problem occurs when I add points to the charts. I expect the charts to be independent because they are separate instances. However, for some reason, they seem to share the labels of the x-axis.

In order to reproduce the problem, create a WPF application with two Sparrow charts. My XAML for chart1 looks like the following and chart2 is the same except for the Chart Name of course.
<sparrow:SparrowChart Name="chart1">
   <sparrow:SparrowChart.XAxis>
     <sparrow:CategoryXAxis/>
   </sparrow:SparrowChart.XAxis>
   <sparrow:SparrowChart.YAxis>
     <sparrow:LinearYAxis/>
   </sparrow:SparrowChart.YAxis>
   <sparrow:LineSeries/>
</sparrow:SparrowChart>
My code behind for chart1 looks like the following
public void AddValue(SparrowChart chart, double value)
{
   CategoryPoint point = new CategoryPoint();
   point.Category = DateTime.Now.ToString("hh:mm:ss tt");
   point.Value = value;
   chart.Series[0].Points.Add(point);
}
For example, if you run the following calls to AddValue
AddValue(chart2, 10);
Thread.Sleep(1000);
AddValue(chart1, 20);
Thread.Sleep(1000);
AddValue(chart1, 30);
Thread.Sleep(1000);
AddValue(chart1, 10);
Thread.Sleep(1000);
AddValue(chart2, 40);
chart1 will display 3 points with values 20, 30, and 10 with their corresponding 3 category labels, which is fine. However, chart2 will display two points with values 10 and 40 but with 5 category labels !!!, which is not expected at all as it should display only the category labels associated with its points. However, for some reason, it displays the category labels of the other chart as well.

Am I missing something? or this is a bug resulting from probably using static x-axis category labels rather than associating them with Class instance. A sample project that demonstrates the problem is attached.

Best regards

file attachments

comments