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

formatter's in tooltip, axisLabel are being reset. #36

Closed hyunahOh closed 2 years ago

hyunahOh commented 2 years ago
  const testOption = {
    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) { // Changed here!!!
        return 'hihi';
      },
    },
    series: [
      {
        name: 'Source',
        type: 'pie',
        legendHoverLink: true,
        hoverAnimation: true,
        avoidLabelOverlap: true,
        startAngle: 180,
        radius: '55%',
        center: ['50%', '35%'],
        data: [
          {value: 105.2, name: 'android'},
          {value: 310, name: 'iOS'},
          {value: 234, name: 'web'},
        ],
        label: {
          normal: {
            show: true,
            textStyle: {
              fontSize: 12,
              color: '#23273C',
            },
          },
        },
        emphasis: {
          lable: {
            show: true,
            fontSize: 12,
            color: '#668BEE',
          },
          itemStyle: {
            show: true,
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)',
          },
        },
      },
    ],
  };

[First]

image

[Second]

image

I set custom formatter like code, and this works for a while and a few seconds later, it shows default tooltip formatter. I tried setNewOption, and same result.

supervons commented 2 years ago

Could you tell me setNewOption params?

@hyunahOh

hyunahOh commented 2 years ago

@supervons

I didn't call setNewOption.

actually I changed second parameter of setOption. and it works. Can you guess why?

// node_modules/react-native-echarts-pro/src/components/Echarts/renderChart.js line:81
// myChart.setOption(option, true, true);
 myChart.setOption(option, false, true);
supervons commented 2 years ago

I knew, i will fix it this week.

you can see more: Apeach Echarts

You can use react-native-echarts-pro@1.8.0 first.

hyunahOh commented 2 years ago

@supervons

oh I see. It was because of notMerge param.

Thanks for quick and detail reply! your package is awesome.

supervons commented 2 years ago

Thanks,have a good trip!