If you followed the getting started article, you now know how to create a chart and add it to a NativeScript page.
RadPieChart both can display a legend. In
RadCartesianChart the legend annotates each of the series, while in
RadPieChart the legend annotates the data points within the chart. In this article you will learn how to show a legend in your chart and how to customize its behavior and appearance.
To define a legend in your chart you need to use the
Example 1: A Cartesian Chart with a Legend
<RadLegendView tkCartesianLegend position="Top" title="Series type" height="150" enableSelection="true"></RadLegendView>
Figure 1: Legend shown in action on Android (left) and iOS (right)
position- used to define the position of the legend. Possible values for this property are defined by the
horizontalOffset- used to define a horizontal offset for the legend. This offset is calculated considering the currently set
verticalOffset- used to define a vertical offset for the legend. This offset is calculated considering the currently set
offsetOrigin- used to define the point relative to which the offsets are calculated. Possible values for this property are defined by the
title- used to define a title for the legend
titleColor- used to define the text color of the legend title
titleSize- used to define the text size of the legend title
enableSelection- determines whether Series or DataPoints in the Chart are automatically selected upon tapping on an item in the Legend
Want to see this scenario in action? Check our SDK Examples repository on GitHub. You will find this and many other practical examples with NativeScript UI.
Examples used in this article:
Related articles you might find useful: