shauns / react-d3-radar

React-based Radar chart for D3
MIT License
53 stars 32 forks source link

[feature request] custom tickFormat #3

Closed zachguo closed 7 years ago

zachguo commented 7 years ago

useful for percentage strings or custom raings like 'A-'.

zachguo commented 7 years ago

I'm not sure how to contribute, but it seems this can be achieved by changing all backgroundScale.tickFormat to this.props.tickFormat if a tickFormat prop being passed by user.

shauns commented 7 years ago

Thanks for checking out the library! I'll have a look.

String formatting is part of d3-scale (https://github.com/d3/d3-scale#continuous_tickFormat) -- the change is probably something in the radiusScales function and then ensuring the necessary props get passed down through <Radar ... />

shauns commented 7 years ago

Hm - the more I look, the more I think the answer is providing a better API for <RadarWrapper .../> so that these sorts of customisations can be provided explicitly. Did you try using it? It's flow-typed so should be a little friendly but am aware its a pretty verbose component and so any feedback is welcome.

zachguo commented 7 years ago

Thanks for looking into it. If I gonna use RadarWrapper directly, I guess I should change backgroundScale prop. However I actually don't want to change scale, but just tickFormat function. And I have to copy and paste codes from Radar to generate other props. I'm not familiar enough with the codebase, and I don't even understand why there's RadarWrapper in the first place. Looks like an unnecessary abstraction but I'm likely wrong.

zachguo commented 7 years ago

Anyway, this lib is good for what it is. A single domain radar chart can be up-and-running quickly. Asking for customization may be too much. 😄 react-vis added support for radar chart few days ago. I gonna give it a try, tickFormat can be passed via prop domains.tickFormat. http://uber.github.io/react-vis/#/documentation/other-charts/radar-chart