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

echarts数轴指示器只在第一次触发 #37

Closed zengyuehao closed 2 years ago

zengyuehao commented 2 years ago

给x轴加上axisPointer: {show: 'true' } 后点击屏幕只有第一次点击有效

zengyuehao commented 2 years ago

react-native-echarts-pro 【1.8.1】; react-native 【0.67.1】; react-native-webview 【11.17.2】; 平台 【安卓】;

zengyuehao commented 2 years ago

import React from "react"; import { View } from "react-native"; import RNEChartsPro from "react-native-echarts-pro";

export default function Demo() { const option = { tooltip: { backgroundColor: "rgba(255,255,255,0.8)", borderColor: "#668BEE", borderWidth: 1, padding: [5, 10], textStyle: { color: "#24283C", fontSize: 12, }, trigger: "item", formatter: function (a) { return ( '<i style="display: inline-block;width: 10px;height: 10px;background: ' + a["color"] + ';margin-right: 5px;border-radius: 50%;}">' + a["name"] + "
Test: " + a["value"] + "个 " + "
proportion: " + a["percent"] + "%" ); }, }, xAxis: { type: 'category', data: [1,2,3], axisPointer: { show: 'true' } }, yAxis: { name: '123' }, series: [ { name: "Source", type: "line", data: [ { value: 105.2, name: "android" }, { value: 310, name: "iOS" }, { value: 234, name: "web" }, ], }, ], };

return (
    <View style={{ height: 320}}>
        <RNEChartsPro height={250} option={option} onPress={res => {}} />
    </View>
);

}

supervons commented 2 years ago

1.8.2 版本已发布,更新至 1.8.2 版本试试。

npm install react-native-echarts-pro@1.8.2
supervons commented 2 years ago

@zengyuehao

zengyuehao commented 2 years ago

``

经测试,还是不行,在真机上测试只能点一次。如果使用模拟器,则可以点多次,多次点击后就会跟真机一样点不动

zengyuehao commented 2 years ago

@zengyuehao

还有就是折线图tooltip没有触发,但是扇形图的tooltip可以正常触发

zengyuehao commented 2 years ago

@supervons 上面描述有误,目前测试来看不管什么图形都是触发不了tooltip的,如果我一开始没有写onPress这一事件,等图形加载完成后再写上去保存则可以触发tooltip

zengyuehao commented 2 years ago

@supervons 1.8.2版本出现卡死闪退的问题

zengyuehao commented 2 years ago

卡死闪退的问题是因为我在同一个页面做了svg动画导致的,异步加载处理后可以正常显示

supervons commented 2 years ago

我这儿没有真机,用安卓模拟器目前功能正常。

react-native-echarts-pro 【1.8.2】 react-native 【0.66.4】 react-native-webview 【11.17.2】

试试我的例子:

import React, { useRef } from "react";
import { View } from "react-native";
import RNEChartsPro from "react-native-echarts-pro";
export default function ChartsComponent() {
  const echartsRef = new useRef(null);
  const pieOption = {
    tooltip: {
      backgroundColor: "rgba(255,255,255,0.8)",
      borderColor: "#668BEE",
      borderWidth: 1,
      padding: [5, 10],
      textStyle: {
        color: "#24283C",
        fontSize: 12,
      },
      trigger: "item",
    },
    xAxis: {
      type: "category",
      data: [1, 2, 3],
      axisPointer: {
        show: "true",
      },
    },
    yAxis: {
      name: "123",
    },
    series: [
      {
        name: "Source",
        type: "line",
        data: [
          { value: 105.2, name: "android" },
          { value: 310, name: "iOS" },
          { value: 234, name: "web" },
        ],
      },
    ],
  };

  return (
    <View
      style={{
        backgroundColor: "#fff",
        height: 350,
        paddingTop: 25,
      }}>
      <RNEChartsPro
        ref={echartsRef}
        onPress={res => alert(JSON.stringify(res))}
        legendSelectChanged={res => alert(res)}
        height={250}
        option={pieOption}
      />
    </View>
  );
}
supervons commented 2 years ago

太久没有回复,有新的回复再持续跟进。