查看完整版本: [-- qml下修改LineSeries坐标轴标签的办法 --]

QTCN开发网 -> Qt QML开发 -> qml下修改LineSeries坐标轴标签的办法 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

solo_wang 2019-04-30 11:00

qml下修改LineSeries坐标轴标签的办法


  1. ChartView {
          title: "Line"
          anchors.fill: parent
          antialiasing: true

          LineSeries {
              name: "LineSeries"
              XYPoint { x: 0; y: 0 }
              XYPoint { x: 1.1; y: 2.1 }
              XYPoint { x: 1.9; y: 3.3 }
              XYPoint { x: 2.1; y: 2.1 }
              XYPoint { x: 2.9; y: 4.9 }
              XYPoint { x: 3.4; y: 3.0 }
              XYPoint { x: 4.1; y: 3.3 }
          }
      }
这是官方给的一段demo,我想问下,有没有什么办法可以修改横轴和纵轴的标签?
比如y轴显示的是"first","second","third"这样的?


ch781609892 2019-05-12 13:54
axisY:BarCategoryAxis {
          id: categoryAxis
          categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ]
      }
或者用CategoryAxis也行

chentao1990 2020-01-21 09:18
你可以使用ValueAxis自己定义X轴Y轴: ValueAxis{
        id:                 axisX
        min:                10
        max:                100
        tickCount:          2
        minorTickCount:     14
        color:              “red"      //颜色
        labelsColor:        “red"  //标题颜色
        labelsVisible:      false  //是否显示标题,也就是你说的标签
        titleText:          qsTr("text")    //标签
        titleVisible:       true
        titleBrush:         "red”
    }
LineSeries {
        id: lineSeries1
        axisX: axisX
        axisY: axisY_L   //这个是Y轴标签,你可以参照上面的X轴自己写一个
    }


查看完整版本: [-- qml下修改LineSeries坐标轴标签的办法 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled