Skip to content

Commit 7d2a168

Browse files
committed
fix(svg): add default strokeWidth for stroke
1 parent 109379b commit 7d2a168

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

example/src/App.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { StyleSheet, View, Dimensions } from 'react-native';
44
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';
55
import { SVGRenderer, SkiaChart, SvgChart } from '@wuba/react-native-echarts';
66
import * as echarts from 'echarts/core';
7-
import { BarChart } from 'echarts/charts';
7+
import { BarChart, LineChart } from 'echarts/charts';
88
import {
99
TitleComponent,
1010
TooltipComponent,
@@ -19,6 +19,7 @@ echarts.use([
1919
SVGRenderer,
2020
// ...
2121
BarChart,
22+
LineChart,
2223
]);
2324

2425
const E_HEIGHT = 250;
@@ -72,11 +73,18 @@ const option = {
7273
yAxis: {
7374
type: 'value',
7475
},
76+
tooltip: {
77+
trigger: 'axis'
78+
},
7579
series: [
7680
{
7781
data: [120, 200, 150, 80, 70, 110, 130],
7882
type: 'bar',
7983
},
84+
{
85+
data: [220, 100, 180, 160, 150, 120, 110],
86+
type: 'line',
87+
}
8088
],
8189
};
8290
function App() {

src/svgChart.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ function SvgEle(props: SVGVEleProps) {
155155
if (tag === 'path') {
156156
// 全部数据为空,iOS渲染有问题,无效的path过滤掉
157157
if (!attrs.d) return null;
158+
// fix: add default strokeWidth for stroke
159+
if(attrs.stroke && attrs.strokeWidth === undefined) {
160+
attrs.strokeWidth = 1;
161+
}
158162
return <Path {...attrs} />;
159163
}
160164
if (tag === 'linearGradient' || tag === 'radialGradient') {

0 commit comments

Comments
 (0)