chart.js2

Chart.js - Setting max Y axis value and keeping steps correct

风格不统一 提交于 2019-12-06 12:47:38
问题 I'm using Chart.js 2.6. I have a chart to which I've added custom pagination to step through the dataset, as it is quite large. My pagination and everything works great, I simply grab the next chunk of data in my set and update the chart.config.data with the new data object, and then call .update() on the chart. However, in order to make the chart make sense, I needed to keep the left (Y-axis) scale the same when the user is paginating through. Normally Chart.js would rebuild it based on the

Chartjs 2: Multi level/hierarchical category axis in chartjs

北战南征 提交于 2019-12-05 17:59:18
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:{ callback:function(label){ var month = label.split(";")[0]; var year = label.split(";")[1]; if(month ===

Chart.js - Setting max Y axis value and keeping steps correct

▼魔方 西西 提交于 2019-12-04 18:38:48
I'm using Chart.js 2.6. I have a chart to which I've added custom pagination to step through the dataset, as it is quite large. My pagination and everything works great, I simply grab the next chunk of data in my set and update the chart.config.data with the new data object, and then call .update() on the chart. However, in order to make the chart make sense, I needed to keep the left (Y-axis) scale the same when the user is paginating through. Normally Chart.js would rebuild it based on the data in the chart, but I want it to always reflect the same values. I've set the max value on the yAxes

Draw horizontal lines in Chart.js 2.0

二次信任 提交于 2019-12-04 17:49:48
问题 Can you help me how to extend Chart.js v2.0. I need to draw some horizontal lines in the charts, something similar to: http://jsfiddle.net/vsh6tcfd/3/ var originalLineDraw = Chart.controllers.bar.prototype.draw; Chart.helpers.extend(Chart.controllers.bar.prototype, { draw: function() { originalLineDraw.apply(this, arguments); var chart = this.chart; var ctx = chart.chart.ctx; var index = chart.config.data.lineAtIndex; if (index) { var xaxis = chart.scales['x-axis-0']; var yaxis = chart.scales

How do I customize y-axis labels on a Chart.js line chart?

只谈情不闲聊 提交于 2019-12-04 11:11:43
问题 I have the following chart and would like to manually set the Y axis labels. Instead of using 1,2,3,4,5, I want One, Two, Three, Four, Five. Is there a way to do this? Here's my options structure: options = { scales: { yAxes: [{ scaleLabel: { labelString: ["One", "Two", "Three", "Four", "Five"] }, ticks: { min: 1, max: 5, stepSize: 1, suggestedMin: 0.5, suggestedMax: 5.5}, gridLines: {display: false} }] }, }; 回答1: In the ticks object you can pass a callback that will be given the label it is

How can I cause a legend to appear to the right of the pie (Chart.JS)?

五迷三道 提交于 2019-12-04 06:22:22
问题 I'm creating a fairly simple pie chart with Chart.JS like so: var data = { labels: [ "Bananas (18%)", "Lettuce, Romaine (14%)", "Melons, Watermelon (10%)", "Pineapple (10%)", "Berries (10%)", "Lettuce, Spring Mix (9%)", "Broccoli (8%)", "Melons, Honeydew (7%)", "Grapes (7%)", "Melons, Cantaloupe (7%)" ], datasets: [ { data: [2755, 2256, 1637, 1608, 1603, 1433, 1207, 1076, 1056, 1048], backgroundColor: [ "#FFE135", "#3B5323", "#fc6c85", "#ffec89", "#021c3d", "#3B5323", "#046b00", "#cef45a", "

Removing legend on charts with chart.js v2

女生的网名这么多〃 提交于 2019-12-03 02:06:48
问题 I'm making a homepage using, Bootstrap, JQuery and Chart.js (v2). I had my implementation working using v1, but recently just got into Bower and downloaded v2 using that. I'm making a grid of 4 columns each containing a pie chart, however the scaling in v2 is sort of confusing for me to get working. I want the charts to be responsive so they scale properly with the smaller devices such as tablets and smartphones, and one of my problems is getting rid of the legend of the charts as well as the

Chart.js 2.0 doughnut tooltip percentages

风格不统一 提交于 2019-12-02 16:09:50
I have worked with chart.js 1.0 and had my doughnut chart tooltips displaying percentages based on data divided by dataset, but I'm unable to replicate this with chart 2.0. I have searched high and low and have not found a working solution. I know that it will go under options but everything I've tried has made the pie dysfunctional at best. <html> <head> <title>Doughnut Chart</title> <script src="../dist/Chart.bundle.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <style> canvas { -moz-user-select: none; -webkit-user-select: none; -ms

Removing legend on charts with chart.js v2

﹥>﹥吖頭↗ 提交于 2019-12-02 15:41:50
I'm making a homepage using, Bootstrap, JQuery and Chart.js (v2). I had my implementation working using v1, but recently just got into Bower and downloaded v2 using that. I'm making a grid of 4 columns each containing a pie chart, however the scaling in v2 is sort of confusing for me to get working. I want the charts to be responsive so they scale properly with the smaller devices such as tablets and smartphones, and one of my problems is getting rid of the legend of the charts as well as the hover information when hovering the mouse over the sections of my chart. index.html <body> <div class=

Chart.js v2 - hiding grid lines

被刻印的时光 ゝ 提交于 2019-12-02 14:59:41
I am using Chart.js v2 to draw a simple line chart. Everything looks fine, except there are grid lines that I don't want: The documentation for Line Chart is here: https://nnnick.github.io/Chart.js/docs-v2/#line-chart , but I can't find anything about hiding those "Grid Lines". How can I remove the grid lines? Irvine I found a solution that works for hiding the grid lines in a Line chart. Set the gridLines color to be the same as the div's background color. var options = { scales: { xAxes: [{ gridLines: { color: "rgba(0, 0, 0, 0)", } }], yAxes: [{ gridLines: { color: "rgba(0, 0, 0, 0)", } }] }