Compare commits

...

13 Commits

Author SHA1 Message Date
Jakub Juszczak
88b16e89d4 💎 Release new version 3.1.1 2018-02-02 15:41:26 +01:00
Jakub
71b50df77a Merge pull request #303 from west-soft-development/refactor-identical-code
Refactor identical code
2018-02-02 15:34:06 +01:00
Nick Nissen
4297872885 Chore: Add dist files 2018-01-31 07:58:44 +01:00
Nick Nissen
96adf9eab3 Refactor: Extract identical code into a function 2018-01-31 07:58:29 +01:00
Jakub
b80b07efd8 docs(readme): Update README.md
Add list for install options
2018-01-30 15:07:41 +01:00
Jakub
84f2934f74 Merge pull request #301 from satoved/patch-1
Missing dot in NPM dependencies in README
2018-01-30 15:06:18 +01:00
Олег
ee5be86e5b Missing dot in NPM dependencies
Either this is a typo or another type of error, the package doesn't work with "chartjs" dependency, it needs "chart.js".
2018-01-30 16:02:39 +02:00
Jakub
3907c5a378 Merge pull request #299 from FrancescoMussi/patch-1
Update README.md
2018-01-29 17:07:49 +01:00
Francesco Mussi
2274cfab22 Update README.md
Added line break
2018-01-29 17:47:13 +02:00
Francesco Mussi
66533c09a9 Update README.md
Just Adding the npm install in the docs.
To avoid people to have to search trough the issues to see for the exact line for npm install.
2018-01-29 15:37:42 +02:00
Jakub
281c847070 Merge pull request #295 from ecaldwell/patch-1
fix typo
2018-01-24 09:35:51 +01:00
Evan Caldwell
e7be94e041 fix typo 2018-01-23 21:48:38 -05:00
Jakub Juszczak
9ef0dedeb0 chore: add dist files 2018-01-12 14:09:16 +01:00
26 changed files with 253 additions and 3713 deletions

View File

@@ -33,7 +33,8 @@ If you're looking for v1 check this [branch](https://github.com/apertureless/vue
## Install
Simply run `yarn add vue-chartjs chart.js`
- **yarn** install: `yarn add vue-chartjs chart.js`
- **npm** install: `npm install vue-chartjs chart.js --save`
Or if you want to use it directly in the browser add
@@ -235,7 +236,7 @@ export default {
## Single File Components
You can create your components in Vues single file components. However it is important that you **do not** have the `<template></template>` included. Because Vue can't merge tempaltes. And the template is included in the mixin. If you leave the template tag in your component, it will overwrite the one which comes from the base chart and you will have a blank screen.
You can create your components in Vues single file components. However it is important that you **do not** have the `<template></template>` included. Because Vue can't merge templates. And the template is included in the mixin. If you leave the template tag in your component, it will overwrite the one which comes from the base chart and you will have a blank screen.
## Available Charts

3092
dist/vue-chartjs.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "vue-chartjs",
"version": "3.1.0",
"version": "3.1.1",
"description": "Vue.js wrapper for chart.js for creating beautiful charts.",
"author": "Jakub Juszczak <jakub@posteo.de>",
"homepage": "http://vue-chartjs.org",

104
src/BaseCharts.js Normal file
View File

@@ -0,0 +1,104 @@
import Chart from 'chart.js'
function generateChart (chartId, chartType) {
return {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: chartId,
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: chartType,
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}
}
export const Bar = generateChart('bar-chart', 'bar')
export const HorizontalBar = generateChart('horizontalbar-chart', 'horizontalBar')
export const Doughnut = generateChart('doughnut-chart', 'doughnut')
export const Line = generateChart('line-chart', 'line')
export const Pie = generateChart('pie-chart', 'pie')
export const PolarArea = generateChart('polar-chart', 'polarArea')
export const Radar = generateChart('radar-chart', 'radar')
export const Bubble = generateChart('bubble-chart', 'bubble')
export const Scatter = generateChart('scatter-chart', 'scatter')
export default {
Bar,
HorizontalBar,
Doughnut,
Line,
Pie,
PolarArea,
Radar,
Bubble,
Scatter
}

View File

@@ -1,78 +0,0 @@
import Chart from 'chart.js'
export default {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'bar-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'bar',
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,80 +0,0 @@
import Chart from 'chart.js'
export default {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'bubble-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'bubble',
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,81 +0,0 @@
import Chart from 'chart.js'
export default {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'doughnut-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'doughnut',
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,80 +0,0 @@
import Chart from 'chart.js'
export default {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'horizontalbar-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'horizontalBar',
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,80 +0,0 @@
import Chart from 'chart.js'
export default {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'line-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'line',
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,80 +0,0 @@
import Chart from 'chart.js'
export default {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'pie-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'pie',
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,80 +0,0 @@
import Chart from 'chart.js'
export default {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'polar-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'polarArea',
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,80 +0,0 @@
import Chart from 'chart.js'
export default {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'radar-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'radar',
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,80 +0,0 @@
import Chart from 'chart.js'
export default {
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'scatter-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default () {
return []
}
}
},
data () {
return {
_chart: null,
_plugins: this.plugins
}
},
methods: {
addPlugin (plugin) {
this.$data._plugins.push(plugin)
},
renderChart (data, options) {
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'scatter',
data: data,
options: options,
plugins: this.$data._plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,4 +1,4 @@
import Bar from '../BaseCharts/Bar'
import { Bar } from '../BaseCharts'
export default {
extends: Bar,

View File

@@ -1,4 +1,4 @@
import Bubble from '../BaseCharts/Bubble'
import { Bubble } from '../BaseCharts'
export default {
extends: Bubble,

View File

@@ -1,4 +1,4 @@
import Doughnut from '../BaseCharts/Doughnut'
import { Doughnut } from '../BaseCharts'
export default {
extends: Doughnut,

View File

@@ -1,4 +1,4 @@
import HorizontalBar from '../BaseCharts/HorizontalBar'
import { HorizontalBar } from '../BaseCharts'
export default {
extends: HorizontalBar,

View File

@@ -1,4 +1,4 @@
import Line from '../BaseCharts/Line'
import { Line } from '../BaseCharts'
export default {
extends: Line,

View File

@@ -1,4 +1,4 @@
import Pie from '../BaseCharts/Pie'
import { Pie } from '../BaseCharts'
export default {
extends: Pie,

View File

@@ -1,4 +1,4 @@
import PolarArea from '../BaseCharts/PolarArea'
import { PolarArea } from '../BaseCharts'
export default {
extends: PolarArea,

View File

@@ -1,4 +1,4 @@
import Radar from '../BaseCharts/Radar'
import { Radar } from '../BaseCharts'
export default {
extends: Radar,

View File

@@ -1,4 +1,4 @@
import Bar from '../BaseCharts/Bar'
import { Bar } from '../BaseCharts'
import reactiveData from '../mixins/reactiveData'
export default {

View File

@@ -1,4 +1,4 @@
import Bar from '../BaseCharts/Bar'
import { Bar } from '../BaseCharts'
import reactiveProp from '../mixins/reactiveProp'
export default {

View File

@@ -1,4 +1,4 @@
import Scatter from '../BaseCharts/Scatter'
import { Scatter } from '../BaseCharts'
export default {
extends: Scatter,

View File

@@ -1,14 +1,16 @@
import Bar from './BaseCharts/Bar'
import HorizontalBar from './BaseCharts/HorizontalBar'
import Doughnut from './BaseCharts/Doughnut'
import Line from './BaseCharts/Line'
import Pie from './BaseCharts/Pie'
import PolarArea from './BaseCharts/PolarArea'
import Radar from './BaseCharts/Radar'
import Bubble from './BaseCharts/Bubble'
import Scatter from './BaseCharts/Scatter'
import mixins from './mixins/index.js'
import npmCfg from '../package.json'
import {
Bar,
HorizontalBar,
Doughnut,
Line,
Pie,
PolarArea,
Radar,
Bubble,
Scatter
} from './BaseCharts'
const VueCharts = {
version: npmCfg.version,