Skip to content

Commit 4915760

Browse files
committed
release: v3.0.0-rc.0
1 parent 4059690 commit 4915760

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coreui/vue-chartjs",
3-
"version": "3.0.0-beta.0",
3+
"version": "3.0.0-rc.0",
44
"description": "Vue component wrapper for Chart.js",
55
"keywords": [
66
"coreui",

src/CChart.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
} from 'vue'
1313

1414
import Chart, { ChartData, ChartOptions, ChartType, Plugin } from 'chart.js/auto'
15-
import * as chartjs from 'chart.js'
1615
import { customTooltips as cuiCustomTooltips } from '@coreui/chartjs'
1716

1817
import assign from 'lodash/assign'
@@ -127,20 +126,28 @@ const CChart = defineComponent({
127126
: merge({}, props.data),
128127
)
129128

129+
const computedOptions = computed(() =>
130+
props.customTooltips
131+
? merge({}, props.options, {
132+
plugins: {
133+
tooltip: {
134+
enabled: false,
135+
mode: 'index',
136+
position: 'nearest',
137+
external: cuiCustomTooltips,
138+
},
139+
},
140+
})
141+
: props.options,
142+
)
143+
130144
const renderChart = () => {
131145
if (!canvasRef.value) return
132146

133-
if (props.customTooltips) {
134-
chartjs.defaults.plugins.tooltip.enabled = false
135-
chartjs.defaults.plugins.tooltip.mode = 'index'
136-
chartjs.defaults.plugins.tooltip.position = 'nearest'
137-
chartjs.defaults.plugins.tooltip.external = cuiCustomTooltips
138-
}
139-
140147
chartRef.value = new Chart(canvasRef.value, {
141148
type: props.type,
142149
data: computedData.value,
143-
options: props.options as ChartOptions,
150+
options: computedOptions.value,
144151
plugins: props.plugins,
145152
})
146153
}

0 commit comments

Comments
 (0)