mirror of
				https://github.com/fralx/LimeReport.git
				synced 2025-10-31 05:11:56 +03:00 
			
		
		
		
	Add x axis field combobox to chart editor
This commit is contained in:
		| @@ -971,13 +971,7 @@ QString AbstractSeriesChart::axisLabel(int i, const AxisData &axisData) | |||||||
| { | { | ||||||
|     const qreal min = axisData.rangeMin(); |     const qreal min = axisData.rangeMin(); | ||||||
|     const qreal step = axisData.step(); |     const qreal step = axisData.step(); | ||||||
|     qreal value = 0; |     qreal value = min + i * step; | ||||||
|     // For values below 0, axis is already reversed (value closer to 0 is higher) |  | ||||||
|     if (axisData.reverseDirection() && min >= 0) { |  | ||||||
|         value = min + (axisData.segmentCount() - i) * step; |  | ||||||
|     } else { |  | ||||||
|         value = min + i * step; |  | ||||||
|     } |  | ||||||
|     if (std::floor(step) == step) { |     if (std::floor(step) == step) { | ||||||
|         return QString::number(value); |         return QString::number(value); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -23,8 +23,6 @@ ChartItemEditor::ChartItemEditor(LimeReport::ChartItem *item, LimeReport::PageDe | |||||||
|     readSetting(); |     readSetting(); | ||||||
|     init(); |     init(); | ||||||
|     connect(m_colorButton, SIGNAL(clicked(bool)), this, SLOT(slotChangeSeriesColor())); |     connect(m_colorButton, SIGNAL(clicked(bool)), this, SLOT(slotChangeSeriesColor())); | ||||||
|  |  | ||||||
|     // TODO_ES add field in editor for x axis field, like for labels |  | ||||||
| } | } | ||||||
|  |  | ||||||
| ChartItemEditor::~ChartItemEditor() | ChartItemEditor::~ChartItemEditor() | ||||||
| @@ -108,6 +106,7 @@ void ChartItemEditor::init() | |||||||
|                 for (int i=0;i<ds->columnCount();++i){ |                 for (int i=0;i<ds->columnCount();++i){ | ||||||
|                    ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i)); |                    ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i)); | ||||||
|                    ui->labelsFieldComboBox->addItem(ds->columnNameByIndex(i)); |                    ui->labelsFieldComboBox->addItem(ds->columnNameByIndex(i)); | ||||||
|  |                    ui->xAxisFieldComboBox->addItem(ds->columnNameByIndex(i)); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -122,8 +121,10 @@ void ChartItemEditor::init() | |||||||
|  |  | ||||||
| #if QT_VERSION < 0x050000 | #if QT_VERSION < 0x050000 | ||||||
|     ui->labelsFieldComboBox->setCurrentIndex(ui->labelsFieldComboBox->findText( m_charItem->labelsField())); |     ui->labelsFieldComboBox->setCurrentIndex(ui->labelsFieldComboBox->findText( m_charItem->labelsField())); | ||||||
|  |     ui->xAxisFieldComboBox->setCurrentIndex(ui->xAxisFieldComboBox->findText( m_charItem->xAxisField())); | ||||||
| #else | #else | ||||||
|     ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField()); |     ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField()); | ||||||
|  |     ui->xAxisFieldComboBox->setCurrentText(m_charItem->xAxisField()); | ||||||
| #endif | #endif | ||||||
|     if (!m_charItem->series().isEmpty()){ |     if (!m_charItem->series().isEmpty()){ | ||||||
|         enableSeriesEditor(); |         enableSeriesEditor(); | ||||||
| @@ -289,3 +290,9 @@ void ChartItemEditor::on_seriesTypeComboBox_currentIndexChanged(const QString &a | |||||||
|         currentSeries()->setPreferredType(static_cast<LimeReport::SeriesItem::SeriesItemPreferredType>(enumerator.keysToValue(arg1.toLatin1()))); |         currentSeries()->setPreferredType(static_cast<LimeReport::SeriesItem::SeriesItemPreferredType>(enumerator.keysToValue(arg1.toLatin1()))); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void ChartItemEditor::on_xAxisFieldComboBox_currentTextChanged(const QString &arg1) | ||||||
|  | { | ||||||
|  |     if (!m_initing) | ||||||
|  |         m_charItem->setXAxisField(arg1); | ||||||
|  | } | ||||||
| @@ -41,6 +41,8 @@ private slots: | |||||||
|     void slotChangeSeriesColor(); |     void slotChangeSeriesColor(); | ||||||
|     void on_seriesTypeComboBox_currentIndexChanged(const QString &arg1); |     void on_seriesTypeComboBox_currentIndexChanged(const QString &arg1); | ||||||
|  |  | ||||||
|  |     void on_xAxisFieldComboBox_currentTextChanged(const QString &arg1); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     void readSetting(); |     void readSetting(); | ||||||
|     void writeSetting(); |     void writeSetting(); | ||||||
|   | |||||||
| @@ -144,16 +144,30 @@ | |||||||
|     </widget> |     </widget> | ||||||
|    </item> |    </item> | ||||||
|    <item> |    <item> | ||||||
|     <layout class="QHBoxLayout" name="horizontalLayout_2"> |     <layout class="QGridLayout" name="gridLayout"> | ||||||
|      <item> |      <item row="0" column="1"> | ||||||
|  |       <widget class="QComboBox" name="labelsFieldComboBox"> | ||||||
|  |        <property name="editable"> | ||||||
|  |         <bool>true</bool> | ||||||
|  |        </property> | ||||||
|  |       </widget> | ||||||
|  |      </item> | ||||||
|  |      <item row="0" column="0"> | ||||||
|       <widget class="QLabel" name="labelsFieldLabel"> |       <widget class="QLabel" name="labelsFieldLabel"> | ||||||
|        <property name="text"> |        <property name="text"> | ||||||
|         <string>Labels field</string> |         <string>Labels field</string> | ||||||
|        </property> |        </property> | ||||||
|       </widget> |       </widget> | ||||||
|      </item> |      </item> | ||||||
|      <item> |      <item row="1" column="0"> | ||||||
|       <widget class="QComboBox" name="labelsFieldComboBox"> |       <widget class="QLabel" name="xAxisFieldLabel"> | ||||||
|  |        <property name="text"> | ||||||
|  |         <string>X data field</string> | ||||||
|  |        </property> | ||||||
|  |       </widget> | ||||||
|  |      </item> | ||||||
|  |      <item row="1" column="1"> | ||||||
|  |       <widget class="QComboBox" name="xAxisFieldComboBox"> | ||||||
|        <property name="editable"> |        <property name="editable"> | ||||||
|         <bool>true</bool> |         <bool>true</bool> | ||||||
|        </property> |        </property> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user