美图齐众专注资阳网站设计 资阳网站制作 资阳网站建设
资阳网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

创新互联ECharts教程:xAxis坐标轴指示器的文本标签设置

xAxis.axisPointer.label   |   Object

用来控制坐标轴指示器的文本标签。

xAxis.axisPointer.label.show   |   boolean

[ default: false ]

表示是否显示文本标签。如果 tooltip.axisPointer.type 设置为 'cross' 则默认显示标签,否则默认不显示。

xAxis.axisPointer.label.precision   |   number, string

[ default: 'auto' ]

表示文本标签中数值的小数点精度。默认根据当前轴的值自动判断。也可以指定如 2 表示保留两位小数。

xAxis.axisPointer.label.formatter   |   string, Function

[ default: null ]

作为文本标签文字的格式化器。

  • 如果为 function,可以是例如:

    参数:

    {Object} params: 含有:

    • {Object} params.value: 轴当前值,如果 axis.type 为 'category' 时,其值为 axis.data 里的数值;如果 axis.type 为 'time',其值为时间戳。
    • {Array.} params.seriesData: 一个数组,是当前 axisPointer 最近的点的信息,每项内容如下:
      {
      componentType: 'series',
      // 系列类型
      seriesType: string,
      // 系列在传入的 option.series 中的 index
      seriesIndex: number,
      // 系列名称
      seriesName: string,
      // 数据名,类目名
      name: string,
      // 数据在传入的 data 数组中的 index
      dataIndex: number,
      // 传入的原始数据项
      data: Object,
      // 传入的数据值
      value: number|Array,
      // 数据图形的颜色
      color: string,
      }

      每项内容还包括轴的信息:

      {
      axisDim: 'x', // 'x', 'y', 'angle', 'radius', 'single'
      axisId: 'xxx',
      axisName: 'xxx',
      axisIndex: 3,
      axisValue: 121, // 当前 axisPointer 对应的 value。
      axisValueLabel: '文本'
      }

      返回值:

      显示的 string。

      例如:

      formatter: function (params) {
      // 假设此轴的 type 为 'time'。
      return 'some text' + echarts.format.formatTime(params.value);
      }

      xAxis.axisPointer.label.margin   |   boolean

      [ default: 3 ]

      表示 label 距离轴的距离。


      本文名称:创新互联ECharts教程:xAxis坐标轴指示器的文本标签设置
      本文网址:http://www.zsjierui.cn/article/dpphpgo.html