I have this chart, and the real value of the price is like 0.0000571134
. The react-chartjs-2 only shows value to 3 decimals but I want the entire value to show or at least 8 decimals. I tried some settings in the datasets like stepSize
but none of them worked.
import React from 'react';
import { Line } from 'react-chartjs-2';
import {Col, Row, Typography} from 'antd';
const {Title } = Typography;
const LineChart = ({coinHistory, currentPrice, coinName}) => {
const coinPrice = [];
const coinTimestamp = [];
for (let i = 0; i < coinHistory?.data?.history?.length; i += 1) {
coinPrice.push(coinHistory?.data?.history[i].price);
coinTimestamp.push(new Date(coinHistory?.data?.history[i].timestamp).toLocaleDateString());
}
const data = {
labels: coinTimestamp,
datasets: [
{
label: 'Price In USD',
data: coinPrice,
fill: false,
backgroundColor: '#0071bd',
borderColor: '#0071bd',
},
],
};
const options = {
scales: {
yAxes: [
{
ticks: {
beginAtZero: true,
},
},
],
},
};
return (
<>
<Row className="chart-header">
<Title level={2} className="chart-title">{coinName} Price Chart</Title>
<Col className="price-container">
<Title level={5} className="price-change">Change: {coinHistory?.data?.change}%</Title>
<Title level={5} className="current-price">Current {coinName} Price: $ {currentPrice}</Title>
</Col>
</Row>
<Line data={data} options={options} />
</>
)
}
export default LineChart
coinHistory log:
{"status":"success","data":{"change":147.09,"history":[{"price":"0.0000283221","timestamp":1634756400000},{"price":"0.0000282727","timestamp":1634760000000},
coinPrice log:
"0.0000283221" "0.0000282727" "0.0000282314"