Javascript 为Line chart.js添加值

Javascript 为Line chart.js添加值,javascript,jquery,chart.js,Javascript,Jquery,Chart.js,我为show Line Chart工作。现在,我需要为折线图中鼠标悬停的每个值添加标题/值 Js: 如何为每个价值/月份添加标题/价值 演示:如果您使用最新版本的chart.js,则有一个新的更新允许您显示带有值/标题的工具提示 有几个选项可以自定义鼠标悬停时的工具提示 // Boolean - Determines whether to draw tooltips on the canvas or not showTooltips: true, // Array - Array of str

我为show Line Chart工作。现在,我需要为折线图中鼠标悬停的每个值添加标题/值

Js:

如何为每个价值/月份添加标题/价值


演示:

如果您使用最新版本的chart.js,则有一个新的更新允许您显示带有值/标题的工具提示

有几个选项可以自定义鼠标悬停时的工具提示

// Boolean - Determines whether to draw tooltips on the canvas or not
showTooltips: true,

// Array - Array of string names to attach tooltip events
tooltipEvents: ["mousemove", "touchstart", "touchmove"],

// String - Tooltip background colour
tooltipFillColor: "rgba(0,0,0,0.8)",

// String - Tooltip label font declaration for the scale label
tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",

// Number - Tooltip label font size in pixels
tooltipFontSize: 14,

// String - Tooltip font weight style
tooltipFontStyle: "normal",

// String - Tooltip label font colour
tooltipFontColor: "#fff",

// String - Tooltip title font declaration for the scale label
tooltipTitleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",

// Number - Tooltip title font size in pixels
tooltipTitleFontSize: 14,

// String - Tooltip title font weight style
tooltipTitleFontStyle: "bold",

// String - Tooltip title font colour
tooltipTitleFontColor: "#fff",

// Number - pixel width of padding around tooltip text
tooltipYPadding: 6,

// Number - pixel width of padding around tooltip text
tooltipXPadding: 6,

// Number - Size of the caret on the tooltip
tooltipCaretSize: 8,

// Number - Pixel radius of the tooltip border
tooltipCornerRadius: 6,

// Number - Pixel offset from point x to tooltip edge
tooltipXOffset: 10,

// String - Template string for single tooltips
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>",
//布尔值-确定是否在画布上绘制工具提示
showTooltips:true,
//Array-用于附加工具提示事件的字符串名称数组
工具提示事件:[“鼠标移动”、“touchstart”、“touchmove”],
//字符串-工具提示背景颜色
工具提示FillColor:“rgba(0,0,0,0.8)”,
//字符串-缩放标签的工具提示标签字体声明
tooltipFontFamily:“'Helvetica Neue','Helvetica','Arial',无衬线”,
//数字-工具提示标签字体大小(以像素为单位)
工具提示字体大小:14,
//字符串-工具提示字体权重样式
tooltipFontStyle:“正常”,
//字符串-工具提示标签字体颜色
tooltipFontColor:#fff“,
//字符串-缩放标签的工具提示标题字体声明
字体字体家族:“'Helvetica Neue','Helvetica','Arial',无衬线符号”,
//数字-工具提示标题字体大小(像素)
ToolTiptTitleFontSize:14,
//字符串-工具提示标题字体权重样式
TooliptTitleFontStyle:“粗体”,
//字符串-工具提示标题字体颜色
ToolTiptTitleFontColor:“fff”,
//Number-工具提示文本周围填充的像素宽度
工具提示添加:6,
//Number-工具提示文本周围填充的像素宽度
ToolTipXPAdd:6,
//Number-工具提示上插入符号的大小
ToolTiCaretSize:8,
//Number-工具提示边框的像素半径
工具提示错误:6,
//数字-从点x到工具提示边的像素偏移
工具提示X偏移:10,
//字符串-单个工具提示的模板字符串
ToolTiptTemplate:“:”,
我同意@jbr

我刚刚更新了fiddle中的chart.min.js文件链接,您的现有代码显示了悬停在图表上的工具提示


在fiddle中检查更新的

fiddle不工作>>您添加的chart.js不工作!!请用工作链接更新。。
// Boolean - Determines whether to draw tooltips on the canvas or not
showTooltips: true,

// Array - Array of string names to attach tooltip events
tooltipEvents: ["mousemove", "touchstart", "touchmove"],

// String - Tooltip background colour
tooltipFillColor: "rgba(0,0,0,0.8)",

// String - Tooltip label font declaration for the scale label
tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",

// Number - Tooltip label font size in pixels
tooltipFontSize: 14,

// String - Tooltip font weight style
tooltipFontStyle: "normal",

// String - Tooltip label font colour
tooltipFontColor: "#fff",

// String - Tooltip title font declaration for the scale label
tooltipTitleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",

// Number - Tooltip title font size in pixels
tooltipTitleFontSize: 14,

// String - Tooltip title font weight style
tooltipTitleFontStyle: "bold",

// String - Tooltip title font colour
tooltipTitleFontColor: "#fff",

// Number - pixel width of padding around tooltip text
tooltipYPadding: 6,

// Number - pixel width of padding around tooltip text
tooltipXPadding: 6,

// Number - Size of the caret on the tooltip
tooltipCaretSize: 8,

// Number - Pixel radius of the tooltip border
tooltipCornerRadius: 6,

// Number - Pixel offset from point x to tooltip edge
tooltipXOffset: 10,

// String - Template string for single tooltips
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>",