We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem with Custom Labels on line chart

Hi,
I am using chartWPF for displaying line chart. I am using Custom mode for x-axis (primary axis) labels. I add the series in code behind (ChartArea.Series.Add)in an event handler which is fired as a result of user input.

Here is a code snippet to add series.

private void AddSeries()
{
float[] spectrum = Presenter.GetSpectraAt (sp.Row,sp.Column);//returns a float array
if (spectrum == null)
return;
Syncfusion.Windows.Chart.ChartSeries spectrumSeries = new Syncfusion.Windows.Chart.ChartSeries(Syncfusion.Windows.Chart.ChartTypes.Line);
spectrumSeries.DataSource = spectrum;
chartArea.Series.Add(spectrumSeries);
}

Following is the code snippet to add custom labels for X-Axis
private void ShowXAxisLabels()
{
//Wavelengths is an array of floats that I want to use for x- axis labels
if (Wavelengths != null)
{
//xAxis is of type ChartAxis
xAxis.CustomLabels.Clear();
xAxis.LabelsMode = Syncfusion.Windows.Chart.ChartAxisLabelsMode.Custom;
for (int i = 0; i < Wavelengths.Length; i++)
{
Syncfusion.Windows.Chart.ChartAxisLabel label = new Syncfusion.Windows.Chart.ChartAxisLabel(i, Wavelengths[i]);
xAxis.CustomLabels.Add(label);
}

}
}

Please note that the lengths of arrays for series (spectrum) and labels (Wavelengths) is the same.

I am experiencing following problems with the chart.

1.Everytime I add a series, the labels reset to the indices. I have add the custom labels after adding every series. Is there any way I can add the labels only once.

2.No matter waht I set for Interval, the x-axis shows tick lines for every label. This clutters the chart. Is there any way I can control the tick interval when Custom labels are used.


5 Replies

SA Saradha Syncfusion Team July 15, 2009 06:04 AM UTC

Hi Hemanth,

Thanks for your interest in Syncfusion products.

1. I'm unable to reproduce the requirement for resetting the custom labels often. Could you please send a simple sample or modify the sample provided in the below given link, to reproduce the issue.

2. Since we set 100 number of custom labels that Axis.Interval property is not taken into account. However, this could be overcome by making the for loop jump with the Axis.Interval value. Please refer to the code below.

for (int i = 0; i < Wavelengths.Length; i= i + (int)XAxis.Interval)
{
Syncfusion.Windows.Chart.ChartAxisLabel label = new Syncfusion.Windows.Chart.ChartAxisLabel(i, Wavelengths[i]);
XAxis.CustomLabels.Add(label);
}

Sample Link:
http://files.syncfusion.com/support/Chart.WPF/7.3.0.6/F88086/main.htm

Please let us know if you have further queries.

Regards,
K. Saradha Devi


HJ Hemanth Javali July 15, 2009 01:54 PM UTC

Hi Saradha Devi,
Thanks for your reply.

1.Correction regarding this issue: The labels actually disappear (do not reset to indices as I mentioned in my first post). This issue issue can be observed in the sample you attached. Here is how you can reproduce:
a.Launch the program "CustomAxisRange.exe"
b.Click button Add series.
c.Click button Add Labels.
d.Click button Add Series. Observe that the x axis labels disappear.

Thanks,
-Hemath



SA Saradha Syncfusion Team July 16, 2009 04:33 AM UTC

Hi Hemanth,

Thanks for using Syncfusion products.

With the same reproduce steps, I'm unable to reproduce the issue. Please refer to the video file that is taken while executing the sample.
http://files.syncfusion.com/support/Chart.WPF/7.3.0.6/F88086/video.zip

Could you please let us know what is the version number you are using.

Thank you,
K. Saradha Devi


HJ Hemanth Javali July 16, 2009 03:15 PM UTC

Aahaa! This is fixed in 7.3.0.20 which was released 2 days ago. I was using 7.2.0.20 in which the problem existed. It was perhaps fixed in 7.2.0.37, but I never installed it.
Anyways thanks for your help. I really appreciate it.

-Hemanth


SA Saradha Syncfusion Team July 24, 2009 07:04 AM UTC

Hi Hemanth,

It's nice to hear that you got to know that the issue is fixed in our latest source.

Thank you for informing us.

Regards,
K. Saradha Devi

Loader.
Live Chat Icon For mobile
Up arrow icon