7 Answers, 1 is accepted
By design Chart's PlotBands does not have any tooltip / labels. If you wish you can submit this idea as a feature request at our UserVoice portal - this way the community would be able to evaluate it and if the suggestion gains popularity we will consider its implementation.
the Telerik team
Kindly let us know if solution is available for this query.
In our project we need to show label for plotbands, because in case of multiple axis user is confused that for which axis it is plotted.
There is no a specific plotBands label option available in Kendo UI Chart, however you could draw text via the Drawing API. Take a look at the following examples which should give a basic idea:
- http://dojo.telerik.com/@Iliana/odAce (using the valueAxis.labels.visual option)
Telerik by Progress
Is it possible to get the rect geometry that the plotband is drawn into to place the text?
It isn't possible to get the plotband rect using the Chart APIs. However, you can draw a custom line/rectangle in the Chart on render, which could also have a Text element added. This help article shows such an example:
Render Custom Plot Bands
Hi we followed the example you mentionned, and it worked well.
However a major limitation to this approach emerged as everything customly drawn is rendered on top of the graphical chart elements (series/points mainly), which results in clicks on points or series to be lost.
Is there a way to let the events go through the shapes drawn so the click events still get captured correctly by the underneath points?
The custom drawn UI indeed captures the click event and prevents it from reaching the series. Unfortunately, there is no way to prevent this as the custom UI is added after the rest of the Chart is already drawn. Also, I cannot suggest a way to propagate the event to the series point lying beneath the custom plot band.
For this scenario, it is maybe better to go one step back where you were considering adding only custom text to already existing plot bands. You could try the following:
1. Use regular plot bands.
2. In the Chart render event, access the value axis and, using its slot() method, find the slot where the plot band is drawn using the to and from values of the plot band.
3. Using the coordinates of the returned slot, determine a position for your custom text and draw it in the Chart.
With this approach, series click will be prevented only if the user clicks on the text but not for the entire plot band:
Additionally, you could vote for the feature request for labels in the regular plot bands to help raise its priority:
Add labelling and tooltips to chart plot bands