I'm trying to create a chart within my WPF web application. I'm getting the data from my database using "SELECT * " query and storing the result in a dataset.
Then I have the following code to create the chart:
code-behind:
// Get the data and store in the dataset
DataSet deviceDS = IGDocumentation.GetData.GetDevicesROI("YOGITHA\\SQLEXPRESS");
Series seriesNetProfit = new Series();
seriesNetProfit.DataSource = deviceDS.Tables["NewDeviceROI"];
seriesNetProfit.DataMapping = "NetProfit";
seriesNetProfit.ChartType = ChartType.Line;
this.xamChart1.Series.Add(seriesNetProfit);
XAML:
<igCA:XamChart Name="xamChart1" DataContext="{Binding ElementName=xamChart1}" />
The chart that I'm getting consists of the values of one column ("NetProfit") of my dataset.
I'm trying to figure out how to get the values out of two columns ("NetProfit" and "DeviceCost") and use those as X and Y coordinates for the plot. But I can't figure out how to edit my code above to accomplish that.
Any ideas?
Thanks
Hi,
If you want an XY plot, choose a scatter type chart. For example seriesNetProfit.ChartType = ChartType.Scatter;
For a scatter type chart, you should use a dataMapping like this:
seriesNetProfit.DataMapping = "ValueX = NetProfit; ValueY = DeviceCost"
does this help?
-Graham
Graham Murray"] Hi, If you want an XY plot, choose a scatter type chart. For example seriesNetProfit.ChartType = ChartType.Scatter; For a scatter type chart, you should use a dataMapping like this: seriesNetProfit.DataMapping = "ValueX = NetProfit; ValueY = DeviceCost" does this help? -Graham
Thanks for that!
Well, what if I want to use a LineChart with multiple columns (such a "NetProfit","GrossProfit"...) for the values and a "DeviceCost" as the Label... Hence I would get one line for each ("NetProfit","GrossProfit"...) and "DeviceCost" will be the X-axis...
How do I declare the DataMapping in such a case?
Thanks again for your help!
DataMapping = "Label = DeviceCost; Value = NetProfit"
and you would create a seperate series for each value you wanted to plot against the DeviceCost categories.