indiespirit / react-native-chart-kit

đź“ŠReact Native Chart Kit: Line Chart, Bezier Line Chart, Progress Ring, Bar chart, Pie chart, Contribution graph (heatmap)

Home Page:https://expo.io/@indiespirit/react-native-chart-kit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error thrown when set `data` is an empty list in <LineChart />

vdamrongsri opened this issue · comments

Code

<LineChart
   bezier
   fromZero
   withVerticalLabels
   withDots={false}
   withInnerLines={false}
   withOuterLines={false}
   withHorizontalLabels={false}
   data={{
      labels: ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'],
      datasets: [
         {
            data: [],      <---- data set to empty array
            color: () => '#FF4F4F',
            strokeWidth: 2
         },
      ]
}}
...  

Error thrown

InvalidNumber: M0,0 L-Infinity, 118 L10, 118 Z

Potential related to

        _this.getBezierLinePoints = function (dataset, _a) {
            var width = _a.width, height = _a.height, paddingRight = _a.paddingRight, paddingTop = _a.paddingTop, data = _a.data;
            if (dataset.data.length === 0) {
                return "M0,0";   <--- this return value
            }