Rotating ChartCustomPoint symbols

Good day,

Is it possible to rotate a ChartCustomPoint symbol? ie I would like a ChartSymbolShape.Arrow to point upwards as opposed to the side.

Thanks,
Kyle

1 Reply 1 reply marked as answer

SM Saravanan Madheswaran Syncfusion Team March 12, 2021 09:42 AM UTC

Hi Kyle, 
 
Greetings form Syncfusion support, 
 
We would like to suggest below two solution instead of using ChartSymbolShape type arrow, hence we do not have direct support to rotate shape.  
 
Solution 1: Add arrow image instead of shape type arrow.  
 
ChartCustomPoint cp = new ChartCustomPoint(); 
cp.Symbol.Shape = ChartSymbolShape.Image; 
cp.Images = new ChartImageCollection(this.imageList1.Images); 
cp.Symbol.Shape = ChartSymbolShape.Image; // Set Image to shape property. 
cp.Symbol.ImageIndex = 0; 
cp.Symbol.Size = new Size(24, 24); 
 
Solution 2: Create custom render to add own graphics. 
 
ChartSeries endArrow = new ChartSeries("end Arrow", ChartSeriesType.Custom); 
endArrow.Points.Add(2, 40);//point position 
endArrow.Renderer = new CustomLineRenderer(endArrow); 
this.chartControl1.Series.Add(endArrow); 
this.chartControl1.Series.Add(chartSeries1); 
 
. . . 
. . . 
public class CustomLineRenderer : Syncfusion.Windows.Forms.Chart.ChartSeriesRenderer 
    public CustomLineRenderer(ChartSeries series) 
        : base(series) 
   
   
 
    public override void Render(ChartRenderArgs2D args) 
   
        IndexRange visibleRange = this.CalculateVisibleRange(); 
        ChartStyledPoint[] styledPoints = this.PrepearePoints(); 
 
        Graphics g = (Graphics)args.Graph.GetType().GetProperty("Graphics").GetValue(args.Graph); 
 
        Brush br = new SolidBrush(Color.Red); 
        Pen pen = new Pen(Color.Black); 
        Font font = new Font("Segoe UI", 12); 
 
        for (int i = visibleRange.From; i <= visibleRange.To; i++) 
       
            ChartStyledPoint point = styledPoints[i]; 
 
            if (point.IsVisible) 
           
                GraphicsPath gp = new GraphicsPath(); 
                PointF ptF = args.GetPoint(point.X, point.YValues[0]); 
                const double Deg2Rad = Math.PI / 180.0; 
                var angle = 270; 
 
                var leftAngle = (angle - 30) * Deg2Rad; 
                var rightAngle = (angle + 30) * Deg2Rad; 
                var leftPtF = new PointF(ptF.X - (float)(10 * Math.Cos(leftAngle)), ptF.Y - (float)(10 * Math.Sin(leftAngle))); 
                var rightPtF = new PointF(ptF.X - (float)(10 * Math.Cos(rightAngle)), ptF.Y - (float)(10 * Math.Sin(rightAngle))); 
 
                //Drawing custom symbol\  
                gp.AddLine(ptF, leftPtF); 
                gp.AddLine(leftPtF, rightPtF); 
                gp.AddLine(rightPtF, ptF); 
                g.FillPath(br, gp); 
                g.DrawPath(pen, gp); 
 
           
       
 
        //Disposing Pen, Brush and Font objects  
        font.Dispose(); 
        br.Dispose(); 
        pen.Dispose(); 
   
 
 
 
Regards, 
Saravanan.

Marked as answer
Loader.
Up arrow icon