Setting colors in chart view

2 posts, 0 answers
  1. Eli
    Eli avatar
    34 posts
    Member since:
    Oct 2011

    Posted 12 Mar 2012 Link to this post

    I am using Telerik version 2012.1
    What I am trying to do is to build a chart with a single source of data. But the source, the chart type, and the color should be able to be selected in drop down comboboxes. I am having trouble figuring out how to get the color set, don't know if it is because I have a generic chart in the XAML and am setting the series definition in an attached property, or if there is another reason. Below is a sample of my code, let me know if you need more. Thank you,


            <charting:RadChart Grid.Row="3"<br>                           PaletteBrushesUseSolidColors="True"<br>                           Name="lineChart"><br>          <br>            <attached:SeriesMapper.BindingInfo><br>                <attached:SeriesBindingInfo DataTable="{Binding DataTable}"<br>                                            EmissionsTemplate="{Binding Template}" /><br>            </attached:SeriesMapper.BindingInfo><br><br>            <charting:RadChart.DefaultView><br>                <Charting:ChartDefaultView><br>                    <Charting:ChartDefaultView.ChartLegend><br>                        <Charting:ChartLegend Name="legend3" /><br>                    </Charting:ChartDefaultView.ChartLegend><br>                    <Charting:ChartDefaultView.ChartArea><br>                        <Charting:ChartArea LegendName="legend3"<br>                                            Legend="{Binding Template.CurrentTemplate}"><br>                            <Charting:ChartArea.ZoomScrollSettingsX><br>                                <Charting:ZoomScrollSettings ScrollMode="ScrollAndZoom"<br>                                                             MinZoomRange=".005" /><br>                            </Charting:ChartArea.ZoomScrollSettingsX><br><br>                            <Charting:ChartArea.AxisX><br>                                <Charting:AxisX DefaultLabelFormat="{Binding AxisXLabelFormat}"<br>                                                LabelStep="12"<br>                                                Title="Date"<br>                                                LayoutMode="Between" /><br>                            </Charting:ChartArea.AxisX><br>                            <Charting:ChartArea.AxisY><br>                                <Charting:AxisY AutoRange="True"<br>                                                Title="{Binding Template.SelectedYColumn.Alias}"<br>                                                ExtendDirection="None" /><br>                            </Charting:ChartArea.AxisY><br>                        </Charting:ChartArea><br>                    </Charting:ChartDefaultView.ChartArea><br>                </Charting:ChartDefaultView><br>            </charting:RadChart.DefaultView><br>        </charting:RadChart>

    <br>        private static SeriesDefinition CreateSeriesDefinition(string seriesType)<br>        {<br>            SeriesDefinition series = null;<br><br>            switch (seriesType)<br>            {<br>                case "Line":<br>                    series = CreateLineSeriesDefinition();<br>                    break;<br>                case "Scatter":<br>                    series = CreateScatterSeriesDefinition();<br>                    break;<br>                case "Spline":<br>                    series = CreateSplineSeriesDefinition();<br>                    break;<br>            }<br><br>            series.Appearance.Foreground = new SolidColorBrush(SystemColors.ControlDarkColor);<br>            return series;<br>        }
  2. Sia
    Sia avatar
    667 posts

    Posted 15 Mar 2012 Link to this post

    Hello Eli,

    Why do not you try a similar approach as shown in our examples, i.e. this one? Here also can be find similar example. If this does not help, please send us a sample project showing your exact scenario and we will modify it for you.

    All the best,
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft R3 2016 release webinar banner
Back to Top