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

[feature] Support line feed char "\n" in the "formatter function". #41

Closed congshengwu closed 2 years ago

congshengwu commented 2 years ago

Summary

Support the line feed char \n in the formatter function. Without this PR, Echarts will display blank when use \n in the formatter function.

In the toString util function, every \n will be removed. This PR will keep \n in the return string of the formatter function.

Test plan

Use the line feed char \n in the formatter function.

Without this PR, Echarts is blank.

With this PR, rendering well with line feed where you want.

<RNEChartsPro
  width="100%"
  height={300}
  option={{
    xAxis: {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
      axisLabel: {
        formatter: (value: string) => {
          return value + '\n' + '(\\n)';
        },
      },
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        data: [150, 230, 224, 218, 135, 147, 260],
        type: 'line'
      }
    ]
  }}
/>

Compatibility

For both Android and iOS.

supervons commented 2 years ago

Thanks for your PR, 👍the test pass.

The next version will be released