tree: 210e7944297da63e4215b209cc19f414937ea514 [path history] [tgz]
  1. dist/
  2. examples/
  3. screenshots/
  4. src/
  5. package-lock.json
  6. package.json
  7. README.md
custom-series/lineRange/README.md

@echarts-x/custom-line-range

lineRange is a custom series for Apache ECharts. It's typically used to show the range of data.

lineRange

Source Code

Usage

Browser Environment

For browser usage, use the auto-registration version that automatically installs the custom series when loaded:

<script src="./node_modules/echarts/dist/echarts.js"></script>
<script src="./node_modules/@echarts-x/custom-line-range/dist/index.auto.js"></script>
<script>
  // No need to call echarts.use(), automatically registered
  const chart = echarts.init(...);
  const option = {
    series: [{
      type: 'custom',
      renderItem: 'lineRange',
      // ...
    }]
  }
  chart.setOption(option);
</script>

See examples for more details.

UMD (Universal Module Definition)

For environments that need manual registration or when using AMD/CommonJS loaders:

// CommonJS
const echarts = require('echarts');
const lineRangeInstaller = require('@echarts-x/custom-line-range');
echarts.use(lineRangeInstaller);
const chart = echarts.init(...);

const option = {
  series: [{
    type: 'custom',
    renderItem: 'lineRange',
    // ...
  }]
}
chart.setOption(option);

See examples for more details.

ESM (ES Modules)

For modern module bundlers or native ES module environments:

npm install @echarts-x/custom-line-range
import * as echarts from 'echarts';
import lineRangeCustomSeriesInstaller from '@echarts-x/custom-line-range';

echarts.use(lineRangeCustomSeriesInstaller);
const chart = echarts.init(...);

const option = {
  series: [{
    type: 'custom',
    renderItem: 'lineRange',
    // ...
  }]
}
chart.setOption(option);

See examples for more details.

API

series.data

The data of the series is an array of arrays.

option = {
  xAxis: {
    data: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
    type: 'category'
  },
  yAxis: {
    type: 'value'
  },
  series: [{
    type: 'custom',
    renderItem: 'lineRange',
    data: [
      [0, 10, 20],
      [1, 20, 30],
      [2, 30, 40],
      [3, 40, 50],
      [4, 50, 60],
      [5, 60, 70],
      [6, 70, 80],
    ],
    encode: {
      x: [1, 2],
      y: 0,
      tooltip: [1, 2]
    }
  }]
};

The first element of the sub-array is the x value. The second element is the starting y value, and the third element is the ending y value. If you want to make a vertical lineRange chart, you can swap the x and y in the above example (including encode).

series.itemPayload

The itemPayload is an object that contains the following properties:

PropertyTypeDefaultDescription
lineStyleobject{}The style of the lines.
lineStyle.colorstringnullThe color of the lines. Default is the series color.
lineStyle.opacitynumber1The opacity of the lines.
lineStyle.widthnumber0The width of the lines.
lineStyle.typestring‘solid’The type of the lines.
lineStyle.dashOffsetnumber0The dashOffset of the lines.
lineStyle.cap'butt' | 'round' | 'square'‘butt’The cap of the lines.
lineStyle.join'bevel' | 'round' | 'miter'‘bevel’The join of the lines.
lineStyle.miterLimitnumber10The miterLimit of the lines.
lineStyle.shadowBlurnumber0The shadowBlur of the lines.
lineStyle.shadowColorstringnullThe shadowColor of the lines.
lineStyle.shadowOffsetXnumber0The shadowOffsetX of the lines.
lineStyle.shadowOffsetYnumber0The shadowOffsetY of the lines.
areaStyleobject{}The style of the area.
areaStyle.colorstringnullThe color of the area. Default is the series color.
areaStyle.opacitynumber0.2The opacity of the area.
areaStyle.shadowBlurnumber0The shadowBlur of the area.
areaStyle.shadowColorstringnullThe shadowColor of the area.
areaStyle.shadowOffsetXnumber0The shadowOffsetX of the area.
areaStyle.shadowOffsetYnumber0The shadowOffsetY of the area.