shutterstock / rickshaw

JavaScript toolkit for creating interactive real-time graphs
https://shutterstock.github.io/rickshaw
MIT License
6.53k stars 941 forks source link

Using Rickshaw.Fixtures.formatBase1024KMGTP seems to cause Y axis to go weird #601

Closed cmouse closed 4 years ago

cmouse commented 6 years ago

With following configuration

var y_fixture = Rickshaw.Fixtures.Number.formatBase1024KMGPT;

var graph = new Rickshaw.Graph( {
    element: config.div.find(".chart")[0],
    width: 550,
    height: 250,
    renderer: config.renderer || 'multi',
    padding: { top: 0.05 },
    series: plotseries

});

var axes = new Rickshaw.Graph.Axis.Time( {
    graph: graph,
    orientation: 'bottom',
    timeFixture: new Rickshaw.Fixtures.Time.Local()
} );

var y_ticks = new Rickshaw.Graph.Axis.Y( {
    graph: graph,
    orientation: 'left',
    tickFormat: y_fixture,
    element: config.div.find(".y_axis")[0]
} );

var legend = new Rickshaw.Graph.Legend( {
    graph: graph,
    element: config.div.find(".legend")[0]
} );

I get following graph with-format1024kmgtp

If I use Rickshaw.Fixtures.Number.formatKMGT I get the following one. (Which is same as KMBT but B changed to G). without-format1024kmgtp

cmouse commented 6 years ago
>Rickshaw.Fixtures.Number.formatBase1024KMGTP(11111111)
"10.596381187438965M"
>Rickshaw.Fixtures.Number.formatKMGT(11111111)
"11.111111M"
cmouse commented 6 years ago

The problem seems to be fixable by surrounding the divisions with (y / factor).toFixed(2)

RichardLitt commented 6 years ago

Interesting. Do you think the best option would be adding this information to documentation, or patching it?

cmouse commented 6 years ago

My feeling is that it should be patched, as it cannot be fixed without altering formatBase1024KMGTP function.