react-chartjs

How to Update chart in react-chartjs-2?

孤街浪徒 提交于 2021-02-08 13:44:58
问题 I call the update() function, but it does not work. TypeError: line.update is not a function. Why is update() not a function? I have seen this example on http://jsfiddle.net/zpnx8ppb/26/ where the update function does work Here is my code: import React, { Component } from 'react'; import { Line } from 'react-chartjs-2'; import Chart from 'chart.js'; const line = { labels: [], datasets: [ { label: 'My First dataset', fill: false, data: [] } ] }; setInterval(function(){ line.labels.push(Math

How to make labels on both side from horizontal bar chart js

…衆ロ難τιáo~ 提交于 2021-01-29 05:13:56
问题 I want to make side labels for double horizontal bar on both side like this: pic 1, pic 2 can someone help me idk how to do it, im new in react and chartjs this post continued from: How to make multiple horizontal bar chartjs here's what i code: this the data: data for chart export const dataPasienKeluarMasuk = { type: 'bar', labels: [ [0, 1, 2, 3,4], // expect output 0 - 4 [5, 6, 7, 8, 9], // expect output 5 - 9 [10, 14], // ext.. [15, 19], [20, 24], [25, 29], [30, 34], ], datasets: [ {

Chart.js Customizing Tick Labels for Mixed Font Styles

。_饼干妹妹 提交于 2021-01-28 07:01:00
问题 I am building a chart with React and Chart.js, and I need to display tick labels that have mixed font styles. Chart.js returns the tick values as a string of the the text passed in as well as the HTML tags that wrap the values we want to italicize. I tried writing a callback function to return jsx which nulled out the y axis tick marks. Additionally, I have tried applying conditions to the fontStyle prop, and customizing the html in the labels. let italicizedFont = 'Font'.italics() console

react-chartjs-2 vertical line when hovering over chart

白昼怎懂夜的黑 提交于 2021-01-28 03:56:57
问题 I'm trying to create a linechart, using react-chartjs-2, that has a vertical line when hovering over the datapoints in the chart. Like in this picture below: Chart requirements I tried using the chartjs-plugin-annotation plugin, but with mixed results. I managed to create a static line, not understanding how or why it works. How should I achieve this? Am I onto something? const data = { labels: [...week(d)], datasets: [ { ... data: [10000, 9500, 7000, 4500, 2500, 1500, 500, 0], } ] }; var

react-chartjs-2 vertical line when hovering over chart

风格不统一 提交于 2021-01-28 00:51:37
问题 I'm trying to create a linechart, using react-chartjs-2, that has a vertical line when hovering over the datapoints in the chart. Like in this picture below: Chart requirements I tried using the chartjs-plugin-annotation plugin, but with mixed results. I managed to create a static line, not understanding how or why it works. How should I achieve this? Am I onto something? const data = { labels: [...week(d)], datasets: [ { ... data: [10000, 9500, 7000, 4500, 2500, 1500, 500, 0], } ] }; var