Merge pull request #13714 from ulleo/dev-v2

feat(图表): 图表支持更换字体
This commit is contained in:
xuwei-fit2cloud
2024-12-02 13:37:48 +08:00
committed by GitHub
5 changed files with 11 additions and 2 deletions

View File

@@ -73,6 +73,8 @@ declare interface Chart {
showPosition: string
extColor: Axis[]
fontFamily?: string
}
declare type CustomAttr = DeepPartial<ChartAttr> | JSONString<DeepPartial<ChartAttr>>
declare type CustomStyle = DeepPartial<ChartStyle> | JSONString<DeepPartial<ChartStyle>>

View File

@@ -358,7 +358,6 @@ export class Line extends G2PlotChartView<LineOptions, G2Line> {
fill: style.stroke
}
}
console.log(optionTmp)
return optionTmp
}
protected setupOptions(chart: Chart, options: LineOptions): LineOptions {

View File

@@ -146,6 +146,11 @@ export function getTheme(chart: Chart) {
}
}
}
if (chart.fontFamily) {
theme.styleSheet = {
fontFamily: chart.fontFamily
}
}
return theme
}
// 通用label

View File

@@ -225,7 +225,8 @@ const renderChart = async (view, callback?) => {
// 与默认图表对象合并,方便增加配置项
const chart = deepCopy({
...defaultsDeep(view, cloneDeep(BASE_VIEW_CONFIG)),
data: chartData.value
data: chartData.value,
fontFamily: props.fontFamily
})
const chartView = chartViewManager.getChartView(view.render, view.type)
recursionTransObj(customAttrTrans, chart.customAttr, scale.value, terminal.value)

View File

@@ -1151,6 +1151,7 @@ const titleTooltipWidth = computed(() => {
:show-position="showPosition"
:element="element"
:suffixId="suffixId"
:font-family="fontFamily"
v-else-if="
showChartView(ChartLibraryType.G2_PLOT, ChartLibraryType.L7_PLOT, ChartLibraryType.L7)
"
@@ -1167,6 +1168,7 @@ const titleTooltipWidth = computed(() => {
:show-position="showPosition"
:element="element"
:drill-length="drillClickLength"
:font-family="fontFamily"
v-else-if="showChartView(ChartLibraryType.S2)"
ref="chartComponent"
@onPointClick="onPointClick"