chart.js2

Hide first label in legend in a Chart using chart.js

扶醉桌前 提交于 2019-12-11 19:34:56
问题 I have created a stacked bar chart and i have to hide first dataset's label and its box in legend which is "Total Line", Is there anyway to hide first or any dataset's label. i have read the documentation there is a filter in options but it didn't work. Hiding This label Here is the html and js for chart var ctx = document.getElementById("girth-measure-chart"); var totalLine = [115, 118, 88, 93, 103, 118, 125] var total = [112, 115, 85, 90, 100, 115, 122] var arms = [46, 55, 41, 41, 47, 54,

Chart.js integration to Django project

牧云@^-^@ 提交于 2019-12-11 19:26:53
问题 New to Charts.js and Django. Seems like I make it working, but not as good as I want it to. Would like to integrate two calculations made on Django side: my views.py: def graph(request): bug_all = BugTable.objects.filter() bug_all_total = bug_all.count() bug_posted = BugTable.objects.filter( status=BugTable.BUG_POSTED) bug_posted_total = bug_posted.count() context = {'bug_all_total': bug_all_total, 'bug_posted_total': bug_posted_total} return render(request, 'graph.html', context) my graphs

ChartJs - set background color of the space between ticks

痴心易碎 提交于 2019-12-11 17:35:12
问题 I need to set the even/odd space between the ticks background color just like in the following image; See the "Interlaced Colors" background color. I need to do this for both vertical and horizontal graphs. See for example: https://canvasjs.com/docs/charts/chart-options/axisY/interlacedcolor/ Any idea on how can I implement something similar in chart js? I also found an almost good solution here: http://jsfiddle.net/e7oy6yk6/2 1) HTML code: <canvas id="myChart"></canvas> 2) Javascript code:

ChartJS plugin datalabels not showing labels on Ionic 3

久未见 提交于 2019-12-11 10:27:48
问题 I'm working with Ionic 3, I'm displaying a bar chart and I need to show data label next to the bar on chart, like this question how to display data values on Chart.js I followed the instructions I have found so far for chartjs-plugin-datalabels but is not working, it's not showing any data label on my chart. I installed chartjs and chartjs-plugin-datalabels via npm and they look like this in my package.json "chart.js": "^2.7.3", "chartjs-plugin-datalabels": "^0.5.0", I did the imports just

How can I calculate a value and place it inside the last bar in a Chart.JS bar chart?

≯℡__Kan透↙ 提交于 2019-12-11 07:08:24
问题 Since it seems impossible or highly difficult (no working answers here) to place a label above the last bar on a bar chart, I would like to now know how to place a label inside the last bar. I am adding labels to all the bars of a horizontal bar chart with this code: Chart.pluginService.register({ afterDraw: function (chartInstance) { if (chartInstance.id !== 1) return; // affect this one only var ctx = chartInstance.chart.ctx; // render the value of the chart above the bar ctx.font = Chart

How to fit Doughnut Chart JS into Bootstrap column?

廉价感情. 提交于 2019-12-11 06:28:43
问题 I want my Doughnut graphic from Chart.js to fit into my bootstrap column. I also want this column to be specific size (actually, I more concerned about height). The problem is that size of canvas div is actually bigger than my column div and all charts overlap on each other. Ideally, I want all 4 charts to be aligned to the right of the row and have a little space from the right (some margin of 10px for example). I've tried to play around with margin/padding settings on the column div and

Chart.js v2 formatting time labels

我的梦境 提交于 2019-12-11 04:10:03
问题 I have charts where a user can input a different range of time spans in order to get a desired result set to graph. Depending on the range of the graph, the formatting of the times should be different. As an example, looking at a graph that's 10 minutes long, you'll probably see something along the lines of a time that's formatted HH:MM, but that won't make sense for a month long graph, where formatting would make more sense in the format of mm/dd. I have the beginning timestamp (unix ts) and

Select All and Unselect Option for chart.js

时间秒杀一切 提交于 2019-12-10 22:36:41
问题 I'm Working on Chart.js, wanted to implement Select All and Unselect All option for labels. I'm trying to find it out but couldn't get anything such. Please do help me out if anything such feature can be implemented. 回答1: If you need to show/hide charts selecting/unselecting all labels here is an example: var barChartData = { labels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32], datasets: [{ label: 'One',

Stacked bar charts in Chart.js with JSON data

本秂侑毒 提交于 2019-12-08 10:38:05
问题 I have following JSON data. [ { "date": "2016-05-01T00:00:00", "productInformation": [ { "productName": "Apple", "totalWeight": 200 } ] }, { "date": "2016-09-01T00:00:00", "productInformation": [ { "productName": "Apple", "totalWeight": 632 }, { "productName": "Mango", "totalWeight": 856 }, { "productName": "Spinach", "totalWeight": 545 }, { "productName": "Grapes", "totalWeight": 338 } ] }, { "date": "2017-01-01T00:00:00", "productInformation": [ { "productName": "Mango", "totalWeight": 500

Chartjs 2: Multi level/hierarchical category axis in chartjs

只愿长相守 提交于 2019-12-07 09:50:31
问题 Is it possible to define a bar chart with a multi level/category axis? For instance I'd like to display the Region/Province categories like in this Excel chart: I found this example using multiple xAxes. xAxes:[ { id:'xAxis1', type:"category", ticks:{ callback:function(label){ var month = label.split(";")[0]; var year = label.split(";")[1]; return month; } } }, { id:'xAxis2', type:"category", gridLines: { drawOnChartArea: false, // only want the grid lines for one axis to show up }, ticks:{