From f79712eef3ad518d8cb1b549780f6cf441c56117 Mon Sep 17 00:00:00 2001
From: pipipi-pikachu <1171051090@qq.com>
Date: Sat, 16 Jan 2021 15:05:57 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9F=BA=E7=A1=80=E7=9A=84?=
=?UTF-8?q?=E5=9B=BE=E8=A1=A8=E5=85=83=E7=B4=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Chart.vue | 108 ++++++++++++++++++
src/configs/element.ts | 16 ++-
src/mocks/index.ts | 38 ++++++
src/types/slides.ts | 19 ++-
.../Editor/Canvas/hooks/useScaleElement.ts | 3 +-
src/views/Editor/Canvas/index.vue | 4 +-
.../Editor/Toolbar/ElementPositionPanel.vue | 11 +-
src/views/Screen/ScreenElement.vue | 4 +-
src/views/Screen/index.vue | 4 +-
.../element/ChartElement/BaseChartElement.vue | 18 ++-
.../ChartElement/ScreenChartElement.vue | 58 ++++++++++
.../components/element/ChartElement/index.vue | 10 +-
12 files changed, 280 insertions(+), 13 deletions(-)
create mode 100644 src/components/Chart.vue
create mode 100644 src/views/components/element/ChartElement/ScreenChartElement.vue
diff --git a/src/components/Chart.vue b/src/components/Chart.vue
new file mode 100644
index 0000000..6fbb044
--- /dev/null
+++ b/src/components/Chart.vue
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/configs/element.ts b/src/configs/element.ts
index 5d46594..bf3c650 100644
--- a/src/configs/element.ts
+++ b/src/configs/element.ts
@@ -49,6 +49,20 @@ export const DEFAULT_TABLE = {
outline: {
width: 2,
style: 'solid',
- color: DEFAULT_COLOR
+ color: DEFAULT_COLOR,
},
+}
+
+export const DEFAULT_FORMULA = {
+ left: 0,
+ top: 0,
+}
+
+export const MIN_SIZE = {
+ text: 20,
+ image: 20,
+ shape: 15,
+ chart: 200,
+ table: 20,
+ formula: 20,
}
\ No newline at end of file
diff --git a/src/mocks/index.ts b/src/mocks/index.ts
index 6274173..09f98ca 100644
--- a/src/mocks/index.ts
+++ b/src/mocks/index.ts
@@ -1,6 +1,44 @@
import { Slide } from '@/types/slides'
export const slides: Slide[] = [
+ {
+ id: 'xsxa123',
+ elements: [
+ {
+ id: 'sdasaxsxs',
+ type: 'chart',
+ left: 100,
+ top: 100,
+ width: 400,
+ height: 400,
+ chartType: 'pie',
+ data: {
+ labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
+ series: [
+ [5, 2, 4, 2, 10],
+ ],
+ },
+ options: {
+ donut: true,
+ },
+ },
+ {
+ id: 'sdasaxs',
+ type: 'chart',
+ left: 600,
+ top: 100,
+ width: 300,
+ height: 300,
+ chartType: 'line',
+ data: {
+ labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
+ series: [
+ [5, 2, 4, 2, 10],
+ ],
+ },
+ },
+ ],
+ },
{
id: 'xxx1',
background: {
diff --git a/src/types/slides.ts b/src/types/slides.ts
index 40434e5..884f9dd 100644
--- a/src/types/slides.ts
+++ b/src/types/slides.ts
@@ -1,3 +1,5 @@
+import { IBarChartOptions, ILineChartOptions, IPieChartOptions } from 'chartist'
+
export interface PPTElementShadow {
h: number;
v: number;
@@ -105,7 +107,7 @@ export interface PPTLineElement {
shadow?: PPTElementShadow;
}
-export type ChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'polarArea' | 'radar'
+export type ChartType = 'bar' | 'line' | 'pie'
export interface ChartData {
labels: string[];
series: number[][];
@@ -121,6 +123,7 @@ export interface PPTChartElement {
height: number;
chartType: ChartType;
data: ChartData;
+ options?: ILineChartOptions & IBarChartOptions & IPieChartOptions;
outline?: PPTElementOutline;
}
@@ -145,8 +148,20 @@ export interface PPTTableElement {
colSizes: number[];
data: TableElementCell[][];
}
+export interface PPTFormulaElement {
+ type: 'formula';
+ id: string;
+ left: number;
+ top: number;
+ lock?: boolean;
+ groupId?: string;
+ width: number;
+ height: number;
+ latex: string;
+ color?: string;
+}
-export type PPTElement = PPTTextElement | PPTImageElement | PPTShapeElement | PPTLineElement | PPTChartElement | PPTTableElement
+export type PPTElement = PPTTextElement | PPTImageElement | PPTShapeElement | PPTLineElement | PPTChartElement | PPTTableElement | PPTFormulaElement
export interface PPTAnimation {
elId: string;
diff --git a/src/views/Editor/Canvas/hooks/useScaleElement.ts b/src/views/Editor/Canvas/hooks/useScaleElement.ts
index 71a1c3a..e3d5772 100644
--- a/src/views/Editor/Canvas/hooks/useScaleElement.ts
+++ b/src/views/Editor/Canvas/hooks/useScaleElement.ts
@@ -4,6 +4,7 @@ import { State, MutationTypes } from '@/store'
import { ElementTypes, PPTElement, PPTImageElement, PPTLineElement, PPTShapeElement } from '@/types/slides'
import { OperateResizeHandlers, AlignmentLineProps, MultiSelectRange } from '@/types/edit'
import { VIEWPORT_SIZE, VIEWPORT_ASPECT_RATIO } from '@/configs/canvas'
+import { MIN_SIZE } from '@/configs/element'
import { AlignLine, uniqAlignLines } from '@/utils/element'
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
@@ -111,7 +112,7 @@ export default (
const startPageX = e.pageX
const startPageY = e.pageY
- const minSize = 15
+ const minSize = MIN_SIZE[element.type] || 20
const getSizeWithinRange = (size: number) => size < minSize ? minSize : size
let points: ReturnType
diff --git a/src/views/Editor/Canvas/index.vue b/src/views/Editor/Canvas/index.vue
index a5b49da..7f4a5ee 100644
--- a/src/views/Editor/Canvas/index.vue
+++ b/src/views/Editor/Canvas/index.vue
@@ -75,7 +75,7 @@
@@ -46,5 +55,10 @@ export default defineComponent({
.element-content {
width: 100%;
height: 100%;
+ opacity: .5;
+ background-color: rgba($color: #000, $alpha: .05);
+ display: flex;
+ justify-content: center;
+ align-items: center;
}
diff --git a/src/views/components/element/ChartElement/ScreenChartElement.vue b/src/views/components/element/ChartElement/ScreenChartElement.vue
new file mode 100644
index 0000000..b3a8df2
--- /dev/null
+++ b/src/views/components/element/ChartElement/ScreenChartElement.vue
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
diff --git a/src/views/components/element/ChartElement/index.vue b/src/views/components/element/ChartElement/index.vue
index 85ed52e..01c81da 100644
--- a/src/views/components/element/ChartElement/index.vue
+++ b/src/views/components/element/ChartElement/index.vue
@@ -18,7 +18,13 @@
:height="elementInfo.height"
:outline="elementInfo.outline"
/>
- Chart
+
@@ -29,11 +35,13 @@ import { PPTChartElement } from '@/types/slides'
import { ContextmenuItem } from '@/components/Contextmenu/types'
import ElementOutline from '@/views/components/element/ElementOutline.vue'
+import Chart from '@/components/Chart.vue'
export default defineComponent({
name: 'editable-element-chart',
components: {
ElementOutline,
+ Chart,
},
props: {
elementInfo: {