パッケージの詳細

vue-chartjs

apertureless2.2mMIT5.3.2

Vue.js wrapper for chart.js for creating beautiful charts.

ChartJs, Vue, Visualisation, Wrapper

readme

vue-chartjs

vue-chartjs logo

vue-chartjs is a wrapper for Chart.js in Vue. You can easily create reuseable chart components.

Supports Chart.js v4.

npm version codecov Build Status Package Quality npm Gitter chat license CDNJS version Known Vulnerabilities Donate ko-fi


QuickStart   •   Docs   •   Stack Overflow


Quickstart

Install this library with peer dependencies:

pnpm add vue-chartjs chart.js
# or
yarn add vue-chartjs chart.js
# or
npm i vue-chartjs chart.js

Then, import and use individual components:

<template>
  <Bar :data="data" :options="options" />
</template>

<script lang="ts">
import {
  Chart as ChartJS,
  Title,
  Tooltip,
  Legend,
  BarElement,
  CategoryScale,
  LinearScale
} from 'chart.js'
import { Bar } from 'vue-chartjs'

ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend)

export default {
  name: 'App',
  components: {
    Bar
  },
  data() {
    return {
      data: {
        labels: ['January', 'February', 'March'],
        datasets: [{ data: [40, 20, 12] }]
      },
      options: {
        responsive: true
      }
    }
  }
}
</script>

Need an API to fetch data? Consider Cube, an open-source API for data apps.


supported by Cube

Docs

Build Setup

# install dependencies
pnpm install

# build for production with minification
pnpm build

# run unit tests
pnpm test:unit

# run all tests
pnpm test

Contributing

  1. Fork it ( https://github.com/apertureless/vue-chartjs/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

This software is distributed under MIT license.

Buy Me A Coffee

更新履歴

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

3.5.1 (2020-08-22)

Bug Fixes

3.5.0 (2019-11-01)

Bug Fixes

  • Fix type script definition for addPlugin method (#564) (3065d70)
  • Update chart.js peerDependency (a140f5a)

Features

  • typescript: Improve mixins type definitions (2a6eb7b)
  • typescript: Improve mixins type definitions (#514) (520faca)
  • Add @types/chart.js types in typescript definitions (#536) (22fb8d1)
  • enhance search on the documentation (3542b34)

3.4.2 (2019-03-18)

Bug Fixes

  • Change peerDependency version of chart.js to include older versions (8c780d3)

3.4.1 (2019-03-18)

Bug Fixes

  • reactive-mixins: Add prop type and default value (8762521)
  • Update peerDependencies (5b19efc), closes #489

3.4.0 (2018-08-04)

Features

  • events: Add events to reactiveMixins (#389) (67e8e4d), closes #382
  • typescript: Add basic typescript definitions (184be5c), closes #376
  • ux: Add a wrapper around generateLegend (#390) (fc646d8)
  • ux: Add fake render method with error message (23ff90d), closes #380

3.3.2 (2018-06-18)

Bug Fixes

  • babel: fix decorator error with new version of babel (2fe804b)
  • core: Delete old chart.js instance first (#375) (89a7cac)
  • mixins: Add condition to check if chart instance is present. (1fed8e7)

Features

  • privacy: Remove GA from docs page (d2d944f)

3.3.1 (2018-03-26)

Bug Fixes

  • release: Add exports to index (8341f94)

3.3.0 (2018-03-23)

Bug Fixes

  • readme: Update paypal donate button (bfda218)

Features

  • charts: Export generateChart to create custom charts (50e5644)
  • docs: Update docs with custom chart example (3247a61)

3.1.0 (2018-01-12)

Bug Fixes

  • mixins: Check for chartjs instance before rendering chart (39ff839), closes #288

Features

  • charts: Remove default styling (ac5d4d8)

Change Log

v3.0.1 (2017-11-06)

Full Changelog

Closed issues:

  • [Suggestion]Loose package dependencies #245
  • reactiveData mixin #244
  • Customise individual Axis Labels #243
  • presets es2015 #242
  • Uncaught TypeError: Cannot read property 'transition' of null #241
  • Is it possible to create an callback on the onAnimationComplete option #240
  • When resizing window, chart returns to first loaded state #239
  • Reactively change chart properties #237
  • how to enforce the max value on y axis #236
  • Chart is not rendered when maintainAspectRatio is set to false and chart container is hidden #235
  • How to access Chart.defaults.global #234
  • Blank Chart - no data #233
  • Maxin with multiple chartData #231
  • How to destroy chart before re-rendering? #230
  • chnage gridlines color #228
  • Stacked bar chart? #226
  • Chart crashes when reentering page #223
  • 在图表上左右滑动会出现数据错乱的问题 #222
  • How do I set the scale of the Y axis? #220
  • Upgrading from 2.8.2 to 2.8.3 breaks charts #209
  • How to scale the radius property of each bubble in a vue-chartjs bubble chart #205
  • Last release is causing problems with Firefox #203
  • 🔥 Remove Vue.extend() #201
  • Update to webpack@3 #134

Merged pull requests:

v3.0.0 (2017-10-14)

Full Changelog

Closed issues:

  • Create an image of the chart to download #219
  • How to achieve this effect? #218
  • Some Error #217
  • Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "chartData" #216
  • can't get legendCallback to fire at all #212
  • this demo is not support, is it because version older? #210
  • how to change value without reload?? #208
  • typescript definition? #207
  • 使用动态数据时报错 #204
  • Commit the final dist js files to github #202
  • [Best Practices❓] Usage of Private Data #182
  • 📝 Update docs & examples - SSR with nuxt #172
  • 📝 Update Docs - Section about extending #171
  • Register vue-chartjs as vue-plugin? #168
  • Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders #151

Merged pull requests:

v2.8.7 (2017-09-16)

Full Changelog

Closed issues:

  • 真机和浏览器呈现的效果不一样的问题 #199
  • can not use npm install? #198
  • Reactive Props - Max Call Stack Exceeded Error #197
  • Unmet Peer Dependency #196
  • Is there a way to update options? #195
  • deepmerge #194
  • TypeError: Cannot convert undefined or null to object #193

v2.8.6 (2017-09-12)

Full Changelog

v2.8.5 (2017-09-12)

Full Changelog

Closed issues:

  • Chart error since the addition of deepmerge in build 2.8.4 #192

v2.8.4 (2017-09-08)

Full Changelog

Closed issues:

  • Regression in 2.8.3 #190
  • Why default Chart.js styles are overridden? #189
  • Legend or other options not working in reactiveProps #188
  • Changes to yAxisID property does not re-render chart #177

Merged pull requests:

v2.8.3 (2017-09-06)

Full Changelog

Closed issues:

  • Rounded corner for Bar chart #185
  • Access canvas object from parents #184
  • Issue with DonutChart in Safari #183
  • Responsive Width, Fixed Height #180
  • Entire Lodash Library Is Loaded!! 200kb chunk! #179
  • height changed unexpectedly after re-rendering #178
  • Default height no longer working in 2.8 #176
  • how to get click on point in bar chart? #175
  • clean install of from npm cannot be used in gulp / browserify #174
  • tooltip callbacks possible? #173
  • Computed object won't populate chart #170
  • Error in nextTick: "RangeError: Maximum call stack size exceeded" #169
  • Standalone chartjs build (don't include moment.js) #124

Merged pull requests:

v2.8.2 (2017-08-12)

Full Changelog

Closed issues:

  • UNMET PEER DEPENDENCY #167
  • Base Charts' height: 200% #164

Merged pull requests:

v2.8.1 (2017-08-05)

Full Changelog

Merged pull requests:

v2.8.0 (2017-08-04)

Full Changelog

Closed issues:

  • Update README CDN link #161
  • Options being ignored #160
  • Fails to dynamically change height. #158
  • Chart doesn't load in bootstrap tab #157
  • Add scatter chart to vue-chatjs@legacy #155
  • [Error] Get error when $destroy is started. #149

Merged pull requests:

v1.2.0 (2017-07-25)

Full Changelog

Closed issues:

  • this.$refs doesn't seem to have expected canvas property #156

Merged pull requests:

v2.7.2 (2017-07-22)

Full Changelog

Closed issues:

  • Accessibility - Add unique titles to frames #150
  • update() not refreshing chart #148
  • Custome label y axis #147
  • Access specific points on the canvas and labels for styling #146
  • legendCallback() doesn't render a custom legend #144
  • where can i get the demo sources code? thanks #143
  • Props not works as expected, updating of value doesn't work #138

Merged pull requests:

v2.7.1 (2017-07-05)

Full Changelog

Closed issues:

  • Default backgroundColor needed #142

Merged pull requests:

  • Fix links to images in translated documents #141 (k-rumi)

v2.7.0 (2017-07-04)

Full Changelog

Closed issues:

  • Reactive Data Tutorial #132
  • Using inline plugins #130
  • Scatter Chart #129
  • Generating Chart after clicking submit button #128
  • Ticks not working with reactive props #127
  • Error in callback for watcher "chartData": "TypeError: Cannot read property 'data' of undefined" #126
  • Passing the data from vue to chartjs #125
  • Combination of Bar and Line Chart #123
  • Reactive data example not working #122
  • vue-chartjs height was 0 when i set v-show #120
  • Bar chart, barPercentage in X axis #119
  • update event not firing on data change #118

Merged pull requests:

v2.6.5 (2017-06-10)

Full Changelog

v2.6.4 (2017-06-04)

Full Changelog

Closed issues:

  • Transition leave-active-class not working #117
  • chartOptions reactivity #116
  • Cannot switch off legend #114
  • run error on my mac pro #113
  • Update install instructions in docs #112
  • Typo in docs #111
  • Charts are given a fixed width, even when they are set to be responsive #108
  • Use Reactive Data with \<script\> version of vue-chartjs #107

Merged pull requests:

v2.6.3 (2017-05-14)

Full Changelog

Closed issues:

  • Reactivity of Options #106
  • Do not use built-in or reserved HTML elements as component id: MenuItem #104
  • Is it possible to use with axios? #103
  • How to change momentjs locale for time scale? #101
  • It seems that the reactiveProp couldn't let the chart update itself #99
  • vue-chartjs not working with lodash-webpack-plugin installed #97
  • multi lines with same options #95
  • Zoom And Pan Options in Vue Charts #94

Merged pull requests:

v2.6.2 (2017-04-29)

Full Changelog

Merged pull requests:

v2.6.1 (2017-04-21)

Full Changelog

Closed issues:

  • Not understanding options #93
  • A Gotcha on component creation. #92
  • Error when building: 'This dependency was not found: chartjs' #91
  • Chart does not render inside conditional #90
  • Unable to add to material-vue layout #87

v2.6.0 (2017-04-09)

Full Changelog

Closed issues:

  • how to export to image or pdf #89
  • 🙏🏻 Testing 2.6.0-rc1 #88
  • Adding annotation plugin functionality #86

v2.6.0-rc1 (2017-04-05)

Full Changelog

Closed issues:

  • Overwrite prop #85

Merged pull requests:

  • Update release build to not include externals. #84 (gcoguiec)

v2.5.6 (2017-03-29)

Full Changelog

Closed issues:

  • Can not render two lines at the same time #83
  • Suggestion: Chart not re-rendering on window resize #82
  • How can you change legend label colour? #81
  • Doughnut with text in the middle #80
  • Set chart width without affecting labels #79
  • Loading data from server and displaying #78
  • Why separate .js files in the examples? #77
  • An in-range update of vue is breaking the build 🚨 #76
  • An in-range update of vue-template-compiler is breaking the build 🚨 #75
  • Uncaught TypeError: Cannot read property 'chartId' of undefined #74
  • TypeError: child._updateFromParent is not a function #72
  • Styling componement's surrounding \<div\> #70

v2.5.5 (2017-03-24)

Full Changelog

Closed issues:

  • Access chartjs methods #71
  • Pass Reactive data into Scatterplot #69

Merged pull requests:

  • Removed -s flag from yarn command in docs #73 (mika76)

v2.5.4 (2017-03-19)

Full Changelog

Closed issues:

  • An in-range update of eslint-config-standard is breaking the build 🚨 #68
  • Using data from vuex to populate a line graph #67
  • How to use without babel/webpack? #66
  • The vue-chartjs/src entry point is still creating a new vue instance. #55

Merged pull requests:

v2.5.3 (2017-03-17)

Full Changelog

Closed issues:

  • Cannot modify styling using options #60

v2.5.2 (2017-03-14)

Full Changelog

Closed issues:

  • TypeError: child._updateFromParent is not a function #62
  • child._updateFromParent is not a function #59
  • dependency was not found #58

Merged pull requests:

v2.5.1 (2017-03-11)

Full Changelog

Closed issues:

  • Lines are looking weird. #57
  • Working with objects #48
  • Mixins don't seem to trigger a refresh of the chart #44

v2.5.0 (2017-03-08)

Full Changelog

Closed issues:

  • UglifyJs is not happy with versions after 2.3.8 #54
  • Why "main" in Package.json is "src/index.js" and not "dist/vue-chartjs.js" #53
  • Adding static data and dynamic data at the same time. #52

Merged pull requests:

v2.4.1 (2017-03-04)

Full Changelog

v2.4.0 (2017-03-03)

Full Changelog

Merged pull requests:

v2.3.9 (2017-03-01)

Full Changelog

Closed issues:

  • Add src folder to package.json "files" and make main "src/index.js" #49
  • Unable to refresh #41

Merged pull requests:

v2.3.8 (2017-03-01)

Full Changelog

Closed issues:

  • Colors of dynamically added bars in bar graph are the default color instead of specified color #42

Merged pull requests:

v2.3.6 (2017-02-22)

Full Changelog

Closed issues:

  • Please update1.1.3 chartjs to 2.5.0 #40
  • Vue-chartjs components creating a second Vue runtime #39
  • Since last update bar chart will no longer stack #38
  • barchart 如何横向显示条形图 #37
  • Animation with reactivity #34

Merged pull requests:

v2.3.5 (2017-02-14)

Full Changelog

Closed issues:

  • Destory chart instance in reactiveMixins on render #35
  • Rerendering doughtnut chart not working #33

Merged pull requests:

v2.3.4 (2017-02-11)

Full Changelog

Closed issues:

  • Update Chart.js docs to include link to vue-chartjs #32
  • Compatibility with Vue 2.1.10 #30

v2.3.3 (2017-01-19)

Full Changelog

Closed issues:

  • How to create mixed chart types #29
  • hello a q about reactivity #28
  • chart do not render after build #26

Merged pull requests:

v2.3.2 (2016-12-23)

Full Changelog

Closed issues:

  • Content Security Policy #22

Merged pull requests:

v2.3.1 (2016-12-20)

Full Changelog

Closed issues:

  • Error in rendering #21
  • Issues after using gulp-- production #19

Merged pull requests:

v2.3.0 (2016-12-17)

Full Changelog

Closed issues:

  • Uncaught TypeError: _c is not a function #20

v2.2.1 (2016-12-07)

Full Changelog

Closed issues:

  • Chart height definition inside the component #18
  • Uncaught TypeError: Cannot read property 'draw' of null #15

Merged pull requests:

v2.2.0 (2016-10-24)

Full Changelog

Closed issues:

  • The page is blank? #13
  • question:syntax with vue-loader #12
  • Rerender when data has changed #10

Merged pull requests:

v2.1.1 (2016-10-02)

Full Changelog

v.2.1.0 (2016-09-23)

Full Changelog

v1.1.3 (2016-09-08)

Full Changelog

Closed issues:

  • Passing chart size (width / height) as prop doesnt resize the chart #8
  • Add test #1

Merged pull requests:

1.1.2 (2016-09-07)

Full Changelog

Closed issues:

  • Change name of the render method to ensure compatiblity with Vue 2.0 #4

1.1.1 (2016-08-23)

Full Changelog

1.1.0 (2016-08-21)

Full Changelog

Closed issues:

  • Use Vue.util.mergeOptions to merge default options with user's options #5

Merged pull requests:

1.0.3 (2016-08-20)

Full Changelog

Closed issues:

  • Publish on NPM #2

Merged pull requests:

1.0.2 (2016-07-27)

* This Change Log was automatically generated by github_changelog_generator