chart.js

Chartjs Line Color Between Two Points

本秂侑毒 提交于 2020-06-25 21:37:05
问题 Is there any way to set line color of specific sections in between two points in chart.js? I would like to color the section 00-07 gray, 07-15 red, and 15-23 blue. Here is what I am passing as the data attribute in the options object to initialize the chart: var chartData = { labels: [/* a single dimensional array of strings */], datasets: [ { label: '', data: [/* a single dimensional array of totals */], fill: false, backgroundColor: '#e7eaeb', borderColor: red } ] }; I think this is where I

Convert FirestoreCollection into an array?

江枫思渺然 提交于 2020-06-25 00:58:48
问题 I'm having difficulty converting the Firestore data into an array for the chart.js graph. Getting the data from Firestore fetchData(){ //Get data this.updatesCollection = this.afs.collection(pathStats); this.updates = this.updatesCollection.valueChanges(); } Creating the Chart createChart(){ this.chart = new Chart('canvas', { type: 'line', data: { labels: ['5/18/18', '5/19/18', '5/20/18', '5/21/18', '5/22/18', '5/23/18'], datasets: [{ label: 'Filled', backgroundColor: 'gray', data: [4, 3, 5,

Convert FirestoreCollection into an array?

◇◆丶佛笑我妖孽 提交于 2020-06-25 00:58:40
问题 I'm having difficulty converting the Firestore data into an array for the chart.js graph. Getting the data from Firestore fetchData(){ //Get data this.updatesCollection = this.afs.collection(pathStats); this.updates = this.updatesCollection.valueChanges(); } Creating the Chart createChart(){ this.chart = new Chart('canvas', { type: 'line', data: { labels: ['5/18/18', '5/19/18', '5/20/18', '5/21/18', '5/22/18', '5/23/18'], datasets: [{ label: 'Filled', backgroundColor: 'gray', data: [4, 3, 5,

how to update chartjs2 option (scale.tick.max)

流过昼夜 提交于 2020-06-22 12:02:28
问题 I have a Bar Chart with this Option scales: { yAxes: [{ ticks: { display:false, beginAtZero:true, max: 1150 } }] } now i change the values of my only dataset barChartData.datasets[0].data = newData; and update the chart window.myBar.update(); How can i also update the max scale of the yAxes?? I have to use a max scale so i cant use suggestedMax. 回答1: found the Solution myself. to change any options of the chart: myBar.config.options in my case myBar.config.options.scales.yAxes[0].ticks.max =

how to update chartjs2 option (scale.tick.max)

最后都变了- 提交于 2020-06-22 12:01:45
问题 I have a Bar Chart with this Option scales: { yAxes: [{ ticks: { display:false, beginAtZero:true, max: 1150 } }] } now i change the values of my only dataset barChartData.datasets[0].data = newData; and update the chart window.myBar.update(); How can i also update the max scale of the yAxes?? I have to use a max scale so i cant use suggestedMax. 回答1: found the Solution myself. to change any options of the chart: myBar.config.options in my case myBar.config.options.scales.yAxes[0].ticks.max =

Unable to produce desired UI output for Chartjs tooltips

拥有回忆 提交于 2020-06-17 09:35:26
问题 I have the following scenario: x-axes: String date y-axes: Integers 2 data sets When i hover over a particular data point, i want to display the following: Data collected as of 2020-06-02 33,600 33,000 Diff: 600 Here is what i get instead: Data collected as of undefined 33,600 33,000 Diff: NaN Here is my tooltip callbacks code: tooltips: { mode: 'index', intersect: false, callbacks: { title: function(toolTipItem, data) { return "Data points collected as of " + toolTipItem.xLabel; // return

ng2-charts: How to set fixed range for y axis

試著忘記壹切 提交于 2020-06-14 10:28:25
问题 I have a chart.js chart using ng2-charts module. The chart shows Percentage on y axis and time on x axis. Is it possible to set y axis to show 0 to 100 instead of dynamic range based on data? 回答1: Try adding the following to your chart options: scales : { yAxes: [{ ticks: { steps : 10, stepValue : 10, max : 100, min: 0 } }] } https://github.com/valor-software/ng2-charts/issues/853 回答2: In my name.component.html: <div style="display: block"> <canvas baseChart height="100" [datasets]=

ng2-charts: How to set fixed range for y axis

假装没事ソ 提交于 2020-06-14 10:25:51
问题 I have a chart.js chart using ng2-charts module. The chart shows Percentage on y axis and time on x axis. Is it possible to set y axis to show 0 to 100 instead of dynamic range based on data? 回答1: Try adding the following to your chart options: scales : { yAxes: [{ ticks: { steps : 10, stepValue : 10, max : 100, min: 0 } }] } https://github.com/valor-software/ng2-charts/issues/853 回答2: In my name.component.html: <div style="display: block"> <canvas baseChart height="100" [datasets]=

ng2-charts: How to set fixed range for y axis

痴心易碎 提交于 2020-06-14 10:25:21
问题 I have a chart.js chart using ng2-charts module. The chart shows Percentage on y axis and time on x axis. Is it possible to set y axis to show 0 to 100 instead of dynamic range based on data? 回答1: Try adding the following to your chart options: scales : { yAxes: [{ ticks: { steps : 10, stepValue : 10, max : 100, min: 0 } }] } https://github.com/valor-software/ng2-charts/issues/853 回答2: In my name.component.html: <div style="display: block"> <canvas baseChart height="100" [datasets]=

Chart.js 2.0: How to change title of tooltip

浪子不回头ぞ 提交于 2020-06-09 11:48:24
问题 Forgive me for my sometimes poor English. Dutch is my native language. I've created a Chart.js linechart which shows me my energy usage reported by my main power smart meter. I got it almost working like the way I want, but there is one thing I can't manage to get it to work in a way I want because I don't understand a little thing. With some help of the user "iecs" at the topic "Chart.js V2: Add prefix or suffix to tooltip label" I was able to change the label at the tooltip. It now shows