Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to set a series of strings as x-axis in QChart?



  • I have a series of strings in the x column, and corresponding values in the y column. I want to plot y versus x in a line chart, and I want each neighboring x labels has the same interval. How can I achieve this? Thank you.



  • @Richard-Lee
    maybe this example meets your need.



  • Thank you very much. I have solved my problem after read through the example.

    Actually, I should have three columns. the first column is just a series of sequential integer numbers, the second column stores the cateogories, which will be appeared as the x axis labels, and the third column stores y-axis values. Then I create a QBarCategoryAxis, e.g. xAxis, then I append the xAxis with the categories column, and link the xAxis with my line series (i.e. setAxisX(xAxis, series).


Log in to reply