I would like to replace the degrees of an angular axis in a QPolarChart with some text like shown in the attached figure (e.g instead of 90.0 -> "Cat 1"). I tried QCategoryAxis but in this case the categories appeared between the axis (e.g between 90 and 180 degree).
Now I am using the following code in order to create the polar chart:
QPolarChart *chart = new QPolarChart();
QValueAxis *angularAxis = new QValueAxis();
angularAxis->setRange(0, 360);
QLineSeries *series1 = new QLineSeries();
series1->append(0, 60);
series1->append(90, -60);
series1->append(180, 50);
series1->append(270, 62);
series1->append(360, 60);
QLineSeries *series2 = new QLineSeries();
series2->append(0, 0);
series2->append(90, 0);
series2->append(180, 0);
series2->append(270, 0);
series2->append(360, 0);
chart->addSeries(series1);
chart->addSeries(series2);
chart->addAxis(angularAxis, QPolarChart::PolarOrientationAngular);
ValueAxis *radialAxis = new QValueAxis();
radialAxis->setTickCount(9);
radialAxis->setLabelFormat("%d");
chart->addAxis(radialAxis, QPolarChart::PolarOrientationRadial);
series1->attachAxis(radialAxis);
series1->attachAxis(angularAxis);
series2->attachAxis(radialAxis);
series2->attachAxis(angularAxis);
radialAxis->setRange(-100, 100);
QChartView *chartView = new QChartView();
chartView->setChart(chart);
chartView->setRenderHint(QPainter::Antialiasing);
ui->mainPlot->addWidget(chartView);
The solution is to use
QCategoryAxis
but with thelabelsPosition
inQCategoryAxis::AxisLabelsPositionOnValue
.