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

@echarts-x/custom-stage

stage is a custom series for Apache ECharts. It's typically used to display the data with various stages, like sleeping stages.

stage

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-stage/dist/index.auto.js"></script>
<script>
  // No need to call echarts.use(), automatically registered
  const chart = echarts.init(...);
  const option = {
    series: [{
      type: 'custom',
      renderItem: 'stage',
      // ...
    }]
  }
  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 stageInstaller = require('@echarts-x/custom-stage');
echarts.use(stageInstaller);
const chart = echarts.init(...);

const option = {
  series: [{
    type: 'custom',
    renderItem: 'stage',
    // ...
  }]
}
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-stage
import * as echarts from 'echarts';
import stageCustomSeriesInstaller from '@echarts-x/custom-stage';

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

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

See examples for more details.

API

series.data

The data of the series is an array of arrays. Each sub-array represents a scatter point.

const data = [
  [new Date('2024-09-07 06:12'), new Date('2024-09-07 06:12'), 'Awake']
];

The first element of the sub-array is the starting value, and the second is ending value. The third element is the stage name. The data with the same x value will be grouped into a stage.

series.itemPayload

The itemPayload is an object that contains the following properties:

PropertyTypeDefaultDescription
itemStyleobject{}The style of the stage.
itemStyle.borderRadiusnumber8The border radius of the stage.
itemStyle.verticalMarginnumber10The vertical margin of the bars.
itemStyle.minHorizontalSizenumber3The minimum width of the bars.
itemStyle.envelopeobject{}The envelope of the stage.
itemStyle.envelope.showbooleantrueWhether to show the envelope.
itemStyle.envelope.colorstring#888The fill color of the envelope.
itemStyle.envelope.opacitynumber0.25The opacity of the envelope.
itemStyle.envelope.externalRadiusnumber8The border radius of the envelope outside.
itemStyle.axisLabelobject{}The style of the axis label.
itemStyle.axisLabel.formatterFunctionnullThe formatter of the axis label. Parameters are (stageName: string, stageIndex: number).
itemStyle.axisLabel.colorstring#8A8A8AThe color of the axis label.