chart.js2

Chart.js 2.0 doughnut tooltip percentages

爷,独闯天下 提交于 2019-11-28 17:00:46
问题 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

Moving vertical line when hovering over the chart using chart.js

▼魔方 西西 提交于 2019-11-28 07:41:02
I've been trying to add a vertical line that shows up with a tooltip when hovering over the chart. But I'm using chart.js 2.6 and the syntax from 1.x seems to be outdated. I've the following code working for 1.x var data = { labels: ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"], datasets: [{ data: [12, 3, 2, 1, 8, 8, 2, 2, 3, 5, 7, 1] }] }; var ctx = document.getElementById("LineWithLine").getContext("2d"); Chart.types.Line.extend({ name: "LineWithLine", draw: function () { Chart.types.Line.prototype.draw.apply(this, arguments); var point = this.datasets

Chart.js - Increase spacing between legend and chart

人盡茶涼 提交于 2019-11-27 21:16:02
I have a bar chart where I have drawn 3 vertical lines, each with it's own label at the top. I would like those labels to be above the top of the y-axis (above the 30% line in the example) but below the legend. I can't figure out how to increase the space between the top legend and the chart such that I can have my vertical line labels (15, 24 & 33) be off of the chart itself but below the legend. Any ideas? Unfortunately, since there is no config option to handle this the only way you can achieve the desired result is to extend Chart.Legend and implement the afterFit() callback. Here is a

How can I change the font (family) for the labels in Chart.JS?

↘锁芯ラ 提交于 2019-11-27 15:05:53
I want to change the font to something snazzier in my Chart.JS horizontal bar chart. I've tried the following, but none of it works: var optionsBar = { . . . //fontFamily: "'Candara', 'Calibri', 'Courier', 'serif'" //bodyFontFamily: "'Candara', 'Calibri', 'Courier', 'serif'" //bodyFontFamily: "'Candara'" label: { font: { family: "Georgia" } } }; I also read that this would work: Chart.defaults.global.defaultFont = "Georgia" ...but where would this code go, and how exactly should it look? I tried this: priceBarChart.defaults.global.defaultFont = "Georgia"; ...but also to no good effet. For the

Chart JS Fill Between two lines

旧巷老猫 提交于 2019-11-27 01:46:32
问题 I am looking for a way to fill between two lines with Chart.js so that it would look like this. I have looked and everything seems to talk about filling between two lines across zero. I also need other lines to fill all the way down like normal. Is this something chart.js can do? 回答1: Here is a solution that uses a plugin to fill between two datasets. Supports all line styles and fill shading between multiple lines. To fill between a dataset, use the custom param fillBetweenSet to tell a