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 32 forks source link

[feature] support parsing string arrow function #94

Closed congshengwu closed 1 year ago

congshengwu commented 1 year ago

Summary

This PR supports parsing the arrow function in string format for the Echarts option, an enhancement for PR #91.

Test Plan

Code:

// Echarts option
const option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    axisLabel: {
      interval: 0,
      formatter: `(value, index) => {
        return value + '(' + index + ')';
      }`,
    },
  },
  yAxis: {
    type: 'value',
    axisLabel: {
      formatter: `(value) => {
      return formatterVariable.currency + value;
    }`,
      textStyle: {
        color: `function(value) {
        return value >= 200 ? 'green' : 'red';
      }`,
      },
    },
  },
  series: [
    {
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line',
    },
  ],
};

// Echarts view
<RNEChartsPro
  style={{width: Dimensions.get('window').width}}
  option={option}
  formatterVariable={{currency: '¥'}}
  enableParseStringFunction
/>

Running result:

demo
lxverycool commented 4 months ago

这种方法,debug环境,图表不显示