diff --git a/src/Charts/GenericPlot.cpp b/src/Charts/GenericPlot.cpp index dc40b2435..4ee7884fc 100644 --- a/src/Charts/GenericPlot.cpp +++ b/src/Charts/GenericPlot.cpp @@ -736,6 +736,8 @@ GenericPlot::addCurve(QString name, QVector xseries, QVector yse { // set up the curves QPieSeries *add = new QPieSeries(); + add->setPieSize(0.7); + add->setHoleSize(0.5); // setup the slices for(int i=0; ilog) vaxis= new QLogValueAxis(qchart); else vaxis= new QValueAxis(qchart); add=vaxis; // gets added later - vaxis->setMin(axisinfo->min()); vaxis->setMax(axisinfo->max()); @@ -1019,6 +1020,7 @@ GenericPlot::configureAxis(QString name, bool visible, int align, double min, do // min should be minimum value for all attached series foreach(QAbstractSeries *series, axis->series) { if (series->type() == QAbstractSeries::SeriesType::SeriesTypeScatter || + series->type() == QAbstractSeries::SeriesType::SeriesTypeBar || series->type() == QAbstractSeries::SeriesType::SeriesTypeLine) { foreach(QPointF point, static_cast(series)->pointsVector()) { if (usey) { @@ -1044,6 +1046,7 @@ GenericPlot::configureAxis(QString name, bool visible, int align, double min, do // min should be minimum value for all attached series foreach(QAbstractSeries *series, axis->series) { if (series->type() == QAbstractSeries::SeriesType::SeriesTypeScatter || + series->type() == QAbstractSeries::SeriesType::SeriesTypeBar || series->type() == QAbstractSeries::SeriesType::SeriesTypeLine) { foreach(QPointF point, static_cast(series)->pointsVector()) { if (usey) { diff --git a/src/Charts/UserChart.cpp b/src/Charts/UserChart.cpp index 3177c6f38..d18539692 100644 --- a/src/Charts/UserChart.cpp +++ b/src/Charts/UserChart.cpp @@ -163,7 +163,7 @@ UserChart::setRide(RideItem *item) series.yseries = ucd->y.asNumeric(); // pie charts need labels - if (chartinfo.type == GC_CHART_PIE || chartinfo.type == GC_CHART_BAR) { + if (chartinfo.type == GC_CHART_PIE) { series.labels.clear(); for(int i=0; ix.asString().count(); i++) series.labels << ucd->x.asString()[i]; @@ -202,6 +202,42 @@ UserChart::setRide(RideItem *item) // it works for now. if (axis.orientation == Qt::Horizontal) axis.labelcolor = axis.axiscolor = GColor(CPLOTMARKER); + // on a user chart the series sets the categories for a bar chart + // find the first series for this axis and set the categories + // to the x series values. + if (chartinfo.type == GC_CHART_BAR && axis.orientation == Qt::Horizontal) { + // find the first series for axis.name + foreach(GenericSeriesInfo s, seriesinfo) { + if (s.xname == axis.name && s.user1) { + axis.type = GenericAxisInfo::CATEGORY; + axis.categories.clear(); + UserChartData *ucd = static_cast(s.user1); + for(int i=0; ix.asString().count(); i++) axis.categories << ucd->x.asString()[i]; + break; + } + } + } + + // we need to set max and min based upon the barsets for bar charts since + // the generic plot only looks are series associated with an axis and we have 0 of those + if (min==-1 && max==-1 && chartinfo.type == GC_CHART_BAR && axis.orientation == Qt::Vertical) { + + // loop through all the series and look at max and min y values + bool first=true; + foreach(GenericSeriesInfo s, seriesinfo) { + if (s.yname == axis.name && s.user1) { + UserChartData *ucd = static_cast(s.user1); + for(int i=0; iy.asNumeric().count(); i++) { + double yy = ucd->y.asNumeric()[i]; + if (first || yy > max) max = yy; + if (first || yy < min) min = yy; + first = false; + } + break; + } + } + } + // we do NOT set align, this is managed in generic plot on our behalf // we also don't hide axes, so visible is always set to true chart->configureAxis(axis.name, true, -1, min, max, axis.type,