Highcharts With React

Sub-skill of highcharts: With React (+1).

vamseeachanta be53202 971 B Updated

File contents

With React (+1)

With React

import { useEffect, useRef } from 'react';
import Highcharts from 'highcharts';

function HighchartsComponent({ options }) {
  const chartRef = useRef(null);

  useEffect(() => {
    const chart = Highcharts.chart(chartRef.current, options);

    return () => {
      chart.destroy();
    };
  }, [options]);

  return <div ref={chartRef} />;
}

With Vue

<template>
  <div ref="chartContainer"></div>
</template>

<script>
import Highcharts from 'highcharts';

export default {
  props: ['options'],
  mounted() {
    this.chart = Highcharts.chart(this.$refs.chartContainer, this.options);
  },
  beforeUnmount() {
    if (this.chart) {
      this.chart.destroy();
    }
  },
  watch: {
    options: {
      deep: true,
      handler(newOptions) {
        this.chart.update(newOptions);
      }
    }
  }
};
</script>

vamseeachanta/workspace-hub/tree/main/.agents/skills/_archive/data/visualization/highcharts/with-react commit be53202454

Frequently asked questions

npx skillmds@latest add vamseeachanta/highcharts-with-react