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

Setting colors in chart view

1 Answer 103 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Eli
Top achievements
Rank 1
Eli asked on 12 Mar 2012, 10:25 PM
Hello,
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,

Eli

        <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>        }

1 Answer, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 15 Mar 2012, 04:20 PM
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,
Sia
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Chart
Asked by
Eli
Top achievements
Rank 1
Answers by
Sia
Telerik team
Share this question
or