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的更多相关文章

  1. jQuery滑动选取数值范围插件

    HTML 首先载入jQuery库文件以及jRange相关的css文件:jquery.range.css和插件:jquery.range.js <script src="jquery.j ...

  2. Highmaps网页图表教程之绘图区显示标签显示数据标签定位

    Highmaps网页图表教程之绘图区显示标签显示数据标签定位 Highmaps数据标签定位 由于数据标签是和节点一一对应,所以数据标签是依据节点位置进行定位的.本节详细讲解如何对数据标签进行定位. H ...

  3. Source Insight 3.X 标签插件v1.0发布

    Source Insight可以说是一款程序员必备的开发/阅读源码工具,美中不足的是SI没有标签栏,多个源码之间切换很不方便,于是我就乘闲暇之余写了该作品sihook:标签插件;不过严格意义上来说si ...

  4. jQuery 浮动标签插件,帮助你提升表单用户体验

    浮动标签模式(Float Label Pattern)是最新流行的一种表单输入域的内容提示方式,当用户在输入框输入内容的时候,原先占位符的内容向上移动,显示在输入的内容的上面.这里推荐的这款 jQue ...

  5. Source Insight 多标签插件

    Source Insight不仅仅是一个强大的程序编辑器,它还能显示reference trees,class inheritance diagrams和call trees.Source Insig ...

  6. 5个最顶级jQuery图表类库插件-Charting plugin

    转载: http://www.cnblogs.com/chu888chu888/archive/2012/12/22/2828962.html 作者:Leonel Hilario翻译:Terry li ...

  7. highchairts柱状图显示数值并且带单位

    $(target).highcharts({ chart: { type: 'bar' }, colors: [ "#1ab394" ], title: { text: title ...

  8. GBin1插件推荐之马可波罗(Marco Polo),jQuery的自动补齐插件 - Autocomplete Plugin

    让我们Google一下"jQuery autocomplete plugin"(jquery自动补齐插件).在过去的4年中,我已经Google了很多次这个组合了.然而结果并没有变化 ...

  9. [1] 插件架构(PLUG-IN)

    网上的一种比较好对插件的定义是:插件(Plug-in,又称addin.add-in.addon或add-on,又译外挂)也称为扩展,是一种遵循一定规范的应用程序接口编写出来的程序,主要是用来扩展软件功 ...

随机推荐

  1. StringBuffer中delete与setLength清空字符串效率比较

    问题: StringBuffer中有delete.setLength两个方法可以快速清空字符数组.哪个效率高呢? 结论:从清空字符串角度看,两者效率都很高,比较来看,setLength效率更高. 分析 ...

  2. Flume-自定义 Interceptor(拦截器)

    使用 Flume 采集服务器本地日志,需要按照日志类型的不同,将不同种类的日志发往不同的分析系统. 在实际的开发中,一台服务器产生的日志类型可能有很多种,不同类型的日志可能需要发送到不同的分析系统. ...

  3. mysql 远程登陆

    1.查询mysql是否启动 netstat  -lnp|grep   3306 ps -df |grep  mysqld 2.通过TCPIP的方式测试连接 mysql -uqingjiao -padm ...

  4. linux调用库的方式

    linux调用库的方式有三种:1.静态链接库2.动态链接库3.动态加载库 其中1,2都是在编程时直接调用,在链接时加参数-l进行链接,运行时自动调用第三种需要在编程时使用dlopen等函数来获取库里面 ...

  5. linux 中gcc的·安装、编译过程

    一.安装gcc编译器 通过命令gcc -v查看当前的GCC版本 [root@localhost /]# gcc -v Reading specs from /usr/i386-glibc-2.1-li ...

  6. centos 7 gitlab安装服务器

    详情见 https://blog.csdn.net/duyusean/article/details/80011540

  7. CockroachDB学习笔记——[译]在CockroachDB中如何让在线模式更改成为可能

    原文链接:https://www.cockroachlabs.com/blog/how-online-schema-changes-are-possible-in-cockroachdb/ 原作者: ...

  8. 【ABAP系列】SAP ABAP下载带密码的Excel文件

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP下载带密码的Ex ...

  9. Java工程师学习指南第2部分:JavaWeb技术世界

    本文整理了微信公众号[Java技术江湖]发表和转载过的Java Web优质文章,想看到更多Java技术文章,就赶紧关注吧. IDEA中的Maven实战 老师,免费版的IDEA为啥不能使用Tomcat? ...

  10. javaweb期末项目-stage2-项目创建、配置、接口设计和功能实现(含核心源码)

    项目的创建.配置.接口设计和功能实现(含核心代码).rar--下载 说明:解压密码为袁老师的全名拼音(全小写) 相关链接: 项目结构:https://www.cnblogs.com/formyfish ...