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

Dashed border

1 Answer 96 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Pauli
Top achievements
Rank 2
Pauli asked on 28 Apr 2015, 03:59 PM

Hi

How can I get dashed line around pink part of the pie and bar in the attached picture?

 Pauli

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Apr 2015, 12:26 PM
Hello Pauli,

Thank you for writing.

You can subscribe to the RadChartView.CreatePointElement event and apply the desired style regarding the border. Here is a sample code snippet demonstrating how customize the BarPointElement and the PiePointElement:
public Form1()
{
    InitializeComponent();
 
    this.radChartView1.CreatePointElement += radChartView1_CreatePointElement;
    BarSeries barSeries = new BarSeries("Performance", "RepresentativeName");
    barSeries.Name = "Q1";          
    barSeries.DataPoints.Add(new CategoricalDataPoint(177, "Harley"));
    barSeries.DataPoints.Add(new CategoricalDataPoint(128, "White"));
    barSeries.DataPoints.Add(new CategoricalDataPoint(143, "Smith"));
    barSeries.CombineMode = ChartSeriesCombineMode.Stack;
    this.radChartView1.Series.Add(barSeries);
 
    BarSeries barSeries2 = new BarSeries("Performance", "RepresentativeName");
    barSeries2.Name = "Q2";
    barSeries2.DataPoints.Add(new CategoricalDataPoint(153, "Harley"));
    barSeries2.DataPoints.Add(new CategoricalDataPoint(141, "White"));
    barSeries2.DataPoints.Add(new CategoricalDataPoint(130, "Smith"));
    barSeries2.CombineMode = ChartSeriesCombineMode.Stack;
    this.radChartView1.Series.Add(barSeries2);
 
    this.radChartView2.CreatePointElement += radChartView2_CreatePointElement;
    this.radChartView2.AreaType = ChartAreaType.Pie;
    PieSeries series = new PieSeries();       
    series.DataPoints.Add(new PieDataPoint(50, "Germany"));
    series.DataPoints.Add(new PieDataPoint(70, "United States"));
    series.DataPoints.Add(new PieDataPoint(40, "France"));
    series.DataPoints.Add(new PieDataPoint(25, "United Kingdom"));
    this.radChartView2.Series.Add(series);
     
}
 
private void radChartView2_CreatePointElement(object sender, ChartViewCreatePointElementEventArgs e)
{
    PieDataPoint pieDatPoint = e.DataPoint as PieDataPoint ;
    if (pieDatPoint != null && pieDatPoint.LegendTitle == "United States")
    {
        PiePointElement pieElement = new PiePointElement(pieDatPoint);
        e.DataPointElement = pieElement;
        pieElement.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
        pieElement.BorderColor = Color.Black;
        pieElement.BackColor = Color.Fuchsia;
    }
}
 
private void radChartView1_CreatePointElement(object sender, ChartViewCreatePointElementEventArgs e)
{
    CategoricalDataPoint c = e.DataPoint as CategoricalDataPoint;
    if (c != null & e.Series is BarSeries & e.Series.Name == "Q2" & c.Category == "White")
    {
        BarPointElement barElement = new BarPointElement(e.DataPoint);
        barElement.BorderWidth = 2;
        barElement.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
        barElement.BackColor = Color.Fuchsia;
        barElement.BorderColor = Color.Black;
        e.DataPointElement = barElement;           
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.
 
Regards,
Dess
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
ChartView
Asked by
Pauli
Top achievements
Rank 2
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or