supervons / react-native-echarts-pro

A React-Native charts based on Apache ECharts, support various charts and map.
https://supervons.github.io/react-native-echarts-pro-docs/
MIT License
216 stars 33 forks source link

宽高不支持变化吗 #33

Closed RengeRenge closed 2 years ago

RengeRenge commented 2 years ago

我的app支持旋转,我在 onLayout 里面获取到新的页面宽高,用 setState 刷新页面,图表的宽高没有发生变化

另外请问支持 type 为 custom 的类型吗,我需要自定义布局,下面这段是官网上的例子

var option = {
    ...,
    series: [{
        type: 'custom',
        renderItem: function (params, api) {
            var categoryIndex = api.value(0);
            var start = api.coord([api.value(1), categoryIndex]);
            var end = api.coord([api.value(2), categoryIndex]);
            var height = api.size([0, 1])[1] * 0.6;

            var rectShape = echarts.graphic.clipRectByRect({
                x: start[0],
                y: start[1] - height / 2,
                width: end[0] - start[0],
                height: height
            }, {
                x: params.coordSys.x,
                y: params.coordSys.y,
                width: params.coordSys.width,
                height: params.coordSys.height
            });

            return rectShape && {
                type: 'rect',
                shape: rectShape,
                style: api.style()
            };
        },
        data: data
    }]
}
supervons commented 2 years ago

1、setState刷新宽高后的回调里面,用 setNewOption 方法重新渲染图表;

2、暂时未找到如何对外提供 echarts 这个对象的方法,所以暂不支持自定义 type 类型。