mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
添加插入图表相关
This commit is contained in:
parent
f79712eef3
commit
a25a736af7
@ -31,15 +31,15 @@ export const DEFAULT_LINE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_CHART = {
|
export const DEFAULT_CHART = {
|
||||||
left: 0,
|
left: 300,
|
||||||
top: 0,
|
top: 81.25,
|
||||||
width: 500,
|
width: 400,
|
||||||
height: 500,
|
height: 400,
|
||||||
data: {
|
data: {
|
||||||
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
|
labels: ['类别1', '类别2', '类别3', '类别4', '类别5'],
|
||||||
series: [
|
series: [
|
||||||
[12, 19, 3, 5, 2, 18],
|
[12, 19, 5, 2, 18],
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
59
src/views/Editor/CanvasTool/ChartPool.vue
Normal file
59
src/views/Editor/CanvasTool/ChartPool.vue
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<template>
|
||||||
|
<ul class="chart-pool">
|
||||||
|
<li class="chart-item" v-for="(chart, index) in chartList" :key="index">
|
||||||
|
<div class="chart-content" @click="selectChart(chart)">
|
||||||
|
<IconChartLine size="24" v-if="chart === 'line'" />
|
||||||
|
<IconChartHistogram size="24" v-else-if="chart === 'bar'" />
|
||||||
|
<IconChartProportion size="24" v-else-if="chart === 'pie'" />
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent } from 'vue'
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'chart-pool',
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const chartList = ['bar', 'line', 'pie']
|
||||||
|
|
||||||
|
const selectChart = (chart: string) => {
|
||||||
|
emit('select', chart)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
chartList,
|
||||||
|
selectChart,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.chart-pool {
|
||||||
|
width: 120px;
|
||||||
|
margin-bottom: -5px;
|
||||||
|
|
||||||
|
@include grid-layout-wrapper();
|
||||||
|
}
|
||||||
|
.chart-item {
|
||||||
|
@include grid-layout-item(3, 32%);
|
||||||
|
|
||||||
|
height: 0;
|
||||||
|
padding-bottom: 32%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.chart-content {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
@ -34,12 +34,17 @@
|
|||||||
<IconConnection class="handler-item" />
|
<IconConnection class="handler-item" />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
<Popover trigger="click" v-model:visible="chartPoolVisible">
|
||||||
|
<template #content>
|
||||||
|
<ChartPool @select="chart => { createChartElement(chart); chartPoolVisible = false }" />
|
||||||
|
</template>
|
||||||
|
<Tooltip :mouseLeaveDelay="0" :mouseEnterDelay="0.5" title="插入图表">
|
||||||
|
<IconChartProportion class="handler-item" />
|
||||||
|
</Tooltip>
|
||||||
|
</Popover>
|
||||||
<Tooltip :mouseLeaveDelay="0" :mouseEnterDelay="0.5" title="插入表格">
|
<Tooltip :mouseLeaveDelay="0" :mouseEnterDelay="0.5" title="插入表格">
|
||||||
<IconInsertTable class="handler-item" />
|
<IconInsertTable class="handler-item" />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :mouseLeaveDelay="0" :mouseEnterDelay="0.5" title="插入图表">
|
|
||||||
<IconChartProportion class="handler-item" />
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip :mouseLeaveDelay="0" :mouseEnterDelay="0.5" title="插入公式">
|
<Tooltip :mouseLeaveDelay="0" :mouseEnterDelay="0.5" title="插入公式">
|
||||||
<IconFormula class="handler-item" />
|
<IconFormula class="handler-item" />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@ -66,12 +71,14 @@ import useCreateElement from '@/hooks/useCreateElement'
|
|||||||
|
|
||||||
import ShapePool from './ShapePool.vue'
|
import ShapePool from './ShapePool.vue'
|
||||||
import LinePool from './LinePool.vue'
|
import LinePool from './LinePool.vue'
|
||||||
|
import ChartPool from './ChartPool.vue'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'canvas-tool',
|
name: 'canvas-tool',
|
||||||
components: {
|
components: {
|
||||||
ShapePool,
|
ShapePool,
|
||||||
LinePool,
|
LinePool,
|
||||||
|
ChartPool,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const store = useStore<State>()
|
const store = useStore<State>()
|
||||||
@ -84,7 +91,7 @@ export default defineComponent({
|
|||||||
const { scaleCanvas } = useScaleCanvas()
|
const { scaleCanvas } = useScaleCanvas()
|
||||||
const { redo, undo } = useHistorySnapshot()
|
const { redo, undo } = useHistorySnapshot()
|
||||||
|
|
||||||
const { createImageElement } = useCreateElement()
|
const { createImageElement, createChartElement } = useCreateElement()
|
||||||
|
|
||||||
const insertImageElement = (files: File[]) => {
|
const insertImageElement = (files: File[]) => {
|
||||||
const imageFile = files[0]
|
const imageFile = files[0]
|
||||||
@ -94,6 +101,8 @@ export default defineComponent({
|
|||||||
|
|
||||||
const shapePoolVisible = ref(false)
|
const shapePoolVisible = ref(false)
|
||||||
const linePoolVisible = ref(false)
|
const linePoolVisible = ref(false)
|
||||||
|
const chartPoolVisible = ref(false)
|
||||||
|
|
||||||
const drawText = () => {
|
const drawText = () => {
|
||||||
store.commit(MutationTypes.SET_CREATING_ELEMENT, {
|
store.commit(MutationTypes.SET_CREATING_ELEMENT, {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
@ -125,9 +134,11 @@ export default defineComponent({
|
|||||||
insertImageElement,
|
insertImageElement,
|
||||||
shapePoolVisible,
|
shapePoolVisible,
|
||||||
linePoolVisible,
|
linePoolVisible,
|
||||||
|
chartPoolVisible,
|
||||||
drawText,
|
drawText,
|
||||||
drawShape,
|
drawShape,
|
||||||
drawLine,
|
drawLine,
|
||||||
|
createChartElement,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user