chart.js

Chart Js , loading data on selection but bar graph displaying old values as well on hovering

天大地大妈咪最大 提交于 2021-01-29 08:56:05
问题 I am trying to dynamically update the chart. I have got different values from the database via another js for name (#cellname) also there is cellname and throughput against each other in data.php (which is being called by ajax). Whenever new selection is made the below script is running fine except when i move mouse on the graph it displays old graph as well, somehow i am lacking to use the chart update function. $(document).ready(function() { function load_stats(id) { $.ajax({ url: "http:/

how to show speedometer on Doughnut chart in chart.js using reactjs

旧街凉风 提交于 2021-01-29 08:54:06
问题 I've created a half doughnut chart and wanted to show like a speedometer, but couldn't able to make it. I have gone through this link I want to display my chart Either as similar to the above link or as per this snippet Here is my code: import React, { Component } from "react"; import { Doughnut } from "react-chartjs-2"; import Data from "./Data.json"; const data = { // labels: ["Red", "Green", "Yellow"], datasets: [ { data: [500, 500, 500], backgroundColor: ["red", "#FFCE56", "lightgreen"],

ERROR TypeError: Cannot read property 'testMethod' of undefined

余生长醉 提交于 2021-01-29 08:50:58
问题 I have following code for component.ts export class HomeComponent implements OnInit { Linecap = {}; dataArray=[]; constructor(private chartGetDataService: ChartGetDataService) { } ngOnInit(): void { this.chartPlotting(); } public testMethod(){ this.chartGetDataService.getLatestData1().subscribe( list=>{ this.dataArray=list.map(item=>{return item.payload.val()});} ); console.log(this.dataArray); return this.dataArray; } public chartPlotting(){ this.Linecap= new Chart('canvas', { type: 'line',

React Native Updating State with Api

馋奶兔 提交于 2021-01-29 08:25:17
问题 0 Hi I'm trying to update the state data value (data:[]) from API. the issue is from the line highlighted this.setState({data.datasets[0].data.data:response.data.rates.AUD}) import React from 'react'; import {Bar} from 'react-chartjs-2'; import axios from 'axios'; class App extends React.Component { constructor(props) { super(props) this.state = { data: { labels:["UK"], datasets:[ {label:"Dev Test",data:[]} ] }} this.test = this.test.bind(this) } async test() { const response = await axios

Chartjs show hidden data on tooltip

心已入冬 提交于 2021-01-29 06:26:15
问题 Good Day, I have a bar chart with multiple datasets for the chart. I would like to hide all the bars except for one (a Totals if you will), and on the Tooltip, I want to show all of the data in all the datasets. Unfortunately, the tooltip only shows the visible datasets. Does anyone know how to show all the data sets? If you run this with <canvas id="myChart" width="400" height="400"></canvas> Hover over the chart and the first dataset (labeled 'First Label') is not shown. How do I show that

Dataset._meta[0].dataset is null in ChartJS

廉价感情. 提交于 2021-01-29 06:13:16
问题 I'm trying to show the value of each bar using chart JS. I saw this thread and followed, but I got an error. Link: How to show data values or index labels in ChartJs (Latest Version) var options = { events: false, showTooltips: false, animation: { duration: 0, onComplete: function(){ var ctx = this.chart.ctx; ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontFamily, 'normal', Chart.defaults.global.defaultFontFamily); ctx.textAlign = 'center'; ctx.textBaseLine = 'bottom';

Chart.js update() method only works once in the end instead of updating every iteration

…衆ロ難τιáo~ 提交于 2021-01-29 06:07:34
问题 function insertSort(inputArray = myChart.data.datasets[0].data) { let inputArrayLength = inputArray.length; let outerIndex = 1; let innerIndex = 0; while(outerIndex<inputArrayLength) { innerIndex = outerIndex - 1; temp = outerIndex; while(innerIndex>=0){ if (inputArray[temp]<inputArray[innerIndex]){ inputArray[innerIndex] = [inputArray[temp], inputArray[temp] = inputArray[innerIndex]][0]; temp = innerIndex; innerIndex--; } else { innerIndex--; } } sleep(1000); console.log('Intermediate result

Chartjs - Stacked bar chart blocking other values

最后都变了- 提交于 2021-01-29 05:29:10
问题 My problem is that chart js is rendering the bar chart based on the order defined on the dataset. As you can see below, the values at index 0 of the arrays are 2500 and 1000 . Since the 2500 was passed first, this will block the bar chart of the 1000 value. https://jsfiddle.net/6bjy9nxh/352/ var barData = { labels: ['Italy', 'UK', 'USA', 'Germany', 'France', 'Japan'], datasets: [ { label: '2010 customers #', fillColor: '#382765', data: [2500, 1902, 1041, 610, 1245, 952] }, { label: '2014

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: [ {

ChartJS: chart not show all data

我与影子孤独终老i 提交于 2021-01-29 03:22:57
问题 For some reason, this chart not show the last two data from the array. var data = { labels: ["Brasil", "Argentina", "Chile", "Paraguai", "Peru", "Bolívia", "México"], datasets: [{ data: [ 9.19, 7.77, 6.80, 6.23, 6.00, 4.00, 4.00 ], backgroundColor: backgroundColor }], }; http://codepen.io/marcelo2605/pen/PWWqJm?editors=0010 Anyone known why is this happens? 回答1: you need to set Y-Axis to start with 0, by default it start with the minimum value present in the data set which is 4 in your case.