How to use the apexcharts.merge function in apexcharts

To help you get started, we’ve selected a few apexcharts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apexcharts / react-apexcharts / dist / react-apexcharts.js View on Github external
componentDidUpdate(prevProps) {
    const props = this.props;
    
    if (JSON.stringify(prevProps.options) !== JSON.stringify(props.options) || JSON.stringify(prevProps.series) !== JSON.stringify(this.props.series)) {
      const newOptions = {
        chart: {
          type: props.type ? props.type : 'line',
          width: props.width ? props.width : '100%',
          height: props.height ? props.height : 'auto'
        },
        series: props.series
      }
  
      const config = ApexCharts.merge(props.options, newOptions);
  
      // series is not changed,but options are changed
      if (JSON.stringify(props.series) === JSON.stringify(prevProps.series)) {
        this.state.chart.updateOptions(config)
      }
      // options are not changed, just the series is changed
      else if (JSON.stringify(props.options) === JSON.stringify(prevProps.options)) {
        this.state.chart.updateSeries(props.series)
  
      // both maybe changed
      } else {
        this.state.chart.updateOptions(config)
      }
    }
  }
github apexcharts / react-apexcharts / dist / react-apexcharts.js View on Github external
componentDidMount() {
    const newOptions = {
      chart: {
        type: this.props.type ? this.props.type : 'line',
        height: this.props.height ? this.props.height : 'auto',
        width: this.props.width ? this.props.width : '100%'
      },
      series: this.props.series
    }

    const config = ApexCharts.merge(this.props.options, newOptions);
    const chart = new ApexCharts(this.chartRef.current, config)
    chart.render().then(() => {
      this.setState({
        chart
      })
    })
  }

apexcharts

A JavaScript Chart Library

MIT
Latest version published 17 days ago

Package Health Score

98 / 100
Full package analysis