mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2025-10-29 18:00:20 +00:00
Add support for inline plugins
This commit is contained in:
@@ -56,18 +56,23 @@ export default Vue.extend({
|
|||||||
barPercentage: 0.2
|
barPercentage: 0.2
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
plugins: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
addPlugin (plugin) {
|
||||||
|
this.plugins.push(plugin)
|
||||||
|
},
|
||||||
renderChart (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
this._chart = new Chart(
|
this._chart = new Chart(
|
||||||
this.$refs.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions,
|
||||||
|
plugins: this.plugins
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this._chart.generateLegend()
|
this._chart.generateLegend()
|
||||||
|
|||||||
@@ -56,11 +56,15 @@ export default Vue.extend({
|
|||||||
barPercentage: 0.2
|
barPercentage: 0.2
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
plugins: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
addPlugin (plugin) {
|
||||||
|
this.plugins.push(plugin)
|
||||||
|
},
|
||||||
renderChart (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
@@ -68,7 +72,8 @@ export default Vue.extend({
|
|||||||
this.$refs.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'bubble',
|
type: 'bubble',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions,
|
||||||
|
plugins: this.plugins
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this._chart.generateLegend()
|
this._chart.generateLegend()
|
||||||
|
|||||||
@@ -39,11 +39,15 @@ export default Vue.extend({
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
}
|
},
|
||||||
|
plugins: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
addPlugin (plugin) {
|
||||||
|
this.plugins.push(plugin)
|
||||||
|
},
|
||||||
renderChart (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
@@ -51,7 +55,8 @@ export default Vue.extend({
|
|||||||
this.$refs.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions,
|
||||||
|
plugins: this.plugins
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this._chart.generateLegend()
|
this._chart.generateLegend()
|
||||||
|
|||||||
@@ -56,18 +56,23 @@ export default Vue.extend({
|
|||||||
barPercentage: 0.2
|
barPercentage: 0.2
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
plugins: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
addPlugin (plugin) {
|
||||||
|
this.plugins.push(plugin)
|
||||||
|
},
|
||||||
renderChart (data, options, type) {
|
renderChart (data, options, type) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
this._chart = new Chart(
|
this._chart = new Chart(
|
||||||
this.$refs.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'horizontalBar',
|
type: 'horizontalBar',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions,
|
||||||
|
plugins: this.plugins
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this._chart.generateLegend()
|
this._chart.generateLegend()
|
||||||
|
|||||||
@@ -54,11 +54,15 @@ export default Vue.extend({
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
plugins: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
addPlugin (plugin) {
|
||||||
|
this.plugins.push(plugin)
|
||||||
|
},
|
||||||
renderChart (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
@@ -66,7 +70,8 @@ export default Vue.extend({
|
|||||||
this.$refs.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions,
|
||||||
|
plugins: this.plugins
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this._chart.generateLegend()
|
this._chart.generateLegend()
|
||||||
|
|||||||
@@ -39,11 +39,15 @@ export default Vue.extend({
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
}
|
},
|
||||||
|
plugins: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
addPlugin (plugin) {
|
||||||
|
this.plugins.push(plugin)
|
||||||
|
},
|
||||||
renderChart (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
@@ -51,7 +55,8 @@ export default Vue.extend({
|
|||||||
this.$refs.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'pie',
|
type: 'pie',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions,
|
||||||
|
plugins: this.plugins
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this._chart.generateLegend()
|
this._chart.generateLegend()
|
||||||
|
|||||||
@@ -39,11 +39,15 @@ export default Vue.extend({
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
}
|
},
|
||||||
|
plugins: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
addPlugin (plugin) {
|
||||||
|
this.plugins.push(plugin)
|
||||||
|
},
|
||||||
renderChart (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
@@ -51,7 +55,8 @@ export default Vue.extend({
|
|||||||
this.$refs.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'polarArea',
|
type: 'polarArea',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions,
|
||||||
|
plugins: this.plugins
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this._chart.generateLegend()
|
this._chart.generateLegend()
|
||||||
|
|||||||
@@ -39,11 +39,15 @@ export default Vue.extend({
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
}
|
},
|
||||||
|
plugins: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
addPlugin (plugin) {
|
||||||
|
this.plugins.push(plugin)
|
||||||
|
},
|
||||||
renderChart (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
@@ -51,7 +55,8 @@ export default Vue.extend({
|
|||||||
this.$refs.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'radar',
|
type: 'radar',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions,
|
||||||
|
plugins: this.plugins
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this._chart.generateLegend()
|
this._chart.generateLegend()
|
||||||
|
|||||||
Reference in New Issue
Block a user