From 26f8070da72dc2676578a6fc0fcc21755e52f0a7 Mon Sep 17 00:00:00 2001 From: tenglonghh <146689148+tenglonghh@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:22:49 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=B7=BB=E5=8A=A0XY=E8=BD=B4=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=AD=97=E4=BD=93=EF=BC=8C=E6=9C=80=E5=A4=A7=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E6=A0=87=E7=AD=BE=E6=95=B0=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hongtenglong Co-authored-by: hongtenglong --- .../charts-wrapper/src/main/ets/AxisBase.ets | 49 ++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/harmony/charts-wrapper/src/main/ets/AxisBase.ets b/harmony/charts-wrapper/src/main/ets/AxisBase.ets index 75c009bf..715748af 100644 --- a/harmony/charts-wrapper/src/main/ets/AxisBase.ets +++ b/harmony/charts-wrapper/src/main/ets/AxisBase.ets @@ -130,6 +130,38 @@ export const setAxis = axis.setGridLineWidth(yAxisRight?.gridLineWidth) } + if (axis instanceof XAxis && xAxis?.fontFamily != undefined) { + if (xAxis.fontFamily === 'sans-serif') { + axis.setTypeface(xAxis.fontFamily) + } + if (xAxis.fontFamily === 'serif') { + axis.setTypeface(xAxis.fontFamily) + } + if (xAxis.fontFamily === 'monospace') { + axis.setTypeface(xAxis.fontFamily) + } + } else if (yAxisLeft?.gridLineWidth != undefined && isyAxis === 'yAxisLeft') { + if (yAxisLeft.fontFamily === 'sans-serif') { + axis.setTypeface(yAxisLeft.fontFamily) + } + if (yAxisLeft.fontFamily === 'serif') { + axis.setTypeface(yAxisLeft.fontFamily) + } + if (yAxisLeft.fontFamily === 'monospace') { + axis.setTypeface(yAxisLeft.fontFamily) + } + } else if (yAxisRight?.gridLineWidth != undefined && isyAxis === 'yAxisRight') { + if (yAxisRight.fontFamily === 'sans-serif') { + axis.setTypeface(yAxisRight.fontFamily) + } + if (yAxisRight.fontFamily === 'serif') { + axis.setTypeface(yAxisRight.fontFamily) + } + if (yAxisRight.fontFamily === 'monospace') { + axis.setTypeface(yAxisRight.fontFamily) + } + } + //设置图表周围边框的颜色。axisLineColor if (axis instanceof XAxis && xAxis?.axisLineColor != undefined) { axis?.setAxisLineColor(xAxis?.axisLineColor); @@ -184,8 +216,6 @@ export const setAxis = if (i.valueTextColor) { limitLine.setTextColor(i.valueTextColor); } - // fontFamily - // 参数还需研究 if (i.labelPosition) { if (i.labelPosition === 'LEFT_TOP') { limitLine.setLabelPosition(LimitLabelPosition.LEFT_TOP) @@ -218,20 +248,20 @@ export const setAxis = // 设置轴的最大标签数 axisMaximum if (axis instanceof XAxis && xAxis?.axisMaximum != undefined) { - axis?.setAxisMaxLabels(xAxis?.axisMaximum); + axis?.setAxisMaximum(xAxis?.axisMaximum); } else if (yAxisLeft?.axisMaximum != undefined && isyAxis === 'yAxisLeft') { - axis?.setAxisMaxLabels(yAxisLeft?.axisMaximum); + axis?.setAxisMaximum(yAxisLeft?.axisMaximum); } else if (yAxisRight?.axisMaximum != undefined && isyAxis === 'yAxisRight') { - axis?.setAxisMaxLabels(yAxisRight?.axisMaximum); + axis?.setAxisMaximum(yAxisRight?.axisMaximum); } //设置轴的最小标签数 axisMinimum if (axis instanceof XAxis && xAxis?.axisMinimum != undefined) { - axis?.setAxisMinLabels(xAxis?.axisMinimum); + axis?.setAxisMinimum(xAxis?.axisMinimum); } else if (yAxisLeft?.axisMinimum != undefined && isyAxis === 'yAxisLeft') { - axis?.setAxisMinLabels(yAxisLeft?.axisMinimum); + axis?.setAxisMinimum(yAxisLeft?.axisMinimum); } else if (yAxisRight?.axisMinimum != undefined && isyAxis === 'yAxisRight') { - axis?.setAxisMinLabels(yAxisRight?.axisMinimum); + axis?.setAxisMinimum(yAxisRight?.axisMinimum); } // 设置轴放大时的最小间隔 granularity @@ -281,7 +311,6 @@ export const setAxis = } else if (yAxisRight?.centerAxisLabels != undefined && isyAxis === 'yAxisRight') { axis?.setCenterAxisLabels(yAxisRight?.centerAxisLabels); } - } else { let xAxis = isRadarCharts?.props.xAxis @@ -374,8 +403,6 @@ export const setAxis = if (i.valueTextColor) { limitLine.setTextColor(i.valueTextColor); } - // fontFamily - // 参数还需研究 if (i.labelPosition) { if (i.labelPosition === 'LEFT_TOP') { limitLine.setLabelPosition(LimitLabelPosition.LEFT_TOP)