0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 16:44:39 +03:00

Fix default values in axis property editor

This commit is contained in:
Emil Sawicki 2022-03-13 07:26:25 +01:00
parent f684acd53b
commit 55c5e577fb
4 changed files with 22 additions and 6 deletions

View File

@ -71,8 +71,6 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
qreal hStep = (barsRect.width() / valuesCount()) / (barSeriesCount == 0 ? 1 : barSeriesCount); qreal hStep = (barsRect.width() / valuesCount()) / (barSeriesCount == 0 ? 1 : barSeriesCount);
qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top(); qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top();
qDebug() << "vStep" << vStep << "hStep" << hStep;
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){ if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){
int curSeries = 0; int curSeries = 0;
foreach (SeriesItem* series, m_chartItem->series()) { foreach (SeriesItem* series, m_chartItem->series()) {

View File

@ -3,6 +3,8 @@
#include "ui_lrchartaxiseditor.h" #include "ui_lrchartaxiseditor.h"
#include "lraxisdata.h" #include "lraxisdata.h"
#include "lrbasedesignintf.h"
ChartAxisEditor::ChartAxisEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, bool isXAxis, QSettings *settings, QWidget *parent): ChartAxisEditor::ChartAxisEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, bool isXAxis, QSettings *settings, QWidget *parent):
QWidget(parent), ui(new Ui::ChartAxisEditor), m_chartItem(item), m_page(page), QWidget(parent), ui(new Ui::ChartAxisEditor), m_chartItem(item), m_page(page),
m_settings(settings), m_isXAxis(isXAxis) m_settings(settings), m_isXAxis(isXAxis)
@ -59,9 +61,9 @@ void ChartAxisEditor::init()
LimeReport::AxisData *axisData = m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData(); LimeReport::AxisData *axisData = m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
ui->minimumSpinBox->setValue(axisData->rangeMin()); ui->minimumSpinBox->setValue(axisData->manualMinimum());
ui->maximumSpinBox->setValue(axisData->rangeMax()); ui->maximumSpinBox->setValue(axisData->manualMaximum());
ui->stepSpinBox->setValue(axisData->step()); ui->stepSpinBox->setValue(axisData->manualStep());
ui->minimumCheckBox->setChecked(axisData->isMinimumAutomatic()); ui->minimumCheckBox->setChecked(axisData->isMinimumAutomatic());
ui->maximumCheckBox->setChecked(axisData->isMaximumAutomatic()); ui->maximumCheckBox->setChecked(axisData->isMaximumAutomatic());
@ -108,7 +110,11 @@ void ChartAxisEditor::on_pushButtonOk_clicked()
axisData->setCalculateAxisScale(ui->enableScaleCalculation_checkbox->isChecked()); axisData->setCalculateAxisScale(ui->enableScaleCalculation_checkbox->isChecked());
axisData->update(); if (m_chartItem->itemMode() == LimeReport::DesignMode) {
axisData->updateForDesignMode();
} else {
axisData->update();
}
close(); close();
} }

View File

@ -50,6 +50,17 @@ void AxisData::update()
calculateSimpleAxisScale(); calculateSimpleAxisScale();
} }
m_delta = m_step * m_segmentCount; m_delta = m_step * m_segmentCount;
// Update manual values if they are automatic
if (m_isStepAutomatic) {
m_manualStep = m_step;
}
if (m_isMinimumAutomatic) {
m_manualMinimum = m_rangeMin;
}
if (m_isMaximumAutomatic) {
m_manualMaximum = m_rangeMax;
}
} }
void AxisData::update(qreal minValue, qreal maxValue) void AxisData::update(qreal minValue, qreal maxValue)

View File

@ -18,6 +18,7 @@ class AxisData : public QObject
public: public:
AxisData(QObject *parent = nullptr); AxisData(QObject *parent = nullptr);
QString toString() const;
void copy(AxisData *other); void copy(AxisData *other);
void update(); void update();
void update(qreal minValue, qreal maxValue); void update(qreal minValue, qreal maxValue);