diff --git a/src/axis/qchartaxis.cpp b/src/axis/qchartaxis.cpp index 6dbe119..0843ec2 100644 --- a/src/axis/qchartaxis.cpp +++ b/src/axis/qchartaxis.cpp @@ -362,6 +362,30 @@ void QChartAxis::setTicksCount(int count) } } +/*! + Sets axis, shades, labels and grid lines to be visible. + */ +void QChartAxis::show() +{ + m_axisVisible=true; + m_gridVisible=true; + m_labelsVisible=true; + m_shadesVisible=true; + emit updated(); +} + +/*! + Sets axis, shades, labels and grid lines to not be visible. + */ +void QChartAxis::hide() +{ + m_axisVisible=false; + m_gridVisible=false; + m_labelsVisible=false; + m_shadesVisible=false; + emit updated(); +} + #include "moc_qchartaxis.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/axis/qchartaxis.h b/src/axis/qchartaxis.h index 57e573f..0bb2a3f 100644 --- a/src/axis/qchartaxis.h +++ b/src/axis/qchartaxis.h @@ -62,6 +62,9 @@ public: QChartAxisCategories* categories() { return &m_category; } + void show(); + void hide(); + signals: void minChanged(qreal min); void maxChanged(qreal max); diff --git a/src/chartpresenter.cpp b/src/chartpresenter.cpp index 05f00b4..6d675a0 100644 --- a/src/chartpresenter.cpp +++ b/src/chartpresenter.cpp @@ -230,14 +230,8 @@ void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) // Hide all from background when there is only piechart // TODO: refactor this ugly code... should be one setting for this if (m_chartItems.count() == 0) { - m_chart->axisX()->setAxisVisible(false); - m_chart->axisY()->setAxisVisible(false); - m_chart->axisX()->setGridVisible(false); - m_chart->axisY()->setGridVisible(false); - m_chart->axisX()->setLabelsVisible(false); - m_chart->axisY()->setLabelsVisible(false); - m_chart->axisX()->setShadesVisible(false); - m_chart->axisY()->setShadesVisible(false); + m_chart->axisX()->hide(); + m_chart->axisY()->hide(); m_chart->setChartBackgroundBrush(Qt::transparent); } item=pie;