Hi telerik,
I have to create chart with code not xaml having LogarithmicAxis and LinearAxis, but can't display series successfully
and don't know what is my mistake, though I refered your sample code in this forum and your doc as well.
My code snippet is as follows;
As you see, x-axis is linear which shows age of person and y-axis shows calculated value as logarithmic.
I think I did correct as you told with your sample and doc, but no luck.
Pls see my attached image and advise me what I made a mistake.
Thank you in advance.
RGDS
HK.Lee
I have to create chart with code not xaml having LogarithmicAxis and LinearAxis, but can't display series successfully
and don't know what is my mistake, though I refered your sample code in this forum and your doc as well.
My code snippet is as follows;
private RadCartesianChart GetChart()
{
RadCartesianChart cartChart = new RadCartesianChart();
cartChart.HorizontalAxis = new LinearAxis() { Maximum = 50, Minimum = 17, MajorStep = 3 };
cartChart.VerticalAxis = new LogarithmicAxis() { LogarithmBase = 10, Minimum = 1000, Maximum = 1000000 };
LineSeries lineSeries = new LineSeries() { ShowLabels = true };
// lineSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "Age" };
lineSeries.CategoryBinding = new GenericDataPointBinding<
CordXy
, double>() { ValueSelector = value => value.Age };
lineSeries.ValueBinding = new GenericDataPointBinding<
CordXy
, double>() { ValueSelector = cord => cord.Num };
// lineSeries.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Num" };
lineSeries.ItemsSource = CordXy.GetFollicleList();
cartChart.Series.Add(lineSeries);
DoubleCollection aray = new DoubleCollection(new double[] {1,1});
cartChart.Annotations.Add(
new CartesianCustomLineAnnotation
{
HorizontalFrom = 35,
HorizontalTo = 35,
VerticalFrom = 0,
VerticalTo = 1000000,
Stroke = new SolidColorBrush(Colors.Blue),
StrokeThickness = 2,
DashArray = aray
});
return cartChart;
}
}
public class CordXy
{
public double Age { get; set; }
public double Num { get; set; }
public static ObservableCollection<
CordXy
> GetFollicleList()
{
var result = new ObservableCollection<
CordXy
>();
for (int i = 0; i < 33; i++)
{
var add = new CordXy();
add.Age = i + 18;
add.Num = Math.Pow(10, (5.717 - 0.00019 * Math.Pow(add.Age, 2.452)));
result.Add(add);
}
return result;
}
}
As you see, x-axis is linear which shows age of person and y-axis shows calculated value as logarithmic.
I think I did correct as you told with your sample and doc, but no luck.
Pls see my attached image and advise me what I made a mistake.
Thank you in advance.
RGDS
HK.Lee