66 * https://opensource.org/licenses/MIT
77 */
88import optionHolder from "@service/components/option-holder"
9- import { processAnimation , processAria , processRtl } from "@util/echarts"
10- import { type AriaComponentOption , type ComposeOption } from "echarts"
9+ import { processAnimation , processAria , processFont , processRtl } from "@util/echarts"
10+ import { type AriaComponentOption , type ComposeOption , SeriesOption , TitleComponentOption } from "echarts"
1111import { type ECharts , init } from "echarts/core"
1212import { ElLoading } from "element-plus"
1313import { type Ref , isRef , onMounted , ref , watch } from "vue"
1414import { useElementSize } from './useElementSize'
1515import { useWindowSize } from "./useWindowSize"
1616
17- type BaseEchartsOption = ComposeOption < AriaComponentOption >
17+ type BaseEchartsOption = ComposeOption <
18+ | AriaComponentOption
19+ | TitleComponentOption
20+ | SeriesOption
21+ >
1822
1923export abstract class EchartsWrapper < BizOption , EchartsOption > {
2024 public instance : ECharts | undefined
@@ -27,9 +31,15 @@ export abstract class EchartsWrapper<BizOption, EchartsOption> {
2731 */
2832 protected replaceSeries : boolean = false
2933 private lastBizOption : BizOption | undefined
34+ /**
35+ * Fix the font family
36+ * @see https://github.com/sheepzh/time-tracker-4-browser/issues/623
37+ */
38+ private textFontFamily : string | undefined
3039
3140 init ( container : HTMLDivElement ) {
3241 this . instance = init ( container )
42+ this . textFontFamily = getComputedStyle ( container ) . fontFamily
3343 }
3444
3545 async render ( biz : BizOption ) {
@@ -40,7 +50,7 @@ export abstract class EchartsWrapper<BizOption, EchartsOption> {
4050
4151 private async innerRender ( ) {
4252 const biz = this . lastBizOption
43- const option = biz && await this . generateOption ( biz ) as ( EchartsOption & BaseEchartsOption )
53+ const option = biz && await this . generateOption ( biz )
4454 if ( ! option ) return
4555
4656 await this . postChartOption ( option )
@@ -54,6 +64,7 @@ export abstract class EchartsWrapper<BizOption, EchartsOption> {
5464 processAnimation ( option , chartAnimationDuration )
5565 processAria ( option , chartDecal )
5666 processRtl ( option )
67+ this . textFontFamily && processFont ( option , this . textFontFamily )
5768 }
5869
5970 async resize ( ) {
@@ -66,7 +77,7 @@ export abstract class EchartsWrapper<BizOption, EchartsOption> {
6677 return this . instance ! . getDom ( )
6778 }
6879
69- protected abstract generateOption ( biz : BizOption ) : Promise < EchartsOption > | EchartsOption
80+ protected abstract generateOption ( biz : BizOption ) : Awaitable < EchartsOption >
7081
7182 protected getDomWidth ( ) : number {
7283 return this . getDom ( ) ?. clientWidth ?? 0
0 commit comments