chart.js

Start bar-chart at 0 using ChartJS

可紊 提交于 2020-01-15 07:03:31
问题 I have a bar chart which use ChartJS that shows data. Based on the bar chart, I have the data: 15, 2, 0, 11 . I can see all of these data in the bar, except 0. Is there a possibility to start the bar chart on 0, so I can also see the data for the fourth column in the bar chart? options: { legend: { display: false }, scales: { yAxes: [{ display: false, }], xAxes: [{ display: true, }], }, title: { display: false, } } 回答1: After hours of working, finally i found a soulution. There is no chartjs

Start bar-chart at 0 using ChartJS

丶灬走出姿态 提交于 2020-01-15 07:01:29
问题 I have a bar chart which use ChartJS that shows data. Based on the bar chart, I have the data: 15, 2, 0, 11 . I can see all of these data in the bar, except 0. Is there a possibility to start the bar chart on 0, so I can also see the data for the fourth column in the bar chart? options: { legend: { display: false }, scales: { yAxes: [{ display: false, }], xAxes: [{ display: true, }], }, title: { display: false, } } 回答1: After hours of working, finally i found a soulution. There is no chartjs

ChartJS, merge legends for multiple charts

对着背影说爱祢 提交于 2020-01-15 06:14:28
问题 I have multiple charts showing different data. however they are all the same object type e.ge [acc1, acc2, acc3]. Therefore I was wondering if it is possible to have one parent legend set on a page somewhere and clicking it will show/hide all the corresponding dataset from all the charts? 回答1: I think you can hide all the legends of the charts except for one and implement a custom onClick function to handle clicks on that legend and hide all the corresponding datasets for each chart. The

Chart.js How to set line height only to the points?

泄露秘密 提交于 2020-01-15 05:07:47
问题 How to set line height only until points? I have used 'gridLines: display:false' but it hides all lines. Here on image below how it should be 回答1: It's not a native option in Chart.js but you can implement it yourself via plugin. See the annotations in the below code. new Chart(document.getElementById('chart'), { type: 'line', data: { labels: [0, 1, 2, 3, 4, 5], datasets: [{ label: 'series 1', data: [0, 2, 4, 3, 1, 0] }] }, options: { maintainAspectRatio: false, scales: { xAxes: [{ gridLines:

Chart.js How to set line height only to the points?

杀马特。学长 韩版系。学妹 提交于 2020-01-15 05:07:13
问题 How to set line height only until points? I have used 'gridLines: display:false' but it hides all lines. Here on image below how it should be 回答1: It's not a native option in Chart.js but you can implement it yourself via plugin. See the annotations in the below code. new Chart(document.getElementById('chart'), { type: 'line', data: { labels: [0, 1, 2, 3, 4, 5], datasets: [{ label: 'series 1', data: [0, 2, 4, 3, 1, 0] }] }, options: { maintainAspectRatio: false, scales: { xAxes: [{ gridLines:

Chart.js show tooltips on page load

若如初见. 提交于 2020-01-14 18:45:12
问题 I am using http://www.chartjs.org/ to display a pie chart but can't seem to figure out how to display the tooltips on page load. $(document).on('ready page:load', function() { Chart.defaults.global.tooltipEvents = ['click', 'mousemove', 'window.onload']; Chart.defaults.global.customTooltips = function(tooltip) { var text = tooltip.text; var tooltipEl = $('#chartjs-tooltip'); if(!tooltip) { tooltipEl.css({ opacity: 0 }); return; } if(text) { var id = text.split(":")[0].replace(/ /g, '-')

Chartjs display label & units when mouse is hover stats

我只是一个虾纸丫 提交于 2020-01-14 14:21:14
问题 Is it possible to have the label & units when my mouse pointer is hover the chart ? For now there is only the number. For the example bellow I would like to show : 58% Label1 0% Label2 0% Label3 0% Label4 0% Label5 My options looks like this : var options = { //Boolean - Show a backdrop to the scale label scaleShowLabelBackdrop : true, //Boolean - Whether to show labels on the scale scaleShowLabels : true, // Boolean - Whether the scale should begin at zero scaleBeginAtZero : true, scaleLabel

Chartjs - keeping 2 graphs aligned side by side

别来无恙 提交于 2020-01-14 10:17:19
问题 Jsfiddle: http://jsfiddle.net/8gvkmLxL/ I have 2 bar graphs that are next to each other and I want them to be aligned relative to their x-axis. I'm having trouble achieving this as the graph height changes according to the length of the labels (see jsfiddle link). What's the best way to maintain consistency of height of the actual charts (as opposed to the canvas) var data,ctx,mychart; data = { labels: ["Iantojones","Jackharkness","Owenharper"], datasets: [ { label: "My First dataset",

Data with pair X and Y values

偶尔善良 提交于 2020-01-13 18:12:09
问题 Is it possible to use a the pair X and Y in the data option in Chart.js to create the bar char? data: [ ['08/09/2016', 12], ['09/09/2016', 19] ], Being in the form of [X, Y] I didn't find any reference about it in the docs. The closer I got was this found in the line charts example: data: [{ x: -10, y: 0 }, { x: 0, y: 10 }, { x: 10, y: 5 }] 回答1: There is no built-in way to create your chart using an array straight into the data. But you can create a small work around using Chart.js plugins.

How to set default colour for bars in Chart.js

半腔热情 提交于 2020-01-13 09:34:10
问题 This seems stupidly trivial but try as I might I cannot seem to find how to set a default colour for bars in chart.js. My charts is taking its data from an ajax request and the chart is rendering just fine. However neither updating Chart.defaults.global.defaultColor nor adding defaultColor to the dataset as an option has any effect. I would very much appreciate anyone pointing me in the right direction here. $.ajax({ type: 'GET', async: true, url: "{{route('stats.monthlyData')}}", dataType: