Bar Chart

Hi,


I am trying to create a chart that looks somewhat similar to the attached image. I am not sure how can I achieve this as the Y axis as you can see should appear at the middle of the chart and the left portion of the chart will show a set of data that will use a different scale than that of the right portion of the chart and hence the scale used by the left side will be different compared to the scale on the right side(sample scale marking shown on image attached). I tied using layouts and adding those to chart but could not get the desired result yet as shown in the image . Also I need to draw the bars with dynamic colors as per the variable values computed in runtime. Can you please help me achieving the desired result as shown in attached image.ChartImg.png


Thanks,

Amitabha


3 Replies

YP Yuvaraj Palanisamy Syncfusion Team July 26, 2021 12:46 PM UTC

Hi Amitabha, 
 
Greetings from Syncfusion.

We have analyzed your query and we have achieved your requirement with the help of multiple axis and custom drawing support in Winforms chart control. Please fine the code example below.
 
 
CodeSnippet: 
private void ChartControl1_ChartAreaPaint(object sender, PaintEventArgs e) 
{ 
              Point ptX = this.chartControl1.ChartArea.GetPointByValue(new ChartPoint(this.chartControl1.PrimaryXAxis.Range.Max, this.chartControl1.PrimaryYAxis.Range.Min)); 
              PointF ptX1 = new PointF(ptX.X - 7, ptX.Y + 7); 
              PointF ptX2 = new PointF(ptX.X, ptX.Y); 
              PointF ptX3 = new PointF(ptX.X + 7, ptX.Y + 7); 
              e.Graphics.FillPolygon(Brushes.Black, new PointF[] { ptX1, ptX2, ptX3 }); 
 
              Point ptY = this.chartControl1.ChartArea.GetPointByValue(new ChartPoint(this.chartControl1.PrimaryXAxis.Range.Min, this.chartControl1.PrimaryYAxis.Range.Max)); 
              PointF ptY1 = new PointF(ptY.X + 7, ptY.Y - 7); 
              PointF ptY2 = new PointF(ptY.X, ptY.Y); 
              PointF ptY3 = new PointF(ptY.X + 7, ptY.Y + 7); 
              e.Graphics.FillPolygon(Brushes.Black, new PointF[] { ptY1, ptY2, ptY3 }); 
 
              var right = this.chartControl1.Axes[2].GetCoordinateFromValue(this.chartControl1.Axes[2].Range.Max); 
              PointF ptsecondY1 = new PointF(right - 7, ptY2.Y - 7); 
              PointF ptsecondY2 = new PointF(right, ptY2.Y); 
              PointF ptsecondY3 = new PointF(right - 7, ptY2.Y + 7); 
              e.Graphics.FillPolygon(Brushes.Black, new PointF[] { ptsecondY1, ptsecondY2, ptsecondY3 });                                 
} 
 
ChartSeriesLegendItem previousSelectedItem; 
Syncfusion.Drawing.BrushInfo previousColor; 
 
Also, we have attached the sample for your reference. Please find the sample from the below link. 
 
  
Output: 
 
 
Regards, 
Yuvaraj. 



AM Amitabha July 28, 2021 05:52 AM UTC

Thanks Yuvaraj,

It Helped.


Amit



YP Yuvaraj Palanisamy Syncfusion Team July 29, 2021 04:34 AM UTC

Hi Amitabha, 
 
Thank you for your update. 
 
Please let us know if you have any concern. 
 
Regards, 
Yuvaraj. 


Loader.
Up arrow icon