chartjs显示数值标签插件:chartjs-plugin-datalabels
Getting Started
#Installation
#npm
npm install chartjs-plugin-datalabels --save
This plugin can also be installed using Bower.
#CDN
By default, https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels
returns the latest (minified) version, however it's highly recommended to always specify a version in order to avoid breaking changes. This can be achieved by appending @{version}
to the url:
https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@1.1.2 // exact version
https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@1 // latest 1.x.x
Read more about jsDeliver versioning on their website.
#Download
You can download the latest version of chartjs-plugin-datalabels
from the GitHub releases:
chartjs-plugin-datalabels.js
(recommended for development)chartjs-plugin-datalabels.min.js
(recommended for production)chartjs-plugin-datalabels.zip
(contains.js
and.min.js
versions + samples)
#Integration
#HTML
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.7.3/dist/Chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.7.0"></script>
IMPORTANT
chartjs-plugin-datalabel
must be loaded after the Chart.js library!
Once imported, the plugin is available under the global property ChartDataLabels
. This is useful to register/unregister the plugin afterward.
#Module
import Chart from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';
#Registration
This plugin registers itself globally, meaning that once imported, all charts will display labels. In case you want it enabled only for a few charts, you first need to unregister it globally:
// NOTE: when imported as a <script> tag, use the global property 'ChartDataLabels'
Chart.plugins.unregister(ChartDataLabels);
Then, you can enabled the plugin only for specific charts:
var chart = new Chart(ctx, {
plugins: [ChartDataLabels],
options: {
// ...
}
})
See also Chart.js › Using plugins.
DEPRECATION
From version 1.x, this plugin will no longer be registered automatically (see #42 for details).
#Configuration
The plugin options can be changed at 3 different levels and are evaluated with the following priority:
- per dataset:
dataset.datalabels.*
- per chart:
options.plugins.datalabels.*
- or globally:
Chart.defaults.global.plugins.datalabels.*
For example:
// Change default options for ALL charts
Chart.helpers.merge(Chart.defaults.global.plugins.datalabels, {
color: '#FE777B'
});
var chart = new Chart(ctx, {
options: {
plugins: {
// Change options for ALL labels of THIS CHART
datalabels: {
color: '#36A2EB'
}
}
},
data: {
datasets: [{
// Change options only for labels of THIS DATASET
datalabels: {
color: '#FFCE56'
}
}]
}
});
chartjs显示数值标签插件:chartjs-plugin-datalabels的更多相关文章
- jQuery滑动选取数值范围插件
HTML 首先载入jQuery库文件以及jRange相关的css文件:jquery.range.css和插件:jquery.range.js <script src="jquery.j ...
- Highmaps网页图表教程之绘图区显示标签显示数据标签定位
Highmaps网页图表教程之绘图区显示标签显示数据标签定位 Highmaps数据标签定位 由于数据标签是和节点一一对应,所以数据标签是依据节点位置进行定位的.本节详细讲解如何对数据标签进行定位. H ...
- Source Insight 3.X 标签插件v1.0发布
Source Insight可以说是一款程序员必备的开发/阅读源码工具,美中不足的是SI没有标签栏,多个源码之间切换很不方便,于是我就乘闲暇之余写了该作品sihook:标签插件;不过严格意义上来说si ...
- jQuery 浮动标签插件,帮助你提升表单用户体验
浮动标签模式(Float Label Pattern)是最新流行的一种表单输入域的内容提示方式,当用户在输入框输入内容的时候,原先占位符的内容向上移动,显示在输入的内容的上面.这里推荐的这款 jQue ...
- Source Insight 多标签插件
Source Insight不仅仅是一个强大的程序编辑器,它还能显示reference trees,class inheritance diagrams和call trees.Source Insig ...
- 5个最顶级jQuery图表类库插件-Charting plugin
转载: http://www.cnblogs.com/chu888chu888/archive/2012/12/22/2828962.html 作者:Leonel Hilario翻译:Terry li ...
- highchairts柱状图显示数值并且带单位
$(target).highcharts({ chart: { type: 'bar' }, colors: [ "#1ab394" ], title: { text: title ...
- GBin1插件推荐之马可波罗(Marco Polo),jQuery的自动补齐插件 - Autocomplete Plugin
让我们Google一下"jQuery autocomplete plugin"(jquery自动补齐插件).在过去的4年中,我已经Google了很多次这个组合了.然而结果并没有变化 ...
- [1] 插件架构(PLUG-IN)
网上的一种比较好对插件的定义是:插件(Plug-in,又称addin.add-in.addon或add-on,又译外挂)也称为扩展,是一种遵循一定规范的应用程序接口编写出来的程序,主要是用来扩展软件功 ...
随机推荐
- Gurobi建模遇到的坑
1.quicksum好像不支持嵌套 最好还是尽可能多的使用一些中间变量来表达. 另外,quicksum()返回的是表达式而不是var,像addGenConstrMax(resvar, [var, va ...
- 查看memcache版本
window: cmd中用telnet 127.0.0.1 11211这样的命令连接上memcache,然后直接输入stats就可以得到memcache服务器的版本. 注意:memcache的默认端口 ...
- error:Cannot pull with rebase
原文文链接:https://blog.csdn.net/u012385190/article/details/70670213git 执行git pull –rebase报错误如下: error: C ...
- Java FTP客户端开源类库 edtFTPj
edtFTPj/Free是免费的流行的Java FTP库,全球公司依靠edtFTPj /Free 为它们的Java应用程序添加FTP客户端功能. (收费的支持SFTP.FTPS的edtFTPj/PRO ...
- Java NIO学习笔记八 DatagramChannel
Java NIO DatagramChannel Java NIO DatagramChannel是可以发送和接收UDP数据包的通道.由于UDP是一种无连接网络协议,因此您不能默认读取和写入Datag ...
- 针对thinkphp 5框架存储过程bug而重写的存储过程的扩展类
近期用tp5框架调取存储过程发现有bug,借鉴了一些官方的函数.以及找了个mysqli的类把存储过程重新写了个扩展类,下面两个类直接放置项目extend目录的stored(这个文件夹名称请按个人习惯命 ...
- 客户端热更新框架之UI热更框架设计(下)
上一篇笔者介绍了关于什么是热更新,为什么需要热更新的技术文章.本篇就专门针对UI框架的热更新功能实现部分展开讨论,讨论的重点是热更新如何与UI框架进行结合? 现在笔者把设计“UI热更新框架”的整体设计 ...
- 合并多个tensorflow模型的办法
直接上代码: import tensorflow as tf from tensorflow.python.tools import freeze_graph from tensorflow.pyth ...
- Git速成学习第六课:Bug分支
Git速成学习笔记整理于廖雪峰老师的官网网站:https://www.liaoxuefeng.com/ 当你接到一个修复代码为101的任务的时候,很自然的你想创建一个分支issue-101来修复它,但 ...
- Python报错:TypeError: data type not understood
K-Means聚类算法 def randCent(dataSet, k): m, n = dataSet.shape # numpy中的shape函数的返回一个矩阵的规模,即是几行几列 centrod ...