mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 16:39:57 +00:00
Add QChart to Python Chart (3h of 5)
Use legend to select which series are plotted by clicking to show hide a series. Hover just shows a hover background and does not temporarily isolate the series, this may be something to consider for later. Applies to scatter and line charts.
This commit is contained in:
@@ -76,6 +76,7 @@ GenericPlot::GenericPlot(QWidget *parent, Context *context) : QWidget(parent), c
|
||||
connect(selector, SIGNAL(hover(QPointF,QString,QAbstractSeries*)), legend, SLOT(hover(QPointF,QString,QAbstractSeries*)));
|
||||
connect(selector, SIGNAL(unhover(QString)), legend, SLOT(unhover(QString)));
|
||||
connect(selector, SIGNAL(unhoverx()), legend, SLOT(unhoverx()));
|
||||
connect(legend, SIGNAL(clicked(QString,bool)), this, SLOT(setSeriesVisible(QString,bool)));
|
||||
|
||||
// config changed...
|
||||
configChanged(0);
|
||||
@@ -211,6 +212,23 @@ GenericPlot::configChanged(qint32)
|
||||
qchart->setBackgroundPen(QPen(GColor(CPLOTMARKER)));
|
||||
}
|
||||
|
||||
void
|
||||
GenericPlot::setSeriesVisible(QString name, bool visible)
|
||||
{
|
||||
// find the curve
|
||||
QAbstractSeries *series = curves.value(name, NULL);
|
||||
|
||||
// does it exist and did it change?
|
||||
if (series && series->isVisible() != visible) {
|
||||
|
||||
// show/hide
|
||||
series->setVisible(visible);
|
||||
|
||||
// tell selector we hid/show a series so it can respond.
|
||||
selector->setSeriesVisible(name, visible);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
GenericPlot::initialiseChart(QString title, int type, bool animate)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user