0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

Get axis label using method

This commit is contained in:
Emil Sawicki 2022-01-25 20:05:18 +01:00
parent fdee26a2b8
commit 5dac77083f
3 changed files with 8 additions and 3 deletions

View File

@ -752,7 +752,6 @@ void AbstractSeriesChart::paintHorizontalGrid(QPainter *painter, QRectF gridRect
painter->save();
const AxisData &yAxisData = this->yAxisData();
const qreal delta = yAxisData.delta();
const int segmentCount = yAxisData.segmentCount();
const int lineCount = segmentCount + 1;
@ -765,7 +764,7 @@ void AbstractSeriesChart::paintHorizontalGrid(QPainter *painter, QRectF gridRect
for (int i = 0 ; i < lineCount ; i++ ) {
painter->drawText(QRectF(gridRect.left() + 4 + hStep * i, gridRect.bottom() - painter->fontMetrics().height(),
hStep, painter->fontMetrics().height()),
QString::number(minValue() + i * delta / segmentCount));
axisLabel(i, yAxisData));
painter->drawLine( gridRect.left()+hStep*i, gridRect.bottom(),
gridRect.left()+hStep*i, gridRect.top());
@ -791,6 +790,7 @@ void AbstractSeriesChart::paintVerticalGrid(QPainter *painter, QRectF gridRect)
const QTextOption verticalTextOption(Qt::AlignRight);
for (int i = 0 ; i < lineCount ; i++ ) {
const qreal y = vStep * i;
// TODO_ES handle horizontalAxisOnTop
painter->drawText(QRectF(gridRect.bottomLeft()-QPointF(textPositionOffset,y+halfFontHeight),
QSizeF(valuesHMargin,fontHeight)),
axisLabel(i, yAxisData),
@ -839,7 +839,7 @@ void AbstractSeriesChart::paintGrid(QPainter *painter, QRectF gridRect)
for (int i = 0 ; i < xAxisLineCount ; i++) {
const qreal x = gridRect.left() + hStep * i + valuesHMargin + gridOffset;
const bool drawFullLine = i == 0 || i == xAxisSegmentCount;
const QString text = QString::number(xAxisData.rangeMin() + i * xAxisData.step());
const QString text = axisLabel(i, xAxisData);
if (m_chartItem->horizontalAxisOnTop()) {
painter->drawLine(x, gridRect.top() - gridOffset,

View File

@ -145,6 +145,9 @@ class ChartItem : public LimeReport::ItemDesignIntf
Q_PROPERTY(int seriesLineWidth READ seriesLineWidth WRITE setSeriesLineWidth)
Q_PROPERTY(bool horizontalAxisOnTop READ horizontalAxisOnTop WRITE setHorizontalAxisOnTop)
Q_PROPERTY(QString xAxisField READ xAxisField WRITE setXAxisField)
//girdChart
// TODO_ES add grid property for showing lines inside
friend class AbstractChart;
public:

View File

@ -23,6 +23,8 @@ ChartItemEditor::ChartItemEditor(LimeReport::ChartItem *item, LimeReport::PageDe
readSetting();
init();
connect(m_colorButton, SIGNAL(clicked(bool)), this, SLOT(slotChangeSeriesColor()));
// TODO_ES add field in editor for x axis field, like for labels
}
ChartItemEditor::~ChartItemEditor()