FVANCOP / ChartNew.js

MIT License
420 stars 142 forks source link

HorizontalBar - Scale Start Override vs Values #392

Closed ryock2000 closed 8 years ago

ryock2000 commented 8 years ago

Hi,

if you override the scale start to a negative value, and if you don't have any negative value, all bars start from the override start instead of 0.

image

image

is there an option I forgot to set on my side ?

have a nice day

FVANCOP commented 8 years ago

It's a bug :-)

I will check how to solve it in the next days.

markosko commented 8 years ago

maybe this will help, change this

    var zeroY = 0;
    if (valueBounds.minValue < 0) {
        zeroY = calculateOffset(config.logarithmic, 0, calculatedScale, valueHop);
    }

to this in code

            var zeroY = 0;
            if (valueBounds.minValue < 0) {
                zeroY = calculateOffset(config.logarithmic, 0, calculatedScale, valueHop);
            }
            else if (valueBounds.minValue > config.scaleStartValue) {
                zeroY = calculateOffset(config.logarithmic, 0, calculatedScale, valueHop);
            }

after change it looks like this image

not sure if this will lead to other bugs or something

EDIT: Legend with normal/bold style is from my others testing of change option from single value to function accepting option

ryock2000 commented 8 years ago

Hi,

it has fixed the problem on my side.

I don't see other problem cause by the fix for now. But now I know where to look.

Thank you

FVANCOP commented 8 years ago

Code has been updated to fix the issue

Great thanks to @markosko for the debugging.

In fact, the zeroY value has to be computed without any condition and the bug was for Bar/StackedBar/Lines/HorizontalBar/HorizontalStackedBar.

markosko commented 8 years ago

Yeah, later i found that there was conditional useless, but probably no one till now checked this or used permanent negative start scale with positive numbers ? Not sure. And no problem.