diff --git a/src/areachart/qareaseries.cpp b/src/areachart/qareaseries.cpp index 3870893..e0be044 100644 --- a/src/areachart/qareaseries.cpp +++ b/src/areachart/qareaseries.cpp @@ -438,7 +438,7 @@ QAbstractAxis::AxisType QAreaSeriesPrivate::defaultAxisType(Qt::Orientation orie QAbstractAxis* QAreaSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const { Q_UNUSED(orientation); - return 0; + return new QValueAxis; } void QAreaSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) diff --git a/src/barchart/qabstractbarseries.cpp b/src/barchart/qabstractbarseries.cpp index c9723ad..1e7a8a5 100644 --- a/src/barchart/qabstractbarseries.cpp +++ b/src/barchart/qabstractbarseries.cpp @@ -852,8 +852,10 @@ void QAbstractBarSeriesPrivate::populateCategories(QBarCategoryAxis *axis) QAbstractAxis* QAbstractBarSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const { - Q_UNUSED(orientation); - return 0; + if (defaultAxisType(orientation) == QAbstractAxis::AxisTypeBarCategory) + return new QBarCategoryAxis; + else + return new QValueAxis; } void QAbstractBarSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) diff --git a/src/boxplotchart/qboxplotseries.cpp b/src/boxplotchart/qboxplotseries.cpp index 2d05f98..22a3eb7 100644 --- a/src/boxplotchart/qboxplotseries.cpp +++ b/src/boxplotchart/qboxplotseries.cpp @@ -394,9 +394,10 @@ QAbstractAxis::AxisType QBoxPlotSeriesPrivate::defaultAxisType(Qt::Orientation o QAbstractAxis* QBoxPlotSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const { - Q_UNUSED(orientation); - - return 0; + if (defaultAxisType(orientation) == QAbstractAxis::AxisTypeBarCategory) + return new QBarCategoryAxis; + else + return new QValueAxis; } void QBoxPlotSeriesPrivate::populateCategories(QBarCategoryAxis *axis) diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index f18012a..fe0778e 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -315,8 +315,20 @@ void ChartDataSet::createDefaultAxes() } // Create the axes of the types selected - createAxes(typeX, Qt::Horizontal); - createAxes(typeY, Qt::Vertical); + // As long as AxisType enum balues are sequential a check to see if there are series of + // different types is needed. In such cases AxisTypeNoAxis is used to create separate axes + // for the types. + if (typeX != QAbstractAxis::AxisTypeNoAxis) { + if (typeX != m_seriesList.first()->d_ptr->defaultAxisType(Qt::Horizontal)) + typeX = QAbstractAxis::AxisTypeNoAxis; + createAxes(typeX, Qt::Horizontal); + } + + if (typeY != QAbstractAxis::AxisTypeNoAxis) { + if (typeY != m_seriesList.first()->d_ptr->defaultAxisType(Qt::Vertical)) + typeY = QAbstractAxis::AxisTypeNoAxis; + createAxes(typeY, Qt::Vertical); + } } @@ -357,7 +369,7 @@ void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation ori } axis->setRange(min,max); } - else if (!type.testFlag(QAbstractAxis::AxisTypeNoAxis)) { + else if (type.testFlag(QAbstractAxis::AxisTypeNoAxis)) { //create separate axis foreach(QAbstractSeries *s, m_seriesList) { QAbstractAxis *axis = s->d_ptr->createDefaultAxis(orientation); diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp index 5c2d89f..88d1856 100644 --- a/src/xychart/qxyseries.cpp +++ b/src/xychart/qxyseries.cpp @@ -575,7 +575,7 @@ QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orient QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const { Q_UNUSED(orientation); - return 0; + return new QValueAxis; } void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options)