154 lines
4.2 KiB
Vue
154 lines
4.2 KiB
Vue
|
<template>
|
||
|
<AppDoc name="ChartDemo" :sources="sources" :dependencies="{ 'chart.js': '3.3.2' }" component="Chart" github="chart/ComboChartDemo.vue" />
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
sources: {
|
||
|
'options-api': {
|
||
|
tabName: 'Options API Source',
|
||
|
content: `
|
||
|
<template>
|
||
|
<div>
|
||
|
<Chart type="bar" :data="chartData" :options="chartOptions" />
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
chartData: {
|
||
|
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
||
|
datasets: [{
|
||
|
type: 'line',
|
||
|
label: 'Dataset 1',
|
||
|
borderColor: '#42A5F5',
|
||
|
borderWidth: 2,
|
||
|
fill: false,
|
||
|
data: [50,25,12,48,56,76,42]
|
||
|
}, {
|
||
|
type: 'bar',
|
||
|
label: 'Dataset 2',
|
||
|
backgroundColor: '#66BB6A',
|
||
|
data: [21,84,24,75,37,65,34],
|
||
|
borderColor: 'white',
|
||
|
borderWidth: 2
|
||
|
}, {
|
||
|
type: 'bar',
|
||
|
label: 'Dataset 3',
|
||
|
backgroundColor: '#FFA726',
|
||
|
data: [41,52,24,74,23,21,32]
|
||
|
}]
|
||
|
},
|
||
|
chartOptions: {
|
||
|
plugins: {
|
||
|
legend: {
|
||
|
labels: {
|
||
|
color: '#495057'
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
scales: {
|
||
|
x: {
|
||
|
ticks: {
|
||
|
color: '#495057'
|
||
|
},
|
||
|
grid: {
|
||
|
color: '#ebedef'
|
||
|
}
|
||
|
},
|
||
|
y: {
|
||
|
ticks: {
|
||
|
color: '#495057'
|
||
|
},
|
||
|
grid: {
|
||
|
color: '#ebedef'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
<\\/script>`
|
||
|
},
|
||
|
'composition-api': {
|
||
|
tabName: 'Composition API Source',
|
||
|
content: `
|
||
|
<template>
|
||
|
<div>
|
||
|
<Chart type="bar" :data="chartData" :options="chartOptions" />
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import { ref } from 'vue';
|
||
|
|
||
|
export default {
|
||
|
setup() {
|
||
|
const chartData = ref({
|
||
|
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
||
|
datasets: [{
|
||
|
type: 'line',
|
||
|
label: 'Dataset 1',
|
||
|
borderColor: '#42A5F5',
|
||
|
borderWidth: 2,
|
||
|
fill: false,
|
||
|
data: [50,25,12,48,56,76,42]
|
||
|
}, {
|
||
|
type: 'bar',
|
||
|
label: 'Dataset 2',
|
||
|
backgroundColor: '#66BB6A',
|
||
|
data: [21,84,24,75,37,65,34],
|
||
|
borderColor: 'white',
|
||
|
borderWidth: 2
|
||
|
}, {
|
||
|
type: 'bar',
|
||
|
label: 'Dataset 3',
|
||
|
backgroundColor: '#FFA726',
|
||
|
data: [41,52,24,74,23,21,32]
|
||
|
}]
|
||
|
});
|
||
|
|
||
|
const chartOptions = ref({
|
||
|
plugins: {
|
||
|
legend: {
|
||
|
labels: {
|
||
|
color: '#495057'
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
scales: {
|
||
|
x: {
|
||
|
ticks: {
|
||
|
color: '#495057'
|
||
|
},
|
||
|
grid: {
|
||
|
color: '#ebedef'
|
||
|
}
|
||
|
},
|
||
|
y: {
|
||
|
ticks: {
|
||
|
color: '#495057'
|
||
|
},
|
||
|
grid: {
|
||
|
color: '#ebedef'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return { chartData, chartOptions }
|
||
|
}
|
||
|
}
|
||
|
<\\/script>`
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
</script>
|