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

Styling Chartview

8 Answers 136 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Gonzalo
Top achievements
Rank 2
Gonzalo asked on 24 Apr 2012, 05:12 PM
Hi there,

How would you style the slices on a PieChart programatically?

assume this code...
Dim radPieChart1 As New RadPieChart()
Dim series As New PieSeries()
 
series.DataPoints.Add(New PieDataPoint() With {.Value = 100})
series.DataPoints.Add(New PieDataPoint() With {.Value = 35})
series.DataPoints.Add(New PieDataPoint() With {.Value = 15, .OffsetFromCenter = 0.3, .IsSelected = True})
 
 
radPieChart1.Series.Add(series)
 
LayoutQ4.Children.Add(radPieChart1)

I would like to have say... slice 1 blue, slice 2 yellow, slice 3 red...


Thanks and best regards,

8 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 27 Apr 2012, 08:34 AM
Hello Gonzalo,

You can use the SliceStyles property of the pie series. The index of the style in the SliceStyles corresponds to the index of the data point in the DataPoints collection.

The slice style needs to target a Path, and probably the property that you most need is Fill.

I hope this helps.

Kind regards,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Gonzalo
Top achievements
Rank 2
answered on 27 Apr 2012, 02:01 PM
Obrigado! Gracias! Thank you very much for your prompt response.

Would you be so kind to provide and example supporting PieSeries and Barseries?

Thanks for all your support,

G
0
Petar Marchev
Telerik team
answered on 27 Apr 2012, 04:57 PM
Hello Gonzalo,

I have attached a simple app that demonstrates how to use the previously suggested approach. The app consists of a button and a chart view. A slice (and a style) should be added for every click of the button.  

All the best,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Gonzalo
Top achievements
Rank 2
answered on 27 Apr 2012, 06:14 PM
Thanks Petar! I will check this :)
0
Gonzalo
Top achievements
Rank 2
answered on 27 Apr 2012, 09:26 PM
Hi Petar,

Thanks so much for the code! How would you code a BarSeries. In xaml is simple but I am trying to do it in code.

Thanks! Have a great weekend!

G

PS. If there is a repository of sample in regards to ChartView I would appreciate you refer me to it.
0
Petar Marchev
Telerik team
answered on 01 May 2012, 09:17 AM
Hello Gonzalo,

For the bar series you can use the Palette property of the chart view.

If you have installed our controls you should have the WPF examples under your Program Files/Telerik folder. In the upper right corner you can click on the Code tab and see the code for the current demo. (or click here)

You can also check our Silverlight online examples here (the same code should be applicable for WPF).

And you can explore our online help here

Greetings,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Gonzalo
Top achievements
Rank 2
answered on 01 May 2012, 05:43 PM
Greetings,

I have this code from radchart, I would love to move it to radchartview

The xaml looks like this

<telerik:RadChart Grid.Column="1" Grid.Row="1" x:Name="RadChart1" Margin="23,180,28,0" />
The code  behind is :

        RadChart1.DefaultView.ChartTitle.Content = "Current Online SVL Providers"
        RadChart1.DefaultView.ChartLegend.Header = "Legend"
        RadChart1.DefaultView.ChartLegend.UseAutoGeneratedItems = True
 
        'Axis X
        RadChart1.DefaultView.ChartArea.AxisX.Title = "Type"
        RadChart1.DefaultView.ChartArea.AxisX.AutoRange = False
        RadChart1.DefaultView.ChartArea.AxisX.MinValue = 1
        RadChart1.DefaultView.ChartArea.AxisX.MaxValue = 5
        RadChart1.DefaultView.ChartArea.AxisX.[Step] = 1
        RadChart1.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Between
         
'Axis Y
        RadChart1.DefaultView.ChartArea.AxisY.Title = "Provider"
        Dim series As New DataSeries()
        series.Definition = New BarSeriesDefinition()
        series.Definition.Appearance.Fill = New SolidColorBrush(Color.FromArgb(255, 87, 179, 233))
        series.LegendLabel = "Number of Providers"
        For row As Integer = 0 To xValues.Count - 1
            series.Add(New DataPoint(xValues(row), yvalues(row)))
        Next
 
        RadChart1.DefaultView.ChartArea.DataSeries.Add(series)
How can I change it as Radchartview does not seem to support DataSeries and I did not see BarSeries  available?

Best regards,

G

PS. Version 2012.1.416.40
0
Petar Marchev
Telerik team
answered on 02 May 2012, 11:49 AM
Hello Gonzalo,

I will again direct you to our online demos and help. I strongly suggest that you invest time in exploring the control to get you familiar with the control's features, possibilities, limitations and how-to's. You can see how to work with BarSeries in the very first example.

Note that the RadChart and RadChartView are two different controls and they do not have an equivalent for each feature. They are also set-up in a different way. So translating code from one control to the other line-by-line is not the best solution.

Here you can read about some of the differences.

I again encourage you to get to know the control before you start developing your project.

Greetings,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ChartView
Asked by
Gonzalo
Top achievements
Rank 2
Answers by
Petar Marchev
Telerik team
Gonzalo
Top achievements
Rank 2
Share this question
or