Commit c445ce722852d64bfa9397807232dc6838b4d7f2

Authored by fengwotao
1 parent e0ae3bd2

feat(packages/external): 重写部分柱状图和部分折线图,新增开启关闭动画效果和全屏效果

... ... @@ -5,11 +5,10 @@ import cloneDeep from 'lodash/cloneDeep'
5 5 import dataJson from './data.json'
6 6
7 7 export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
8   -
9 8 // 其它配置项比如新增(动画)
10 9 const otherConfig = {
11 10 // 轮播动画
12   - isCarousel: false,
  11 + isCarousel: false
13 12 }
14 13 export const seriesItem = {
15 14 type: 'bar',
... ... @@ -35,7 +34,7 @@ export const option = {
35 34 type: 'shadow'
36 35 }
37 36 },
38   -xAxis: {
  37 + xAxis: {
39 38 show: true,
40 39 type: 'category'
41 40 },
... ...
... ... @@ -11,7 +11,8 @@
11 11 autoresize
12 12 @mouseover="handleHighlight"
13 13 @mouseout="handleDownplay"
14   - ></v-chart>
  14 + >
  15 + </v-chart>
15 16 </template>
16 17
17 18 <script setup lang="ts">
... ... @@ -30,6 +31,7 @@ import { isPreview } from '@/utils'
30 31 import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
31 32 import isObject from 'lodash/isObject'
32 33 import dataJson from './data.json'
  34 +import { isFullScreen } from '../../utls/isFullScreen'
33 35
34 36 const props = defineProps({
35 37 themeSetting: {
... ... @@ -56,6 +58,28 @@ const option = computed(() => {
56 58 return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
57 59 })
58 60
  61 +const toolBoxOption = {
  62 + show: true,
  63 + right: 20,
  64 + feature: {
  65 + myFullButton: {
  66 + show: true,
  67 + title: '全屏查看',
  68 + icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z',
  69 + onclick: () => {
  70 + const getEchartDom = vChartRef.value?.getDom()
  71 + const domName = document.getElementById(getEchartDom.id) as any
  72 + const htmlName = document.querySelector('html') as any
  73 + isFullScreen(domName, htmlName)
  74 + }
  75 + }
  76 + }
  77 +}
  78 +props.chartConfig.option = {
  79 + ...props.chartConfig.option,
  80 + ...{ toolbox: toolBoxOption }
  81 +}
  82 +
59 83 // dataset 无法变更条数的补丁
60 84 watch(
61 85 () => props.chartConfig.option.dataset,
... ... @@ -161,7 +185,6 @@ const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (n
161 185
162 186 onMounted(() => {
163 187 seriesDataMaxLength = dataJson.source.length
164   - console.log(props.chartConfig.option.isCarousel)
165 188 if (props.chartConfig.option.isCarousel) {
166 189 addPieInterval(undefined, true)
167 190 }
... ...
... ... @@ -30,6 +30,7 @@ import { isPreview } from '@/utils'
30 30 import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
31 31 import isObject from 'lodash/isObject'
32 32 import dataJson from './data.json'
  33 +import { isFullScreen } from '../../utls/isFullScreen'
33 34
34 35 const props = defineProps({
35 36 themeSetting: {
... ... @@ -56,6 +57,28 @@ const option = computed(() => {
56 57 return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
57 58 })
58 59
  60 +const toolBoxOption = {
  61 + show: true,
  62 + right: 20,
  63 + feature: {
  64 + myFullButton: {
  65 + show: true,
  66 + title: '全屏查看',
  67 + icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z',
  68 + onclick: () => {
  69 + const getEchartDom = vChartRef.value?.getDom()
  70 + const domName = document.getElementById(getEchartDom.id) as any
  71 + const htmlName = document.querySelector('html') as any
  72 + isFullScreen(domName, htmlName)
  73 + }
  74 + }
  75 + }
  76 +}
  77 +props.chartConfig.option = {
  78 + ...props.chartConfig.option,
  79 + ...{ toolbox: toolBoxOption }
  80 +}
  81 +
59 82 // dataset 无法变更条数的补丁
60 83 watch(
61 84 () => props.chartConfig.option.dataset,
... ...
1 1 <template>
2   - <v-chart
3   - ref="vChartRef"
4   - :init-options="initOptions"
5   - :theme="themeColor"
6   - :option="option.value"
7   - :manual-update="isPreview()"
8   - autoresize
9   - @mouseover="handleHighlight"
10   - @mouseout="handleDownplay"
  2 + <v-chart
  3 + ref="vChartRef"
  4 + :init-options="initOptions"
  5 + :theme="themeColor"
  6 + :option="option.value"
  7 + :manual-update="isPreview()"
  8 + autoresize
  9 + @mouseover="handleHighlight"
  10 + @mouseout="handleDownplay"
11 11 ></v-chart>
12 12 </template>
13 13
14 14 <script setup lang="ts">
15   -import { reactive, watch, PropType,onMounted } from 'vue'
  15 +import { reactive, watch, PropType, onMounted } from 'vue'
16 16 import VChart from 'vue-echarts'
17 17 import { useCanvasInitOptions } from '@/hooks/useCanvasInitOptions.hook'
18 18 import { use, graphic } from 'echarts/core'
... ... @@ -24,8 +24,9 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
24 24 import { chartColorsSearch, defaultTheme } from '@/settings/chartThemes/index'
25 25 import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
26 26 import { useChartDataFetch } from '@/hooks'
27   -import { isPreview, colorGradientCustomMerge} from '@/utils'
  27 +import { isPreview, colorGradientCustomMerge } from '@/utils'
28 28 import dataJson from './data.json'
  29 +import { isFullScreen } from '../../utls/isFullScreen'
29 30
30 31 const props = defineProps({
31 32 themeSetting: {
... ... @@ -50,6 +51,27 @@ const chartEditStore = useChartEditStore()
50 51 const option = reactive({
51 52 value: {}
52 53 })
  54 +const toolBoxOption = {
  55 + show: true,
  56 + right: 20,
  57 + feature: {
  58 + myFullButton: {
  59 + show: true,
  60 + title: '全屏查看',
  61 + icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z',
  62 + onclick: () => {
  63 + const getEchartDom = vChartRef.value?.getDom()
  64 + const domName = document.getElementById(getEchartDom.id) as any
  65 + const htmlName = document.querySelector('html') as any
  66 + isFullScreen(domName, htmlName)
  67 + }
  68 + }
  69 + }
  70 +}
  71 +props.chartConfig.option = {
  72 + ...props.chartConfig.option,
  73 + ...{ toolbox: toolBoxOption }
  74 +}
53 75
54 76 // 渐变色处理
55 77 watch(
... ...
  1 +export const isFullScreen = (domName: any, htmlName: any) => {
  2 + const isFullScreen = document.fullscreenElement
  3 + const currentDatkTheme = htmlName.getAttribute('data-theme')
  4 +
  5 + if (isFullScreen) {
  6 + console.log('退出全屏')
  7 + if (document.exitFullscreen) {
  8 + document.exitFullscreen()
  9 + domName.style.background = ''
  10 + } else if (document.msExitFullscreen) {
  11 + document.msExitFullscreen()
  12 + domName.style.background = ''
  13 + } else if (document.mozCancelFullScreen) {
  14 + document.mozCancelFullScreen()
  15 + domName.style.background = ''
  16 + } else if (document.webkitCancelFullScreen) {
  17 + document.webkitCancelFullScreen()
  18 + domName.style.background = ''
  19 + }
  20 + } else {
  21 + console.log('进入全屏')
  22 + if (domName.requestFullscreen) {
  23 + domName.requestFullscreen()
  24 + domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c'
  25 + } else if (domName.mozRequestFullScreen) {
  26 + domName.mozRequestFullScreen()
  27 + domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c'
  28 + } else if (domName.webkitRequestFullscreen) {
  29 + domName.webkitRequestFullscreen()
  30 + domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c'
  31 + } else if (domName.msRequestFullscreen) {
  32 + domName.msRequestFullscreen()
  33 + domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c'
  34 + }
  35 + }
  36 +}
... ...