mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2025-01-12 00:40:32 +08:00
NEW: added JKQTPGLabelCenteredOnData to JKQTPGraphLabelPosition, so JKQTPXYGraphLabels can draw directly centered over the datapoint
This commit is contained in:
parent
8e6847b593
commit
24526aa6a5
3
.gitignore
vendored
3
.gitignore
vendored
@ -178,3 +178,6 @@ Sicherungskopie_*
|
||||
/doc/images/JKQTPGLabelTowardsYAxis_small.png
|
||||
/doc/images/JKQTPGLSimpleBoxVertical_small.png
|
||||
/doc/images/JKQTPGLSimpleBox_small.png
|
||||
/doc/images/JKQTPGLabelCenteredOnDataVertical.png
|
||||
/doc/images/JKQTPGLabelCenteredOnDataVertical_small.png
|
||||
/doc/images/JKQTPGLabelCenteredOnData_small.png
|
||||
|
@ -273,7 +273,7 @@ if(JKQtPlotter_BUILD_EXAMPLES)
|
||||
symbols_and_errors/JKQTPXYLineErrorGraph_JKQTPErrorBars,JKQTPXYLineErrorGraph_JKQTPErrorLines,JKQTPXYLineErrorGraph_JKQTPErrorPolygons/--iteratefunctorsteps--iteratefunctorsteps_suppressinitial--smallscreenshotplot
|
||||
boxplot/JKQTPBoxplotVerticalGraph,JKQTPBoxplotHorizontalGraph/--iteratefunctorsteps--iteratefunctorsteps_suppressinitial--smallscreenshotplot
|
||||
second_axis/JKQTBasePlotter_addSecondaryYAxis,JKQTBasePlotter_addSecondaryXAxis
|
||||
graphlabels/JKQTPGLabelAwayFromXAxis,JKQTPGLabelAwayFromYAxis,JKQTPGLabelTowardsXAxis,JKQTPGLabelTowardsYAxis,JKQTPGLabelAboveData,JKQTPGLabelRightHandSide,JKQTPGLabelBelowData,JKQTPGLabelLeftHandSide,JKQTPGLSimpleBox,JKQTPGLSimpleBoxVertical,JKQTPGLSimpleBoxAndLine,JKQTPGLSimpleBoxAndLineVertical,JKQTPGLSimpleBoxAndLineONLYLABELS,JKQTPGLSimpleBoxAndLineONLYLABELSVertical/--iteratefunctorsteps--smallscreenshotplot
|
||||
graphlabels/JKQTPGLabelAwayFromXAxis,JKQTPGLabelAwayFromYAxis,JKQTPGLabelTowardsXAxis,JKQTPGLabelTowardsYAxis,JKQTPGLabelAboveData,JKQTPGLabelRightHandSide,JKQTPGLabelBelowData,JKQTPGLabelLeftHandSide,JKQTPGLabelCenteredOnData,JKQTPGLabelCenteredOnDataVertical,JKQTPGLSimpleBox,JKQTPGLSimpleBoxVertical,JKQTPGLSimpleBoxAndLine,JKQTPGLSimpleBoxAndLineVertical,JKQTPGLSimpleBoxAndLineONLYLABELS,JKQTPGLSimpleBoxAndLineONLYLABELSVertical/--iteratefunctorsteps--smallscreenshotplot
|
||||
vectorfield/JKQTPVectorFieldGraph,JKQTPVectorFieldGraphAnchorBottom,JKQTPVectorFieldGraphAnchorMid,JKQTPVectorFieldGraphAnchorTip,JKQTPVectorFieldGraphAutoscaleLength,JKQTPVectorFieldGraphLengthFromData,JKQTPVectorFieldGraphIgnoreLength,JKQTPVectorFieldGraphIgnoreLengthAutoscaleLineWidthFromLength,JKQTPVectorFieldGraphAutoscaleLengthAutoscaleLineWidthFromLength/--iteratefunctorsteps
|
||||
)
|
||||
|
||||
|
BIN
doc/images/JKQTPGLabelCenteredOnData.png
Normal file
BIN
doc/images/JKQTPGLabelCenteredOnData.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
@ -110,7 +110,19 @@ int main(int argc, char* argv[])
|
||||
plotV.redrawPlot();
|
||||
plotH.redrawPlot();
|
||||
});
|
||||
|
||||
app.addExportStepFunctor([&](){
|
||||
gV.second->setLabelPosition(JKQTPGLabelCenteredOnData);
|
||||
gH.second->setLabelPosition(JKQTPGLabelCenteredOnData);
|
||||
gV.first->setVisible(false);
|
||||
gH.first->setVisible(false);
|
||||
plotV.redrawPlot();
|
||||
plotH.redrawPlot();
|
||||
});
|
||||
|
||||
app.addExportStepFunctor([&](){
|
||||
gV.first->setVisible(true);
|
||||
gH.first->setVisible(true);
|
||||
gV.second->setLabelPosition(JKQTPGLabelAwayFromXAxis);
|
||||
gV.second->setLabelBoxType(JKQTPGLSimpleBox);
|
||||
gV.second->setDrawLabelBoxFrame(true);
|
||||
|
@ -35,6 +35,7 @@ QString JKQTPGraphLabelPosition2String(JKQTPGraphLabelPosition pos)
|
||||
case JKQTPGLabelAwayFromYAxis: return "label_away_from_yaxis";
|
||||
case JKQTPGLabelTowardsXAxis: return "label_towards_xaxis";
|
||||
case JKQTPGLabelTowardsYAxis: return "label_towards_xaxis";
|
||||
case JKQTPGLabelCenteredOnData: return "label_centered";
|
||||
}
|
||||
return "label_away_from_xaxis";
|
||||
}
|
||||
@ -50,6 +51,7 @@ JKQTPGraphLabelPosition String2JKQTPGraphLabelPosition(const QString &pos)
|
||||
if (m=="label_away_from_yaxis" || m=="away_from_yaxis") return JKQTPGLabelAwayFromYAxis;
|
||||
if (m=="label_towars_xaxis" || m=="towars_xaxis") return JKQTPGLabelTowardsXAxis;
|
||||
if (m=="label_towars_yaxis" || m=="towars_yaxis") return JKQTPGLabelTowardsYAxis;
|
||||
if (m=="label_centered" || m=="centered" || m=="label_centered_on_data" || m=="centered_on_data") return JKQTPGLabelCenteredOnData;
|
||||
return JKQTPGraphLabelDefault;
|
||||
}
|
||||
|
||||
@ -185,6 +187,7 @@ bool JKQTPGraphValueLabelStyleMixin::isLabelPositioningGrowingInX() const
|
||||
case JKQTPGLabelAwayFromXAxis:
|
||||
case JKQTPGLabelTowardsXAxis:
|
||||
case JKQTPGLabelTowardsYAxis:
|
||||
case JKQTPGLabelCenteredOnData:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@ -202,6 +205,7 @@ bool JKQTPGraphValueLabelStyleMixin::isLabelPositioningGrowingInY() const
|
||||
case JKQTPGLabelTowardsYAxis:
|
||||
case JKQTPGLabelLeftHandSide:
|
||||
case JKQTPGLabelRightHandSide:
|
||||
case JKQTPGLabelCenteredOnData:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@ -257,7 +261,8 @@ void JKQTPGraphValueLabelStyleMixin::drawLabel(JKQTPEnhancedPainter &painter, co
|
||||
case LabelGeometry::BoxBottom:
|
||||
painter.drawLine(xDataPixel, QPointF(xDataPixel.x(), qMin(g.boxRect.top(),g.boxRect.bottom())));
|
||||
break;
|
||||
|
||||
case LabelGeometry::BoxCentered:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,6 +301,9 @@ JKQTPGraphValueLabelStyleMixin::LabelGeometry JKQTPGraphValueLabelStyleMixin::ca
|
||||
// rhs
|
||||
res.textRect=QRectF(xDataPixel.x()+res.labelOffsetPx+res.padX+res.lw/2.0, xDataPixel.y()-res.textSize.overallHeight/2.0, res.textSize.width, res.textSize.overallHeight);
|
||||
res.boxpos=LabelGeometry::BoxRight;
|
||||
} else if (m_labelPosition==JKQTPGLabelCenteredOnData) {
|
||||
res.textRect=QRectF(xDataPixel.x()-res.textSize.width/2.0, xDataPixel.y()-res.textSize.overallHeight/2.0, res.textSize.width, res.textSize.overallHeight);
|
||||
res.boxpos=LabelGeometry::BoxCentered;
|
||||
}
|
||||
|
||||
res.boxRect=QRectF(res.textRect.x()-res.padX-res.lw/2.0, res.textRect.y()-res.padY-res.lw/2.0, res.textRect.width()+res.padX*2.0+res.lw, res.textRect.height()+res.padY*2.0+res.lw);
|
||||
|
@ -52,6 +52,8 @@ enum JKQTPGraphLabelPosition {
|
||||
JKQTPGLabelLeftHandSide, /*!< \brief all labels always on the left-hand side of the datapoint \image html JKQTPGLabelLeftHandSide.png */
|
||||
JKQTPGLabelTowardsYAxis, /*!< \brief all labels between the datapoint and the y-axis the datapoint \image html JKQTPGLabelTowardsYAxis.png */
|
||||
JKQTPGLabelAwayFromYAxis, /*!< \brief all labels pointing away from the y-axis \image html JKQTPGLabelAwayFromYAxis.png */
|
||||
JKQTPGLabelCenteredOnData, /*!< \brief graph label is drawn centered arond the data point \c (x,y) \image html JKQTPGLabelCenteredOnData.png */
|
||||
|
||||
|
||||
JKQTPGraphLabelDefault=JKQTPGLabelAwayFromXAxis,
|
||||
};
|
||||
@ -223,7 +225,8 @@ protected:
|
||||
BoxLeft,
|
||||
BoxRight,
|
||||
BoxTop,
|
||||
BoxBottom
|
||||
BoxBottom,
|
||||
BoxCentered
|
||||
};
|
||||
BoxPos boxpos;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user