RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
创新互联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://jxjierui.cn/article/dpphpgo.html
      0.0628s