This is a migrated thread and some comments may be shown as answers.

LineSeriesDefinition chart

1 Answer 70 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Anne Lyon
Top achievements
Rank 1
Anne Lyon asked on 27 Jul 2010, 10:30 AM
Hi,

I have a Line chart where I map XValue and YValue using a class as the ItemSource. My problem is that the X Axis is always scaled as if the axis should be a category axis (i.e., point 1 plots at tickmark 1, point 2 plots at tickmark 2 etc.).
What I need to plot is a scatter plot, i.e. point 1 with value 5 plots at x=5 and not x=1, point 2 with value 8 plots at x=8 and not x= 2.

The code is as follows:
SeriesMapping seriesMapping = new SeriesMapping();
seriesMapping.SeriesDefinition = new LineSeriesDefinition();
seriesMapping.ItemMappings.Add(new ItemMapping("AODate", DataPointMember.XValue));
seriesMapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue));
seriesMapping.ItemMappings.Add(new ItemMapping("Label", DataPointMember.Label));
ctlRadChart.SeriesMappings.Add(seriesMapping);
List<clsPlotData> data = new List<clsPlotData>();
double minX = 5;
double middleX = 8;
double middle2X = 9;
double maxX = 14;
double minY = 1;
double middleY = 3;
double middle2Y = 8.5;
double maxY = 2;
data.Add(new clsPlotData(minX, minY, ""));
data.Add(new clsPlotData(middleX, middleY, ""));
data.Add(new clsPlotData(middle2X, middle2Y, ""));
data.Add(new clsPlotData(maxX, maxY, ""));
ctlRadChart.ItemsSource = data;

with clsPLotData being this:
public class clsPlotData
{
    public clsPlotData(double AOdate, double yValue, string label)
    {
        this.YValue = yValue;
        this.AOdate = AOdate;
        this.Label = "X: " + AOdate.ToString() + "\nY: " + yValue.ToString();
    }
    public double YValue
    {
        get;
        set;
    }
    public Double AOdate
    {
        get;
        set;
    }
    public string Label
    {
        get;
        set;
    }
}

The chart produced is attached as a jpg. How coan I get the x axis to show data from 5 to 14 instead of point 1 to 4?

thanks,
Anne

1 Answer, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 30 Jul 2010, 10:24 AM
Hello Anne Lyon,

Please, find attached a small working example demonstrating the desired scenario.

Hope this will help.

All the best,
Velin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Anne Lyon
Top achievements
Rank 1
Answers by
Velin
Telerik team
Share this question
or