Hi,telerik
I have to create chart by code and export into image with legend.
After reading your doc and related threads,unfortunately can't find
right answer how to create legend with code. My question is
1. Add legend into RadCartesianChart by code
Following is my code.
2. Export chart into image with legend
All sample shows legend is placed outside of chart control.
Is it possible to export chart with legend ? or Should I go back to outdated RadCharting ?
TIA.
RGDS
Kang
I have to create chart by code and export into image with legend.
After reading your doc and related threads,unfortunately can't find
right answer how to create legend with code. My question is
1. Add legend into RadCartesianChart by code
Following is my code.
RadCartesianChart cartChart = new RadCartesianChart();
cartChart.HorizontalAxis = new LinearAxis() { Maximum = 50, Minimum = 17, MajorStep = 3 };
cartChart.VerticalAxis = new LinearAxis() { LabelFormat = "p0" };
var resultList = CordXy.GetMonthFecundity();
ScatterLineSeries pregSeries = new ScatterLineSeries() { Stroke = new SolidColorBrush(Colors.Blue), StrokeThickness = 2 }; ;
pregSeries.XValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Age" };
pregSeries.YValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Num" };
// ADD Legend
pregSeries.LegendSettings = new SeriesLegendSettings() { Title = "TEST" };
pregSeries.ItemsSource = resultList[0] as IEnumerable<
CordXy
>;
cartChart.Series.Add(pregSeries);
ScatterLineSeries delSeries = new ScatterLineSeries() { Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 2 }; ;
delSeries.XValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Age" };
delSeries.YValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Num" };
// ADD Legend
delSeries.LegendSettings = new SeriesLegendSettings() { Title = "TEST2" };
delSeries.ItemsSource = resultList[1] as IEnumerable<
CordXy
>;
cartChart.Series.Add(delSeries);
// STUCK HERE...
//cartChart.LegendItems.Add(pregSeries.LegendSettings);
//cartChart.LegendItems.Add(delSeries.LegendSettings);
2. Export chart into image with legend
All sample shows legend is placed outside of chart control.
Is it possible to export chart with legend ? or Should I go back to outdated RadCharting ?
TIA.
RGDS
Kang