First of all, thank you for your work; I have not seen a chart looking this good out of the box, which such a small footprint.
Explanation About What Code Achieves:
This small change makes it possible to format the value from a dataset. this way I could have to datasets from different types to be displayed in the same chart (Example: Rank (#), Value ($))
let values = this.state.datasets.map((set, i) => {
let value = set.values[index];
return {
title: set.name,
value: value,
yPos: set.yPositions[index],
color: this.colors[i],
formatted: formatY ? formatY(value, i) : value, // extending the function with i as `index`
};
});
Passing through the index from the mapping function, we can now format based on the index of the dataset, making it easy to have multiple formatting rules without breaking current implementations.
First of all, thank you for your work; I have not seen a chart looking this good out of the box, which such a small footprint.
Explanation About What Code Achieves:
This small change makes it possible to format the value from a dataset. this way I could have to datasets from different types to be displayed in the same chart (Example: Rank (#), Value ($))
Passing through the index from the mapping function, we can now format based on the index of the dataset, making it easy to have multiple formatting rules without breaking current implementations.
Screenshots/GIFs:
Steps To Test:
Run
yarn dev
and open theindex.html
in docs.or use the following
formatTooltipY
exampleTODOs: