score:0
The problem seems that when a chart instance is constructed, the 'realtime' scale is not registered yet, and chart.scales['x-axis-0']
is left undefined
. Please make sure the chartjs-plugin-streaming is imported before a chart is constructed.
By the way, you don't need to register the plugin object to the pluginService explicitly. It is done with import 'chartjs-plugin-streaming'
. Try this working sample:
import React from 'react';
import ReactDOM from 'react-dom';
import { Bubble } from 'react-chartjs-2';
import 'chartjs-plugin-streaming';
ReactDOM.render(
<Bubble
data={{
datasets: [{
label: 'demo',
backgroundColor: 'rgba(75,192,192,1)',
data: []
}]
}}
options={{
plugins: {
streaming: {
onRefresh: function(chart) {
chart.data.datasets[0].data.push({
x: Date.now(),
y: Math.random() * 100,
r: 5
});
},
delay: 500,
refresh: 1000,
frameRate: 30,
duration: 3600000 // 3600000 = 1hour
}
},
scales: {
xAxes: [{
type: 'realtime'
}]
}
}}
/>
, document.getElementById('root'));
Source: stackoverflow.com
Related Query
- how to get React chartjs to resize back down with window
- Graph streaming real-time data with react and chartjs
- Chartjs not working with d3 from csv source
- React component wont re-render ChartJS chart with redux props
- ReactJs issues with setstate on array in ChartJs
- Updating Chartjs to 2.5 with custom code
- Styling background (fill) with ChartJs and React
- Use chartjs-plugin-annotation 0.5.7 in Chartjs 2.9.x with React
- Trying to export chart with Chartjs and React but getting erorr
- Having issues with running npm start after installing chartjs
- Issues with Moment and ChartJS Time Format Parsing
- ChartJS - Issues with positioning and viewing various components of horizontal bar
- Rest api / json error while using it with react chartjs
- Error Message when using ChartJS with React
- showing values or percentages with chartjs in react
- Custom Legend with ChartJS v2.0
- Chartjs random colors for each part of pie chart with data dynamically from database
- ChartJS New Lines '\n' in X axis Labels or Displaying More Information Around Chart or Tooltip with ChartJS V2
- ChartJS - Draw chart with label by month, data by day
- Display line chart with connected dots using chartJS
- react-chartjs-2 with chartJs 3: Error "arc" is not a registered element
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- Show bar with zero value in ChartJs v2
- Using Charts.js with react
- Chartjs linechart with only one point - how to center
- How to fix chart Legends width-height with overflow scroll in ChartJS
- ChartJS - Donut charts with multiple rings
- Chartjs v2 xAxes label overlap with scaleLabel
- Updating chartJS with dynamic data
- TypeError: Cannot read property 'defaults' of undefined when using the react wrapper of chartjs
More Query from same tag
- How to adjust Chart.js height according to datasets size. Ionic 3
- how can I render multiple charts in chartjs?
- How to have chart.js automatically build x-axis labels based on x,y dataset?
- Uncaught TypeError: Cannot read property 'draw' of undefined
- Updating chart.js not working after recieved new data from database with ajax
- How would I include toBase64Image class using the fxcosta library for Chart.js
- Erro Nova ChartJs SQL Generator when using PostgreSQL
- How can I sort, insert in between and update full dataset in chartjs?
- ChartJS executes a function multiple times
- Set max value for each label with Chart.js
- Calculate the average distance between two data sets of X and Y (in JS)
- how do I break a comma separated string into new lines in tooltip callbacks afterBody?
- ChartJS: add a clickable text in title
- How to change colours for Angular-Chart.js
- ChartJS - Finding the minimum and maximum labels that are inside a pan (When zooming)
- Is it possible to make points in a line chart of Chart JS 3.7.0 look like a donut?
- Chartjs: Is it possible to hide the data labels on the axis but show up on the graph on hover?
- Chart.js sets canvas dimentions to 0x0 and do not display anything
- chartjs stepSize by 5
- Adding line over stacked line chart with ChartJS
- Chart.js is not displayed when page loads first time
- Utils package in Chart.js
- Chart.js stacked line chart with differently styled sections
- How to align ticks label in chartJS 3.x?
- ChartsJS get value of Data/Dataset Label for Tooltip
- Chart.JS To Not Start At 0
- Change border color on legend in Chart.js
- How to add legend on chart js annotation
- ChartJS + jQuery = Chart not showing
- Update Chart.js data with ajax