A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://nagix.github.io/chartjs-plugin-streaming/master/samples/integration/financial.html below:

Financial | chartjs-plugin-streaming

chartjs-plugin-streaming # Financial

Integration with chartjs-chart-financial (opens new window)

const config = {
  type: 'candlestick',
  data: data,
  options: {
    scales: {
      x: {
        type: 'realtime',
        ticks: {
          source: 'auto'
        },
        realtime: {
          duration: 120000,
          refresh: 500,
          delay: 0,
          onRefresh: onRefresh
        }
      }
    },
    interaction: {
      intersect: false
    },
    animation: {
      duration: 0
    },
    plugins: {
      legend: {
        display: false,
      }
    }
  },
};
const data = {
  datasets: [
    {
      data: []
    }
  ]
};
const onRefresh = chart => {
  const _data = chart.data.datasets[0].data;
  let t = Date.now();
  let last;
  t -= t % 5000;
  if (_data.length === 0) {
    _data.push({x: t - 5000, o: 99, h: 101, l: 98, c: 100});
  }
  last = _data[_data.length - 1];
  if (t !== last.x) {
    const c = last.c;
    last = {x: t, o: c, h: c, l: c, c: c};
    _data.push(last);
  }
  last.c = +(last.c + Utils.rand(-0.5, 0.5)).toFixed(2);
  last.h = +Math.max(last.h, last.c).toFixed(2);
  last.l = +Math.min(last.l, last.c).toFixed(2);
};

For plain JavaScript, use script tags in the following order.

Zoom Interactions


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4