Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2 graph overflows on y Axis #1661

Closed
Kalzem opened this issue Nov 17, 2015 · 7 comments
Closed

v2 graph overflows on y Axis #1661

Kalzem opened this issue Nov 17, 2015 · 7 comments
Assignees

Comments

@Kalzem
Copy link

Kalzem commented Nov 17, 2015

screencapture at tue nov 17 23 06 23 cet 2015

<canvas id="chart__inscriptions" width="500" height="250"></canvas>

var lineChart, overallData;
$(function(){
    var ctx = $("#chart__inscriptions");
    analyzeData();
    lineChart = new Chart(ctx, {
        type: 'line',
        data: overallData
    });
});

function analyzeData() {
    overallData = {
        labels: *List of 30 days*,
        datasets: [{
                label: 'Candidats',
                fill: true,
                backgroundColor: "rgba(220,220,220,0.2)",
                borderColor: "rgba(220,220,220,1)",
                data: *30 days of data eg: [0, 4, 0, 35, 3, 0 ...]*
            }, {
                label: 'Startups',
                fill: true,
                backgroundColor: "rgba(100,200,220,0.2)",
                borderColor: "rgba(100,200,220,1)",
                data: *30 days of data eg: [2, 4, 20, 5, 1, 1 ...]*
            }
        ]
    };
}

As you can see, my graph is strangely overflowing. The min y value is 0 and the max y value is about 50.
The y-axis-0 (y axis by default, didn't touch anything about it) has only 9 ticks valued from 0 to 9. How come?

@etimberg
Copy link
Member

hmm @BabyAzerty what does your data look like? Is it attached to the chart as strings or numbers?

@Kalzem
Copy link
Author

Kalzem commented Nov 17, 2015

Great catch!

I was tricked into thinking that the data was correctly understood by ChartJS as it really did show the graph correctly beside the overflow problem...
Not really sure how ChartJS can show the points at the right locations but not the y-axis correctly? It should instead fail everything, shouldn't it?

Thank you!

Just for the record, here is the original data (which is not yet treated)

var rawDataChartCompany = [{"for_date":"2015-10-19","total":"3"},{"for_date":"2015-10-20","total":"5"},{"for_date":"2015-10-21","total":"6"},{"for_date":"2015-10-22","total":"1"},{"for_date":"2015-10-25","total":"1"},{"for_date":"2015-10-26","total":"5"},{"for_date":"2015-10-27","total":"3"},{"for_date":"2015-10-28","total":"5"},{"for_date":"2015-10-30","total":"4"},{"for_date":"2015-11-02","total":"5"},{"for_date":"2015-11-03","total":"5"},{"for_date":"2015-11-04","total":"1"},{"for_date":"2015-11-05","total":"5"},{"for_date":"2015-11-06","total":"3"}];
var rawDataChartCandidate = [{"for_date":"2015-10-19","total":"23"},{"for_date":"2015-10-20","total":"49"},{"for_date":"2015-10-21","total":"35"},{"for_date":"2015-10-22","total":"27"},{"for_date":"2015-10-23","total":"17"},{"for_date":"2015-10-24","total":"9"},{"for_date":"2015-10-25","total":"14"},{"for_date":"2015-10-26","total":"25"},{"for_date":"2015-10-27","total":"25"},{"for_date":"2015-10-28","total":"24"},{"for_date":"2015-10-29","total":"19"},{"for_date":"2015-10-30","total":"10"},{"for_date":"2015-10-31","total":"5"},{"for_date":"2015-11-01","total":"2"},{"for_date":"2015-11-02","total":"30"},{"for_date":"2015-11-03","total":"17"},{"for_date":"2015-11-04","total":"34"},{"for_date":"2015-11-05","total":"67"},{"for_date":"2015-11-06","total":"30"},{"for_date":"2015-11-07","total":"4"}];

@etimberg etimberg self-assigned this Nov 17, 2015
@etimberg
Copy link
Member

It should support strings as data (I don't recall any code that requires a number to be passed in). That being said, I'm going to investigate since this really should work.

@Kalzem
Copy link
Author

Kalzem commented Nov 17, 2015

Here is the entire code if you need it: https://gist.github.com/BabyAzerty/d96c56d4eb0945554a9d
Btw, the only Number type values are all the 0, otherwise the rest is string based. Maybe ChartJS doesn't like the mix?

@etimberg
Copy link
Member

thanks! I've replicated the issue on my end. Hopefully I can get this debugged quickly.

@etimberg
Copy link
Member

@BabyAzerty see #1662 for the fix.

@etimberg
Copy link
Member

CLosing as #1662 was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants