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

RadControlsSilverlightCourseware MVVM.

1 Answer 54 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Natália
Top achievements
Rank 1
Natália asked on 11 Aug 2010, 03:52 PM
Hello!

Development in the sample(MVVM) obtained on RadControlsSilverlightCourseware.
But the series were not color what might be happening?

thanks
public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            chart.Loaded += new RoutedEventHandler(chart_Loaded);
        }
  
        void chart_Loaded(object sender, RoutedEventArgs e)
        {
            List<Pepper> peppers = new List<Pepper>()
            {
                new Pepper() { Name = "Pimento", ScovilleRating = 250 },
                new Pepper() { Name = "Poblano Pepper", ScovilleRating = 500 },
                new Pepper() { Name = "Jalapeno Pepper", ScovilleRating = 2500 },
                new Pepper() { Name = "Cayenne Pepper", ScovilleRating = 10000 }
            };
  
            List<PepperViewModel> viewModel = new List<PepperViewModel>();
  
            foreach (Pepper pepper in peppers)
            {
                viewModel.Add(new PepperViewModel(pepper));
            }
  
            // setup the grid to display name and rating
            chart.DefaultSeriesDefinition = new BarSeriesDefinition() { ItemStyle = this.ScovilleStyle };
            SeriesMapping mapping = new SeriesMapping();
            mapping.ItemMappings.Add(new ItemMapping("Pepper.ScovilleRating", DataPointMember.YValue));
            mapping.ItemMappings.Add(new ItemMapping("Pepper.Name", DataPointMember.XCategory));
            chart.SeriesMappings.Add(mapping);
            // bind view model to chart
            chart.ItemsSource = viewModel;
  
            chart.DefaultView.ChartLegend.Visibility = Visibility.Collapsed;
            chart.DefaultView.ChartTitle.Content = "Scoville Scale";
            chart.DefaultView.ChartTitle.Foreground = new SolidColorBrush(Colors.Red);
            chart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;
  
            chart.DefaultView.ChartArea.AxisY.AxisStyles.AxisLineStyle = this.Resources["CustomAxisStyle"] as Style;
            chart.DefaultView.ChartArea.AxisY.AxisStyles.ItemLabelStyle = this.Resources["CustomItemLabelStyle"] as Style;
            chart.DefaultView.ChartArea.AxisX.AxisStyles.AxisLineStyle = this.Resources["CustomAxisStyle"] as Style;
            chart.DefaultView.ChartArea.AxisX.AxisStyles.ItemLabelStyle = this.Resources["CustomItemLabelStyle"] as Style;
        }
    }

1 Answer, 1 is accepted

Sort by
0
Natália
Top achievements
Rank 1
answered on 11 Aug 2010, 09:16 PM
Do not worry. The problem was the name of a method that was wrong.
Tags
Chart
Asked by
Natália
Top achievements
Rank 1
Answers by
Natália
Top achievements
Rank 1
Share this question
or