Qt QChart 中 QValueAxis 和 QCategoryAxis 区别

QValueAxis

Detailed Description

The QValueAxis class is used for manipulating chart’s axis.
ValueAxis can be setup to show axis line with tick marks, grid lines and shades. Values of axis are drawn to position of ticks.

详细说明
这个QValueAxis类,用于操纵chart的图轴。
ValueAxis可以设置显示刻度轴线、网格线和阴影。以及轴的值被绘制到轴上面的位置。


QCategoryAxis

Detailed Description
The QCategoryAxis class allows putting a named ranges on the axis.
This class can be used when the underlying data needs to be given extra meaning. Unlike with the QBarCategoryAxis the QCategoryAxis allows the categories ranges widths to be specified freely.
Example code on how to use QCategoryAxis:

详细说明
这个QCategoryAxis类允许自定义,所指定的轴范围。
这个类可以使用时,底层的数据需要给予额外的意义。与QBarCategoryAxis类的QCategoryAxis允许类范围可任意指定宽度。
这与QBarCategoryAxis的QCategoryAxis允许类范围可任意指定宽度不同。

  QChartView *chartView = new QChartView;
  QLineSeries *series = new QLineSeries;
  // ...
  chartView->chart()->addSeries(series);

  QCategoryAxis *axisY = new QCategoryAxis;
  axisY->setMin(0);
  axisY->setMax(52);
  axisY->setStartValue(15);
  axisY->append("First", 20);
  axisY->append("Second", 37);
  axisY->append("Third", 52);
  chartView->chart()->setAxisY(axisY, series);

这里写图片描述


个人理解:
简单的说QValueAxis是一个懒人版,轴的范围什么的不需要自己指定,轴上显示的label(也就是0,1,2,3这些内容)是默认的。qt会根据你轴上的点自动设置。
若你需要自定义一些内容,QCategoryAxis是比较好的,但是需要自己自定义好才可以调用。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值