Skip to content

Commit

Permalink
Generic Plot log axes
Browse files Browse the repository at this point in the history
.. add log axes support.
  • Loading branch information
liversedge committed Mar 9, 2020
1 parent b17c337 commit 9e7f843
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
9 changes: 6 additions & 3 deletions src/Charts/GenericPlot.cpp
Expand Up @@ -654,7 +654,9 @@ GenericPlot::finaliseChart()
case GenericAxisInfo::TIME: // TODO
case GenericAxisInfo::CONTINUOUS:
{
QValueAxis *vaxis= new QValueAxis(qchart);
QAbstractAxis *vaxis=NULL;
if (axisinfo->log) vaxis= new QLogValueAxis(qchart);
else vaxis= new QValueAxis(qchart);
add=vaxis; // gets added later

vaxis->setMin(axisinfo->min());
Expand Down Expand Up @@ -745,8 +747,9 @@ GenericPlot::finaliseChart()

// look for first series with a horizontal axis (we will use this later)
foreach(QAbstractAxis *axis, series->attachedAxes()) {
if (axis->orientation() == Qt::Horizontal && axis->type()==QAbstractAxis::AxisTypeValue) {
legend->addX(static_cast<QValueAxis*>(axis)->titleText());
if (axis->orientation() == Qt::Horizontal) {
if (axis->type()==QAbstractAxis::AxisTypeValue) legend->addX(static_cast<QValueAxis*>(axis)->titleText());
else if (axis->type()==QAbstractAxis::AxisTypeLogValue) legend->addX(static_cast<QLogValueAxis*>(axis)->titleText());
havexaxis=true;
break;
}
Expand Down
21 changes: 10 additions & 11 deletions src/Charts/GenericSelectTool.cpp
Expand Up @@ -213,19 +213,18 @@ void GenericSelectTool::paint(QPainter*painter, const QStyleOptionGraphicsItem *

if (calc.series->isVisible() == false) continue;

// slope calcs way over the top for a line chart
// where there are multiple series being plotted
if (host->charttype == GC_CHART_SCATTER) {
QString lr=QString("y = %1 x + %2").arg(calc.m).arg(calc.b);
QPen line(calc.color);
painter->setPen(line);
painter->drawText(QPointF(0,0), lr);
}

// slope
if (calc.xaxis != NULL) {

if (calc.xaxis->type() == QAbstractAxis::AxisTypeValue) { //XXX todo for log date etc?
if (calc.xaxis->type() == QAbstractAxis::AxisTypeValue) {

// slope calcs way over the top for a line chart
// where there are multiple series being plotted
if (host->charttype == GC_CHART_SCATTER) {
QString lr=QString("y = %1 x + %2").arg(calc.m).arg(calc.b);
QPen line(calc.color);
painter->setPen(line);
painter->drawText(QPointF(0,0), lr);
}

double startx = static_cast<QValueAxis*>(calc.xaxis)->min();
double stopx = static_cast<QValueAxis*>(calc.xaxis)->max();
Expand Down

0 comments on commit 9e7f843

Please sign in to comment.