FVANCOP / ChartNew.js

MIT License
420 stars 142 forks source link

HorizontalStackedBarChart scaleOverride Bug and Fix #411

Closed billparkinson closed 8 years ago

billparkinson commented 8 years ago

Around line 3384

We have this

    if (!config.scaleOverride) {
        calculatedScale = calculateScale(1, config, valueBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minValue, labelTemplateString);
        msr = setMeasures(data, config, ctx, height, width, calculatedScale.labels, null, true, true, true, true, true, "HorizontalStackedBar");
    } else {
        calculatedScale = {
            steps: config.scaleSteps,
            stepValue: config.scaleStepWidth,
            graphMin: config.scaleStartValue,
            labels: []
        }
        for (var i = 0; i < calculatedScale.steps; i++) {
            if (labelTemplateString) {
                calculatedScale.labels.push(tmpl(labelTemplateString, {
                    value: fmtChartJS(config, 1 * ((config.scaleStartValue + (config.scaleStepWidth * i)).toFixed(getDecimalPlaces(config.scaleStepWidth))), config.fmtYLabel)
                }));
            }
        }
        msr = setMeasures(data, config, ctx, height, width, calculatedScale.labels, null, true, true, true, true, true, "HorizontalStackedBar");
    }

-->> The line: for (var i = 0; i < calculatedScale.steps; i++) { Should be for (var i = 0; i <= calculatedScale.steps; i++) { < changed to <= ....

The symptom was scale that might read like 0 10 20 undef instead of 0 10 20 30 because we were 1 label short.

markosko commented 8 years ago

I think undefined cant come cause steps are from 1 and for cycle starts with 0 because for cycle would done one more than it should if there will be less or equal

markosko commented 8 years ago

Sorry my problem forgot that u need to add start of scale so yeah there must be less or equal but problem is when this happened because "<=" was there two weeks ago

FVANCOP commented 8 years ago

@billparkinson

Hi,

I think that you use an (very) old version (or a fork); This has been fixed a long time ago.

Regards, François

billparkinson commented 8 years ago

Hi Francois, Yes I must have picked it up from a dead fork somewhere because my version is 30 Sep 2014.  I had in 2015 gone back to the dead fork and seen no updates.  When I searched ChartNew.js this time I found the right place,  but did not realize it until after posting (my apologies).  I will very happily be pulling the new version now though. Many thanks for your efforts! -Bill

  From: Francois Vancoppenolle <notifications@github.com>

To: FVANCOP/ChartNew.js ChartNew.js@noreply.github.com Cc: billparkinson bill_parkinson@yahoo.com Sent: Thursday, February 11, 2016 6:01 PM Subject: Re: [ChartNew.js] HorizontalStackedBarChart scaleOverride Bug and Fix (#411)

@billparkinson Hi,I think that you use an (very) old version (or a fork); This has been fixed a long time ago.Regards, François— Reply to this email directly or view it on GitHub.