Chart ptviewer added

pull/6424/head
tugcekucukoglu 2024-09-17 15:21:10 +03:00
parent 5b358df016
commit 9096aa7500
3 changed files with 96 additions and 12 deletions

View File

@ -1,8 +0,0 @@
<template>
<DocSectionText v-bind="$attrs">
<p>{{ $attrs.description }}</p>
</DocSectionText>
<div class="card">
<img class="w-full" src="https://primefaces.org/cdn/primevue/images/pt/wireframe-placeholder.jpg" />
</div>
</template>

View File

@ -0,0 +1,92 @@
<template>
<DocSectionText v-bind="$attrs" />
<DocPTViewer :docs="ptViewerDoc">
<Chart type="bar" :data="chartData" :options="chartOptions" />
</DocPTViewer>
</template>
<script>
import { getPTOptions } from '@/components/doc/helpers';
import EventBus from '@/layouts/AppEventBus';
export default {
data() {
return {
chartData: null,
chartOptions: null,
ptViewerDoc: [
{
data: getPTOptions('Chart'),
key: 'Chart'
}
]
};
},
beforeUnmount() {
EventBus.off('dark-mode-toggle-complete', this.redrawListener);
EventBus.off('theme-palette-change', this.redrawListener);
},
mounted() {
this.chartData = this.setChartData();
this.chartOptions = this.setChartOptions();
this.redrawListener = () => {
this.chartOptions = this.setChartOptions();
};
EventBus.on('theme-palette-change', this.redrawListener);
EventBus.on('dark-mode-toggle-complete', this.redrawListener);
},
methods: {
setChartData() {
return {
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
datasets: [
{
label: 'Sales',
data: [540, 325, 702, 620],
backgroundColor: ['rgba(249, 115, 22, 0.2)', 'rgba(6, 182, 212, 0.2)', 'rgb(107, 114, 128, 0.2)', 'rgba(139, 92, 246, 0.2)'],
borderColor: ['rgb(249, 115, 22)', 'rgb(6, 182, 212)', 'rgb(107, 114, 128)', 'rgb(139, 92, 246)'],
borderWidth: 1
}
]
};
},
setChartOptions() {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--p-text-color');
const textColorSecondary = documentStyle.getPropertyValue('--p-text-muted-color');
const surfaceBorder = documentStyle.getPropertyValue('--p-content-border-color');
return {
plugins: {
legend: {
labels: {
color: textColor
}
}
},
scales: {
x: {
ticks: {
color: textColorSecondary
},
grid: {
color: surfaceBorder
}
},
y: {
beginAtZero: true,
ticks: {
color: textColorSecondary
},
grid: {
color: surfaceBorder
}
}
}
};
}
}
};
</script>

View File

@ -11,16 +11,16 @@
<script> <script>
import DocApiTable from '@/components/doc/DocApiTable.vue'; import DocApiTable from '@/components/doc/DocApiTable.vue';
import { getPTOptions } from '@/components/doc/helpers'; import { getPTOptions } from '@/components/doc/helpers';
import PTImage from './PTImage.vue'; import PTViewer from './PTViewer.vue';
export default { export default {
data() { data() {
return { return {
docs: [ docs: [
{ {
id: 'pt.image', id: 'pt.viewer',
label: 'Wireframe', label: 'Viewer',
component: PTImage component: PTViewer
}, },
{ {
id: 'pt.doc.chart', id: 'pt.doc.chart',