Skip to content

Axis

Axis options allow a more detailed configuration over the visualization axis. They can be defined as shown below:

1
2
3
4
5
6
var axis = { yAxis: {...}, xAxis: {...} }
myChart.set(axis)

//or

myChart.set('yAxis', {...})

Options

The supported options are the following:

label

Sets a custom label for the specified axis

1
myChart.set('xAxis', { label: 'My Custom Label' })
custom-label

labelGap

Sets the distance between axis name and axis line

1
2
myChart.set('xAxis', { label: 'My Custom Label' , labelGap: 10 })
myChart.set('yAxis', { labelGap: 70 })
custom-label

type

Sets what type of values are going to be used. Accepts 'log' or 'values' which is the default.

1
myChart.set('yAxis', { type: 'log'}) 
log

show

Hides or show the specified axis

1
myChart.set('xAxis', { show: false }) 
show

min / max

Sets min and/or max values for the specified axis

1
myChart.set('yAxis', { max: 100000, min: 20000 })
min-max

lines

Hides or displays the grid lines for the specified axis

1
2
myChart.set('yAxis', { lines: false })
myChart.set('xAxis', { lines: false })
axis-lines

position

Allows to change the axis position. Available values for x-axis are top and bottom, the default value is bottom. Available values for y-axis are left and right, the default value is left.

1
2
myChart.set('xAxis', { position: "top" })
myChart.set('yAxis', { position: "right" })
axis-position

rotate

Allows changing the axis tick label rotation degree, which is especially useful when there is no enough space for the category axis. The supported values are -90 to 90.

1
2
myChart.set('xAxis', { rotate: -90 })
myChart.set('yAxis', { rotate: 45 })
axis-position

center

Allows to center the bars when we have negative values in the axis. By default the axis is not centered.

1
myChart.set('xAxis', { center: true })

Note

This property is only supported for the Bar chart. To center the axis on other charts (e.g. Trend), set the min/max to the same negative and positive values respectively. Example: .set("yAxis", {min: -50000, max: 50000})

Echarts custom options

For more flexibility, axis options support Echart xAxis and yAxis custom properties to be passed directly.

The following is an example of how to configure an axis with some of those properties:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
.set("xAxis", {
    show: true,
    lines: {
      lineStyle: {
        color: "rgba(228, 23, 23, 1)",
      },
      show: true,
    },
    axisLine: {
      lineStyle: {
        color: "green",
      },
    },
    axisTick: {
      lineStyle: {
        color: "red",
      },
    },
    axisLabel: {
      fontSize: 12,
      color: "red",
    },
  })
  .set("yAxis", {
    show: true,
    splitLine: true,
    axisLine: {
      lineStyle: {
        color: "red",
      },
    },
    axisTick: {
      lineStyle: {
        color: "red",
      },
    },
    axisLabel: {
      fontSize: 12,
      margin: 11,
    },
  });

The previous configuration used in a Bar chart, will be rendered like this:

advanced-axis-options

Chart support

Chart label log type show min / max lines position rotate center
Area Line Yes Yes Yes Yes Yes Yes Yes No
Bars Yes Yes Yes Yes Yes Yes Yes Yes
Bars and Line Yes No Yes Yes Yes Yes Yes No
Box Plot Yes Yes Yes No Yes Yes Yes No
Floating Bubbles Yes Yes Yes Yes Yes Yes Yes No
Histogram Yes Yes Yes Yes Yes Yes Yes No
Multigroup Trend Yes No Yes Yes Yes Yes Yes No
Multimetric Area Line Yes No Yes Yes Yes Yes Yes No
Multimetric Bars Yes No Yes Yes Yes Yes Yes No
Multimetric Trend Yes No Yes Yes Yes Yes Yes No
Scatter Plot Yes Yes Yes Yes Yes Yes Yes No
Trend Yes No Yes Yes Yes Yes Yes No