Associate Annotation With Individual Series

Hi,

Is there any way to associate an annotation with a specific series so that the annotations are displayed/hidden when the individual series on the legend is selected/unselected?

Thank you,

Dean


1 Reply

DR Dhanaraj Rajendran Syncfusion Team May 17, 2024 01:55 PM UTC

Hi Dean,


Yes, you can associate the visibility of an annotation with a specific series by binding the IsSeriesVisible property of the series to the Visibility property of the annotation. This way, the annotation will be displayed or hidden when you toggle the visibility of the associated series in the legend. Here is a code snippet to demonstrate this:

<Grid>

    <chart:SfChart>

 

        <chart:SfChart.Legend>

            <chart:ChartLegend ToggleSeriesVisibility="True"/>

        </chart:SfChart.Legend>

 

        <chart:SfChart.Annotations>

            <chart:VerticalLineAnnotation Visibility="{Binding IsSeriesVisible,ElementName=lineSeries}"/>

        </chart:SfChart.Annotations>

 

        <chart:LineSeries IsSeriesVisible="False" x:Name="lineSeries" />

        <chart:LineSeries IsSeriesVisible="True" x:Name="lineSeries2" />

 

    </chart:SfChart>

</Grid>


Output:


We have also attached a prepared sample for your reference.

If you have any questions or need further assistance, feel free to ask. We're here to help.


Regards,

Dhanaraj Rajendran.


Attachment: SF_F188298_6cf975c6.zip

Loader.
Up arrow icon