FVANCOP / ChartNew.js

MIT License
420 stars 142 forks source link

HorizontalBar - sometimes the Bar with smallest Value doesn't appear right #388

Closed tobiasvitt closed 8 years ago

tobiasvitt commented 8 years ago

Hey, i have created a HorizontalBar with ChartNew.js and have a mystical problem that sometimes appears. (https://www.dropbox.com/s/epkuxtft6v8n79k/bar-ok.tiff?dl=0) Using [9,15,4,7] as data works fine and the chart appears like i want to, but if i use other data like [9,6,8,10] then the Bar with the smallest value in this case "6" doesn't appear as expected. (https://www.dropbox.com/s/65h482qsjfufgjk/bar-error.tiff?dl=0) I couldn't unterstand the pattern, in which cases it appears and in which not. The only differences between the image 'bar-ok' and 'bar-error' are the dataset values. Do you have similar issues or do you know how to fix that problem??

My Code:

var data = {
        labels: ["FILE1", "FILE2", "FILE3", "FILE4"],
        datasets: [
            {
                fillColor : ["rgb(228,135,186)","rgb(89,155,255)","rgb(250,199,92)","rgb(43,198,172)"],
                strokeColor : ["rgba(228,135,186,0)","rgba(89,155,255,0)","rgba(250,199,92,0)","rgba(43,198,172,0)"],
                data : [9,15,4,7],
                //      9,15,4,7 works fine
                //      9,6,8,10 works not
            }
        ]
};

    var options = {
        scaleShowGridLines: false,
        scaleLineWidth : 1,
        scaleLineColor: 'rgba(0,0,0,0)', 
        scaleTickSizeLeft: 0,
        scaleTickSizeBottom: 0,
        showYLabels: false,
        showXLabels: false,
        barBorderRadius: 7,
        barShowStroke : false,
        barValueSpacing: 12,
        maxBarWidth : 12,
        inGraphDataShow: true,
        inGraphDataXPosition: 1,
        inGraphDataYPosition: 1,
        inGraphDataPaddingX: -1,
        inGraphDataPaddingY: -7,
        inGraphDataTmpl: '<%=v2%>',
        annotateDisplay: true,
        annotateBackgroundColor: 'rgb(84,92,103)',
        annotateBorder: '3px solid rgb(84,92,103)',
        annotateBorderRadius: '10px',
        annotateLabel : '<%=v3%>',
    };

    var ctx = $(".canvas").get(0).getContext("2d");
    var chart = new Chart(ctx);
    chart.HorizontalBar(data,options);

Thanks

FVANCOP commented 8 years ago

Set option "graphMin : 0"; I agree that it should be the default value, but... historically, it was not the case...