Merge pull request #13721 from ulleo/dev-v2

feat(图表): 地图支持更换字体
This commit is contained in:
dataeaseShu
2024-12-02 15:24:03 +08:00
committed by GitHub
4 changed files with 16 additions and 7 deletions

View File

@@ -268,7 +268,8 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
textOffset: [0, 0], // 文本相对锚点的偏移量 [水平, 垂直]
spacing: 2, // 字符间距
padding: [1, 1], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
textAllowOverlap: true
textAllowOverlap: true,
fontFamily: chart.fontFamily ? chart.fontFamily : undefined
})
configList.push(startTextLayer)
}
@@ -295,7 +296,8 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
textOffset: [0, 0], // 文本相对锚点的偏移量 [水平, 垂直]
spacing: 2, // 字符间距
padding: [1, 1], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
textAllowOverlap: true
textAllowOverlap: true,
fontFamily: chart.fontFamily ? chart.fontFamily : undefined
})
configList.push(endTextLayer)
}

View File

@@ -384,7 +384,8 @@ export class Map extends L7PlotChartView<ChoroplethOptions, Choropleth> {
domStyles: {
'l7plot-legend__category-value': {
fontSize: legend.fontSize + 'px',
color: legend.color
color: legend.color,
'font-family': chart.fontFamily ? chart.fontFamily : undefined
},
'l7plot-legend__category-marker': {
...LEGEND_SHAPE_STYLE_MAP[legend.icon],

View File

@@ -394,7 +394,7 @@ export class SymbolicMap extends L7ChartView<Scene, L7Config> {
}
`
document.head.appendChild(style)
const htmlPrefix = `<div style='font-size:${tooltip.fontSize}px;color:${tooltip.color}'>`
const htmlPrefix = `<div style='font-size:${tooltip.fontSize}px;color:${tooltip.color};font-family: ${chart.fontFamily}'>`
const htmlSuffix = '</div>'
const containerElement = document.getElementById(container)
if (containerElement) {
@@ -522,7 +522,8 @@ export class SymbolicMap extends L7ChartView<Scene, L7Config> {
.style({
textAllowOverlap: label.fullDisplay,
textAnchor: 'center',
textOffset: [0, 0]
textOffset: [0, 0],
fontFamily: chart.fontFamily ? chart.fontFamily : undefined
})
)
}

View File

@@ -196,7 +196,8 @@ export function getLabel(chart: Chart) {
layout,
style: {
fill: l.color,
fontSize: l.fontSize
fontSize: l.fontSize,
fontFamily: chart.fontFamily
},
formatter: function (param: Datum) {
return valueFormatter(param.value, l.labelFormatter)
@@ -903,6 +904,9 @@ export function configL7Label(chart: Chart): false | LabelOptions {
style.textAllowOverlap = false
style.padding = [2, 2]
}
if (chart.fontFamily) {
style.fontFamily = chart.fontFamily
}
return {
visible: label.show,
style
@@ -981,7 +985,8 @@ export function configL7Tooltip(chart: Chart): TooltipOptions {
'l7plot-tooltip': {
'background-color': tooltip.backgroundColor,
'font-size': `${tooltip.fontSize}px`,
'line-height': 1.6
'line-height': 1.6,
'font-family': chart.fontFamily ? chart.fontFamily : undefined
},
'l7plot-tooltip__name': {
color: tooltip.color