Skip to content

Latest commit

 

History

History
88 lines (71 loc) · 2.84 KB

kb-chartview-howto-conditionally-hide-label-connectors.md

File metadata and controls

88 lines (71 loc) · 2.84 KB
title description type page_title slug position tags ticketid res_type
How to hide/not show the label connector based on datapoint's value or property.
Conditionally hide label connector.
how-to
Show label connector only for certain datapoints.
kb-chartview-howto-conditionally-hide-label-connectors
0
hide, label, connector
1411891
kb

Environment

Product Version 2017.3.913 or later
Product RadChartView for WPF

Description

Choose which label connectors are visible depending on the datapoint.

Solution

Define a custom series and override its GetLabelConnector method. The following examples demonstrate how to create a custom [ScatterLineSeries]({%slug radchartview-series-scatterlineseries%}) and hide the label connector of all points with XValue of 1.

[C#]

{{region cs-kb-chartview-howto-conditionally-hide-label-connectors-0}} public class CustomScatterLineSeries : ScatterLineSeries { protected override List GetLabelConnector(ChartSeriesLabelPositionInfo info) { //info.DataPoint.DataItem will contain the bound object in a data binding scenario

        var dataPoint = info.DataPoint as ScatterDataPoint;

        if (dataPoint != null && dataPoint.XValue == 1)
        {
            return new List<Point>() { new Point(), new Point() };
        }

        return base.GetLabelConnector(info);
    }
}

{{endregion}}

[C#]

{{region xaml-kb-chartview-howto-conditionally-hide-label-connectors-1}} <Grid.Resources> <telerik:ChartSeriesLabelConnectorsSettings x:Key="LabelConnectorSettings" /> </Grid.Resources> telerik:RadCartesianChart telerik:RadCartesianChart.HorizontalAxis telerik:LinearAxis/ </telerik:RadCartesianChart.HorizontalAxis>

		<telerik:RadCartesianChart.VerticalAxis>
			<telerik:LinearAxis/>
		</telerik:RadCartesianChart.VerticalAxis>

        <local:CustomScatterLineSeries ShowLabels="True" LabelConnectorsSettings="{StaticResource LabelConnectorSettings}" >
            <local:CustomScatterLineSeries.DataPoints>
				<telerik:ScatterDataPoint XValue="1" YValue="2"/>
				<telerik:ScatterDataPoint XValue="2" YValue="3"/>
				<telerik:ScatterDataPoint XValue="4" YValue="5"/>
				<telerik:ScatterDataPoint XValue="5" YValue="6"/>
				<telerik:ScatterDataPoint XValue="7" YValue="8"/>
			</local:CustomScatterLineSeries.DataPoints>
		</local:CustomScatterLineSeries>
	</telerik:RadCartesianChart>
</Grid>

{{endregion}}

Figure 1: Custom ScatterLineSeries with one hidden label connector

Custom ScatterLineSeries with one hidden label connector

See Also

  • [Label Connectors]({%slug radchartview-features-label-connectors%})