chart.js2

Chart.js v2: space between doughnut inside doughnut

我的未来我决定 提交于 2019-12-02 13:31:50
问题 I am using chart.js v2.5.0. I put doughnut inside doughnut. I want the disdance between 2 doughnuts( A ) to be larger without affecting the distance between slices inside the same doughnut( B ). Please see the following image: Currently I am using the property borderWidth . However, this also affects the width of B . Please see the following code: options: { elements: { arc: { borderWidth: 18, }, }, cutoutPercentage: 60, responsive: true, } I want the doughnuts to look like this: 回答1: The

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

早过忘川 提交于 2019-12-02 10:02:09
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", "#421C52", "#FEA620" ] } ] }; var optionsPie = { responsive: true, scaleBeginAtZero: true, tooltips: {

How to remove the line/rule of an axis in Chart.js?

て烟熏妆下的殇ゞ 提交于 2019-12-01 19:03:33
问题 I managed to remove all horizontale lines/rules in my chart using this: scales: { xAxes: [{ gridLines: { display: false } }] } But I also want to get rid of the rule/bar that represents the Y-axis as well. But I want to keep the labels : Unfortunately I can't find any option for that. I can only remove the whole axis including labels. I'm using Chart.js 2.3. 回答1: I found a way to remove this line. It's actually called the border of the axis and there's an option for it, see "Grid Line

How to remove the line/rule of an axis in Chart.js?

可紊 提交于 2019-12-01 19:00:49
I managed to remove all horizontale lines/rules in my chart using this: scales: { xAxes: [{ gridLines: { display: false } }] } But I also want to get rid of the rule/bar that represents the Y-axis as well. But I want to keep the labels : Unfortunately I can't find any option for that. I can only remove the whole axis including labels. I'm using Chart.js 2.3. I found a way to remove this line. It's actually called the border of the axis and there's an option for it, see "Grid Line Configuration" : scales: { yAxes: [{ gridLines: { drawBorder: false, } }] } This should work options: { scales: {

How can I show a subset of data on pie pieces in Chart.JS while still displaying the superset when hovering?

大兔子大兔子 提交于 2019-12-01 14:14:00
I've got a pie chart that looks like this when hovering over a piece of pie: Except for wanting the legend to the right instead of on top , I'm fairly content with this, but I want just the percentage value to display "all the time" in the pie pieces - and still have the <name> (<%val>): <data> displayed on hover. In other words, I want the pie to look something like this: How can I break that one piece of data out (the percentage) and draw that onto each piece of pie? Here is the code I'm using so far: var formatter = new Intl.NumberFormat("en-US"); var data = { labels: [ "Bananas (18%)",

How to add text in centre of the doughnut chart using Chart.js?

China☆狼群 提交于 2019-12-01 06:53:32
I want to create a Doughnut graph with two values. Clicking the graphs should print the value in center. I found a solution in stackoverflow similar to my requirement. I would like to use latest Chart.js library from github . Is this feature is available in latest Chart.js? David It is certainly possible to do something like this in Chart.js v2.x I think the nicest way to do it is by using a plugin. In fact, Cmyker awnser to the question you linked to even updated his posts to show how this would work in Charts.js v2.x See his fiddle: https://jsfiddle.net/cmyker/ooxdL2vj/ and the corresponding

Chart.js remove stacking

故事扮演 提交于 2019-12-01 06:40:53
问题 I have a stacked bar chart and two line charts. The second line chart is beeing stacked on top of the first line chart but I don't want this behaviour. What I've tried is to explicitly set the stack mode on false ,but this option is not beeing executed. ... type: 'line', label: 'lineChart1', data: lineData1, borderWidth: 1, fill: false, options: { legend: { display: false }, scales: { xAxes: [{ stacked: false, }], yAxes: [{ stacked: false }] } } } ... 回答1: Here is an example that configures a

How to add text in centre of the doughnut chart using Chart.js?

你。 提交于 2019-12-01 04:53:20
问题 I want to create a Doughnut graph with two values. Clicking the graphs should print the value in center. I found a solution in stackoverflow similar to my requirement. I would like to use latest Chart.js library from github. Is this feature is available in latest Chart.js? 回答1: It is certainly possible to do something like this in Chart.js v2.x I think the nicest way to do it is by using a plugin. In fact, Cmyker awnser to the question you linked to even updated his posts to show how this

Modifying the X-Axis Labels of a Scatterplot in Chart.js 2

眉间皱痕 提交于 2019-11-30 14:30:02
In Chart.js 2 I am generating a scatter-plot where there x coordinates are Epoch timestamps and the y coordinates are integers. I was wondering if there was a way to format the x-axis labels of the graph, so that the dates are displayed in a human-readable format. Update: Currently I am building my graph from Unix timestamps in milliseconds. The other parts of this prototype format those dates with the toDateString method of the Date class (eg. Fri Aug 5 2016). For this you can make use of the ticks.userCallback in the scales.xAxes option so that you return a formatted date for each xaxis tick

Modifying the X-Axis Labels of a Scatterplot in Chart.js 2

余生颓废 提交于 2019-11-29 19:03:33
问题 In Chart.js 2 I am generating a scatter-plot where there x coordinates are Epoch timestamps and the y coordinates are integers. I was wondering if there was a way to format the x-axis labels of the graph, so that the dates are displayed in a human-readable format. Update: Currently I am building my graph from Unix timestamps in milliseconds. The other parts of this prototype format those dates with the toDateString method of the Date class (eg. Fri Aug 5 2016). 回答1: For this you can make use