Search code examples
c#winformschartssyncfusion

How to place the label of ChartCustomPoint in a Syncfusion Chart (winform)


I have a syncfusion chart in my winform application. I add a series of data. I want to highlight a specific point of the series (let's say the 25th data point of the first series) with a red circle and the "Focus" text.

ChartCustomPoint cp = new ChartCustomPoint();
cp.CustomType = ChartCustomPointType.PointFollow;
cp.PointIndex=25;
cp.SeriesIndex=1;
cp.Symbol.Shape = ChartSymbolShape.Circle;
cp.Symbol.Color = Color.Red;
cp.Symbol.Marker.LineInfo.Width = 4;
cp.Alignment = ChartTextOrientation.Up;
cp.Text = "Focus";
chartControl1.CustomPoints.Add(cp);

but, the displayed text is stuck to the symbol. I would like to add space between the label and the symbol. Is there a property I missed ?

Thank you


Solution

  • Thanks for using Syncfusion Products. We have analyzed your query. While using the Custom Points the space between the text and the symbol can be provided by using the Alignment property of the Custom points. The alignment property is used to align the text in the center, top, topleft , topright ,left ,right ,bottom ,bottomleft ,bottomright and when the symbol is present the RegionUp, RegionDown, RegionCenter will consider the symbol and the align the text accordingly. When the RegionUp is set to the alignment the space is provided between the symbol and the text

           ChartCustomPoint cp1 = new ChartCustomPoint();
           // Point that follows a series point:
           cp1.PointIndex = 2;
           cp1.SeriesIndex = 0;
           cp1.CustomType = ChartCustomPointType.PointFollow;
           cp1.Symbol.Shape = ChartSymbolShape.Circle;
           cp1.Offset = 20;
           cp1.Font.Facename = "Times New Roman";
           cp1.Font.Bold = true;
           cp1.Font.Size = 11f;
           cp1.Symbol.Color = Color.FromArgb(0Xc1, 0X39, 0x2b);
           // Provide space between the symbol and the text
           cp1.Alignment = ChartTextOrientation.RegionUp;
           cp1.Text = "Circle";
           cp1.Symbol.Marker.LineInfo.Width = 4;
           chart.CustomPoints.Add(cp1);
    

    We have attached the sample for your reference. Sample link:http://www.syncfusion.com/downloads/support/directtrac/general/ze/Custom_points-2112217385

    Please let us know if you have any concerns.

    Regards,

    Deepaa.