This question is locked. New answers and comments are not allowed.
Hi,
I am trying to use my own stylepallet for LineSeries.i have defined style pallete in XAML as below:
following is my code behind file:
Error:
"Unhandled error in Silverlight application.Code:4004,Category:ManagedRuntime Error".
Please let me know what is wrong with the code.? and how to resolve this issue.
I am using DLL-"Telerik.Windows.Controls.Charting" Version:"2009.3.1314.1030"
One more thing: Wt I have observed is that- If I use DataSeries , Line Style gets applied to the chart. (NOTE:I don;t want to use line series. :) I want to use Series Mapping for Chart. )
Thanks,
Vinod Sardar.
I am trying to use my own stylepallet for LineSeries.i have defined style pallete in XAML as below:
| <UserControl> |
| <UserControl.Resources> |
| <chart:StylesPalette x:Key="LineStyle"> |
| <Style TargetType="Shape"> |
| <Setter Property="Fill" |
| Value="Yellow" /> |
| </Style> |
| <Style TargetType="Shape"> |
| <Setter Property="Fill" |
| Value="Orange" /> |
| </Style> |
| </chart:StylesPalette> |
| </UserControl.Resources> |
| <Grid x:Name="LayoutRoot" Background="White"> |
| <telerik:RadChart x:Name="RadChart1" /> |
| </Grid> |
| </UserControl> |
following is my code behind file:
| public partial class MainPage : UserControl |
| { |
| #region Properties |
| public string GroupedBy { get; set; } |
| public string XAxisProperty { get; set; } |
| public string YAxisProperty { get; set; } |
| #endregion |
| public MainPage() |
| { |
| InitializeComponent(); |
| SetProperties(); |
| this.Loaded += Page_Loaded; |
| } |
| private void Page_Loaded(object sender, RoutedEventArgs e) |
| { |
| //DataSeries series = new DataSeries(); |
| ////series.Definition = new LineSeriesDefinition(); |
| //series.Definition = new DoughnutSeriesDefinition(); |
| //series.Add(new DataPoint(45) { LegendLabel = "NO" }); |
| //series.Add(new DataPoint(55) { LegendLabel = "YES" }); |
| //RadChart1.DefaultView.ChartArea.DataSeries.Add(series); |
| //RadChart1.Loaded += RadChart1_Loaded; |
| //RadChart1.ItemsSource = series; |
| ////For STOCKS DATA |
| //SeriesMapping s = new SeriesMapping(); |
| //LineSeriesDefinition lineSeries = new LineSeriesDefinition(); |
| //s.SeriesDefinition = lineSeries; |
| ////s.LegendLabel = key; |
| ////s.CollectionIndex = groupDic[key]; |
| //s.ItemMappings.Add(new ItemMapping(YAxisProperty, DataPointMember.YValue)); |
| //s.ItemMappings.Add(new ItemMapping(XAxisProperty, DataPointMember.XCategory)); |
| ////s.ChartArea = nomuraChartArea; |
| //RadChart1.SeriesMappings.Add(s); |
| //this.RadChart1.DefaultView.ChartArea.SeriesStyles.LineSeriesStyle = this.Resources[ "LineStyle1" ] as Style; |
| RadChart1.DefaultSeriesDefinition = new LineSeriesDefinition(); |
| RadChart1.ItemsSource = Stock.GetStocks(); |
| } |
| private void RadChart1_Loaded(object sender, RoutedEventArgs e) |
| { |
| //RadChart1.DefaultView.ChartLegend.Items[0].Background = new SolidColorBrush(Colors.Red); |
| //RadChart1.DefaultView.ChartLegend.Items[1].Background = new SolidColorBrush(Colors.Green); |
| } |
| private void SetProperties() |
| { |
| GroupedBy = "Name"; |
| XAxisProperty = "Month"; |
| YAxisProperty = "Volume"; |
| } |
| } |
| public class Stock |
| { |
| public string Name { get; set; } |
| public string Month { get; set; } |
| public double Volume { get; set; } |
| public double Price { get; set; } |
| public static IEnumerable GetStocks() |
| { |
| List<Stock> _lstStocks = new List<Stock>(); |
| Stock s9 = new Stock(); |
| s9.Name = "Total"; |
| s9.Month = "JAN"; |
| s9.Volume = 110; |
| s9.Price = 90; |
| Stock s10 = new Stock(); |
| s10.Name = "Total"; |
| s10.Month = "FEB"; |
| s10.Volume = 160; |
| s10.Price = 125; |
| Stock s11 = new Stock(); |
| s11.Name = "Total"; |
| s11.Month = "March"; |
| s11.Volume = 140; |
| s11.Price = 150; |
| Stock s12 = new Stock(); |
| s12.Name = "Total"; |
| s12.Month = "April"; |
| s12.Volume = 110; |
| s12.Price = 97; |
| Stock s13 = new Stock(); |
| s13.Name = "Total"; |
| s13.Month = "May"; |
| s13.Volume = 290; |
| s13.Price = 210; |
| Stock s14 = new Stock(); |
| s14.Name = "Total"; |
| s14.Month = "June"; |
| s14.Volume = 140; |
| s14.Price = 185; |
| //Institutional |
| Stock s15 = new Stock(); |
| s15.Name = "Institutional"; |
| s15.Month = "JAN"; |
| s15.Volume = 110; |
| s15.Price = 90; |
| Stock s16 = new Stock(); |
| s16.Name = "Institutional"; |
| s16.Month = "FEB"; |
| s16.Volume = 160; |
| s16.Price = 125; |
| Stock s17 = new Stock(); |
| s17.Name = "Institutional"; |
| s17.Month = "March"; |
| s17.Volume = 90; |
| s17.Price = 150; |
| Stock s18 = new Stock(); |
| s18.Name = "Institutional"; |
| s18.Month = "April"; |
| s18.Volume = 145; |
| s18.Price = 97; |
| Stock s19 = new Stock(); |
| s19.Name = "Institutional"; |
| s19.Month = "May"; |
| s19.Volume = 189; |
| s19.Price = 210; |
| Stock s20 = new Stock(); |
| s20.Name = "Institutional"; |
| s20.Month = "June"; |
| s20.Volume = 120; |
| s20.Price = 185; |
| //For Total |
| _lstStocks.Add(s9); |
| _lstStocks.Add(s10); |
| _lstStocks.Add(s11); |
| _lstStocks.Add(s12); |
| _lstStocks.Add(s13); |
| _lstStocks.Add(s14); |
| //for institutional |
| _lstStocks.Add(s15); |
| _lstStocks.Add(s16); |
| _lstStocks.Add(s17); |
| _lstStocks.Add(s18); |
| _lstStocks.Add(s19); |
| _lstStocks.Add(s20); |
| return _lstStocks as IEnumerable; |
| } |
| public static List<Stock> GetStocksWithIndexList() |
| { |
| List<List<Stock>> _indexList = new List<List<Stock>>(); |
| List<Stock> _lstStocks = new List<Stock>(); |
| Stock s9 = new Stock(); |
| s9.Name = "Total"; |
| s9.Month = "JAN"; |
| s9.Volume = 110; |
| s9.Price = 90; |
| Stock s10 = new Stock(); |
| s10.Name = "Total"; |
| s10.Month = "FEB"; |
| s10.Volume = 160; |
| s10.Price = 125; |
| Stock s11 = new Stock(); |
| s11.Name = "Total"; |
| s11.Month = "March"; |
| s11.Volume = 140; |
| s11.Price = 150; |
| Stock s12 = new Stock(); |
| s12.Name = "Total"; |
| s12.Month = "April"; |
| s12.Volume = 110; |
| s12.Price = 97; |
| Stock s13 = new Stock(); |
| s13.Name = "Total"; |
| s13.Month = "May"; |
| s13.Volume = 290; |
| s13.Price = 210; |
| Stock s14 = new Stock(); |
| s14.Name = "Total"; |
| s14.Month = "June"; |
| s14.Volume = 140; |
| s14.Price = 185; |
| //Institutional |
| Stock s15 = new Stock(); |
| s15.Name = "Institutional"; |
| s15.Month = "JAN"; |
| s15.Volume = 110; |
| s15.Price = 90; |
| Stock s16 = new Stock(); |
| s16.Name = "Institutional"; |
| s16.Month = "FEB"; |
| s16.Volume = 160; |
| s16.Price = 125; |
| Stock s17 = new Stock(); |
| s17.Name = "Institutional"; |
| s17.Month = "March"; |
| s17.Volume = 90; |
| s17.Price = 150; |
| Stock s18 = new Stock(); |
| s18.Name = "Institutional"; |
| s18.Month = "April"; |
| s18.Volume = 145; |
| s18.Price = 97; |
| Stock s19 = new Stock(); |
| s19.Name = "Institutional"; |
| s19.Month = "May"; |
| s19.Volume = 189; |
| s19.Price = 210; |
| Stock s20 = new Stock(); |
| s20.Name = "Institutional"; |
| s20.Month = "June"; |
| s20.Volume = 120; |
| s20.Price = 185; |
| //For Total |
| _lstStocks.Add(s9); |
| _lstStocks.Add(s11); |
| _lstStocks.Add(s12); |
| _lstStocks.Add(s13); |
| _lstStocks.Add(s14); |
| //for institutional |
| _lstStocks.Add(s15); |
| _lstStocks.Add(s16); |
| _lstStocks.Add(s17); |
| _lstStocks.Add(s18); |
| _lstStocks.Add(s19); |
| _lstStocks.Add(s20); |
| _indexList.Add(_lstStocks); |
| //_indexList.Add(_lstStocks); |
| return _lstStocks; |
| } |
| } |
Error:
"Unhandled error in Silverlight application.Code:4004,Category:ManagedRuntime Error".
Please let me know what is wrong with the code.? and how to resolve this issue.
I am using DLL-"Telerik.Windows.Controls.Charting" Version:"2009.3.1314.1030"
One more thing: Wt I have observed is that- If I use DataSeries , Line Style gets applied to the chart. (NOTE:I don;t want to use line series. :) I want to use Series Mapping for Chart. )
Thanks,
Vinod Sardar.