How to remove annotation from a C1flexchart

Posted by: mohamad.zaman on 5 March 2020, 6:47 am EST

  • Posted 5 March 2020, 6:47 am EST

    Hello

    Could you please help me to solve my problem.

    I want to add annotations (text) through first loop and delete and then update annotations (text) to new values. I do not know how to delete or clear the annotations (text) created in the previous steps. I have attached a section of my code representing my problem.

    Thank you very much.

    C1.Win.Chart.Annotation.AnnotationLayer zBeamSecIdAnnotationLayer = new AnnotationLayer(flexChart1);

    zBeamSecIdAnnotationLayer.Annotations.Clear();

    C1.Win.Chart.Annotation.Text zbeamAnnoText = new Text();

            for (int i = 0; i < Ns; i++)
            {
                for (int j = 0; j < Nb; j++)
                {
                    if (zDisplayBeamSecName == true)
                    {
                        //zbeamAnnoText = new Text();
                        zbeamAnnoText.Content = zBeamSecId[Nb * i + j];
                        zbeamAnnoText.Attachment = AnnotationAttachment.DataCoordinate;
                        zbeamAnnoText.Location = new PointF(
                            (float)((XMainNodes[(i + 1) * (Nb + 1) + j] + XMainNodes[(i + 1) * (Nb + 1) + j + 1]) / 2),
                            (float)((YMainNodes[(i + 1) * (Nb + 1) + j] + YMainNodes[(i + 1) * (Nb + 1) + j + 1]) /
                                     2) + 200);
                        zbeamAnnoText.Style.StrokeColor = Color.Cyan;
                        zBeamSecIdAnnotationLayer.Annotations.Add(zbeamAnnoText);
                    }
                    else
                    {
                        zBeamSecIdAnnotationLayer.Annotations.Clear();
                    }
                }
            }
    
  • Posted 6 March 2020, 6:22 am EST

    Hi,

    I could not spot any issue with the provided code snippet. Using AnnotationLayer.Annotations.Clear() should have cleared annotations from the chart. Could you please verify by using the attached sample and share your observations with us.

    Also, it seems like you just want to show some text from data for the corresponding data point on the chart. If so, I would suggest considering using DataLabels. You can refer to the documentation for details on DataLabels from https://www.grapecity.com/componentone/docs/win/online-flexchart/datalabels.html.

    AnnotatePointsWithText.zip

    Regards,

    Basant

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels