highcharts-vue icon indicating copy to clipboard operation
highcharts-vue copied to clipboard

'Moving window' when data is added dynamically - how to adjust?

Open chapkovski opened this issue 4 years ago • 1 comments

So when the data is added every second Highstocks start having a 'moving window'.

But can we set this moving window to something different than 5 seconds?

Here is the demo: https://codesandbox.io/s/highcharts-vue-demo-forked-kk8s0?file=/src/components/Chart.vue:0-852

Here is an example of the code

<template>
  <div>
    <highcharts
      :constructorType="'stockChart'"
      class="hc"
      :options="chartOptions"
      ref="chart"
    ></highcharts>
    
  </div>
</template>

<script>
export default {
  data() {
    return {
      chartOptions: {
        rangeSelector: {
          selected: 0,
          
        },
        series: [
          {
            pointStart: Date.now(), // starting at the moment
            pointInterval: 1000 , // second data
            data: [1, 2, 3],
          },
        ],
      },
    };
  },
  created() {
    const that = this;

    var series = this.chartOptions.series[0];
    setInterval(function () {
      var x = new Date().getTime(), // current time
        y = Math.round(Math.random() * 100);
      series.data.push(Math.random() * 100);
    }, 1000);
  },
  methods: {
    
  },
};
</script>

chapkovski avatar Apr 30 '21 13:04 chapkovski

Hi @chapkovski ,

Thank you for contacting us! I see that you also asked about that on Stack Overflow, and Wojtek has replied on that one. Did this answer resolve your issue and can be closed now, or do you still need any support here?

Kind regards!

Denyllon avatar May 06 '21 07:05 Denyllon

Closing as it's a duplicate.

jszuminski avatar May 25 '23 12:05 jszuminski