Skip to content

DecimalPlaces property is not used properly #61

@tkayfun

Description

@tkayfun

Heya,

Just looked into the code of this awesome charting library and found a bug which could be fixed very easily:

In src/abstract-chart.js we have the renderHorizontalLabels function which gets the decimalPlaces property, but is not used :( It is hardcoded in the code to 2;

<Text
          key={Math.random()}
          x={paddingRight - yLabelsOffset}
          textAnchor="end"
          y={(height * 3 / 4) - ((height - paddingTop) / count * i) + 12}
          fontSize={12}
          fill={this.props.chartConfig.color(0.5)}
        >{count === 1 ? data[0].toFixed(2) : ((this.calcScaler(data) / (count - 1)) * i + Math.min(...data)).toFixed(2)}
        </Text>

To allow us to change the decimalPlaces we need this piece of code: (change 2 to the variable)

<Text
          key={Math.random()}
          x={paddingRight - yLabelsOffset}
          textAnchor="end"
          y={(height * 3 / 4) - ((height - paddingTop) / count * i) + 12}
          fontSize={12}
          fill={this.props.chartConfig.color(0.5)}
        >{count === 1 ? data[0].toFixed(decimalPlaces) : ((this.calcScaler(data) / (count - 1)) * i + Math.min(...data)).toFixed(decimalPlaces)}
        </Text>

@Hermanya I have a PR for this issue: #60

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions