Skip to content

Open source personal finance application

perf: lazy-load ECharts into separate async chunk

Ilya Komichev2a7a8be96c46
diff --git a/app/components/stat/chart/View.vue b/app/components/stat/chart/View.vue
index 1f2f5732..fa762290 100644
--- a/app/components/stat/chart/View.vue
+++ b/app/components/stat/chart/View.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import defu from 'defu'
-import { BarChart, LineChart, PieChart } from 'echarts/charts'
-import { DataZoomComponent, GridComponent, MarkAreaComponent, MarkLineComponent, MarkPointComponent, TooltipComponent } from 'echarts/components'
+import { BarChart, LineChart } from 'echarts/charts'
+import { GridComponent, MarkAreaComponent, MarkLineComponent, TooltipComponent } from 'echarts/components'
import { use } from 'echarts/core'
import { SVGRenderer } from 'echarts/renderers'
import VChart from 'vue-echarts'
@@ -32,13 +32,10 @@ const emit = defineEmits<{
use([
BarChart,
- DataZoomComponent,
GridComponent,
LineChart,
MarkAreaComponent,
MarkLineComponent,
- MarkPointComponent,
- PieChart,
SVGRenderer,
TooltipComponent,
])
diff --git a/app/components/stat/chart/Wrap.vue b/app/components/stat/chart/Wrap.vue
index 32300e8d..7acc6dc7 100644
--- a/app/components/stat/chart/Wrap.vue
+++ b/app/components/stat/chart/Wrap.vue
@@ -66,7 +66,7 @@ function onChangePeriod(period: Period) {
</div>
</div>
- <StatChartView
+ <LazyStatChartView
:chartType="statConfig.config.value.chartType"
:period="statDate.params.value.intervalsBy"
:series="props.series"
diff --git a/app/components/stat/chart/config.ts b/app/components/stat/chart/config.ts
index 87bcf9ba..c2bae728 100644
--- a/app/components/stat/chart/config.ts
+++ b/app/components/stat/chart/config.ts
@@ -1,5 +1,5 @@
import type { GridComponentOption } from 'echarts'
-import type { BarSeriesOption, LineSeriesOption, PieSeriesOption } from 'echarts/charts'
+import type { BarSeriesOption, LineSeriesOption } from 'echarts/charts'
import type { TooltipComponentOption } from 'echarts/components'
import type { ComposeOption } from 'echarts/core'
@@ -9,7 +9,6 @@ import { getCompactAmount, getLocalAmount } from '~/components/stat/chart/utils'
type EChartsOption = ComposeOption<
| TooltipComponentOption
- | PieSeriesOption
| GridComponentOption
>
diff --git a/app/components/stat/chart/types.ts b/app/components/stat/chart/types.ts
index 7bc5fda3..c95e7330 100644
--- a/app/components/stat/chart/types.ts
+++ b/app/components/stat/chart/types.ts
@@ -1,3 +1,3 @@
-export const chartTypes = ['bar', 'line', 'pie'] as const
+export const chartTypes = ['bar', 'line'] as const
export type ChartType = (typeof chartTypes)[number]