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

Spline Chart

1 Answer 87 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Ashraf Syed
Top achievements
Rank 1
Ashraf Syed asked on 29 Nov 2010, 11:41 PM
1. How can I create a Spline chart like in WPF Chart example with custom Values(it will help me to understand the structure)?

I tried 
List<double[]> itemsSource = new List<double[]>();
itemsSource.Add(SeriesExtensions.GetUserData(12, 0));
itemsSource.Add(SeriesExtensions.GetUserData(12, 1));

but "SeriesExtensions" gives me an error.

2. Is it possible to Align the Y-Axis label?..by default it's center align.
Thanks

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 01 Dec 2010, 02:38 PM
Hi Ashraf ,

Thanks for contacting us.
1. This is the full code-behind for creating Spline Chart as shown in our example - http://demos.telerik.com/wpf/#Chart/Gallery/Spline
Copy Code
public partial class MainWindow : Window
   {
       private static double[,] constsY = new double[3, 12] { {24, 9, 18, 31, 25, 13, 17, 33, 21, 28, 19, 11},
                                                             {6, 19, 28, 11, 15, 31, 27, 14, 19, 21, 30, 15},
                                                             {17, 8, 31, 22, 26, 12, 23, 17, 28, 19, 24, 29}};
       public MainWindow()
       {
           InitializeComponent();
           this.FillSampleChartData();
           RadChart1.DefaultView.ChartArea.AxisY.AxisStyles.TitleStyle = this.Resources["AxisTitleStyle"] as Style; 
       }
       private void FillSampleChartData()
       {
           SeriesMapping sm1 = new SeriesMapping();
           sm1.SeriesDefinition = new SplineSeriesDefinition();
           sm1.LegendLabel = "Spline Series 1";
           sm1.CollectionIndex = 0;
           ItemMapping im1 = new ItemMapping();
           im1.DataPointMember = DataPointMember.YValue;
           sm1.ItemMappings.Add(im1);
           SeriesMapping sm2 = new SeriesMapping();
           sm2.SeriesDefinition = new SplineSeriesDefinition();
           sm2.LegendLabel = "Spline Series 2";
           sm2.CollectionIndex = 1;
           ItemMapping im2 = new ItemMapping();
           im2.DataPointMember = DataPointMember.YValue;
           sm2.ItemMappings.Add(im2);
           RadChart1.SeriesMappings.Add(sm1);
           RadChart1.SeriesMappings.Add(sm2);
           List<double[]> itemsSource = new List<double[]>();
           itemsSource.Add(GetUserData(12, 0));
           itemsSource.Add(GetUserData(12, 1));
           RadChart1.ItemsSource = itemsSource;
           RadChart1.DefaultView.ChartArea.AxisY.Title = "Axis Y";
       }
       public static double[] GetUserData(int numberOfItems, int seriesIndex)
       {
           int ind = seriesIndex % 3;
           double[] points = new double[numberOfItems];
           for (int i = 0; i < numberOfItems; i++)
               points[i] = constsY[ind, i];
           return points;
       }
   }

2. To be able to change the alignment of Axis Labels you can review our help topic - http://www.telerik.com/help/wpf/radchart-styling-and-appearance-styling-axis-title.html.

Please let me know if I can assist you any further.

Regards,
Evgenia
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
Chart
Asked by
Ashraf Syed
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or