Custom legend for chart?
Solved
General and Desktop
-
I have a QChart with multiple QLineSeries, that come from 2 sources - so each series get a color according to it's source. I want to have a legend only with the two sources but the native legend is based on all of the QLineSeries. Is there a way to custom the legend? Assign specific text values, or remove unwanted ones so only the 2 sources will remain?
Thanks -
Hi
You can get its legend
QLegend *QChart::legend() const
and then
https://doc.qt.io/qt-5/qlegend.html#markers
and you can then hide markers with
https://doc.qt.io/qt-5/qlegendmarker.html#setVisibleas far as i know its not possible to create a new legend as you cant assign it to the chart/series.
-
Thanks, got it working!