Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Decimals in labels on an axis of a QChart[View]
ibkv last edited by ibkv
I have a QLineSeries/QChart displayed in a QChartView. Even though the points I've added are whole numbers, the display graph shows decimals point along the X/Y axes. How do I turn off the decimals points, i.e., specify 0 decimals?
Yashpal last edited by
You can use format specifiers, have a look at the following example from Qt documentation.
QChartView *chartView = new QChartView; QLineSeries *series = new QLineSeries; // ... chartView->chart()->addSeries(series); QValueAxis *axisX = new QValueAxis; axisX->setRange(10, 20.5); axisX->setTickCount(10); axisX->setLabelFormat("%.2f"); chartView->chart()->setAxisX(axisX, series);