Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Struggling with Chart.js

I'm pretty much lost with this chart JS thing I have to do for the front end degree 9th project

$(function()  {

    var trafficData = {
    labels: ["16-22", "23-29", "30-5", "6-12", "13-19", "20-26", "27-3", "4-10", "11-17", "18-24", "25-31"],
    datasets: [
        {
            label: "Traffic",
            fillColor: "rgba(116, 121, 189, .5)",
            strokeColor: "#7479bd",
            pointColor: "#fff",
            BorderColor: "#7479bd",
            BorderWidth: 2,
            pointStrokeColor: "#7479bd",
            pointRadius: 6,
            pointBorderColor: '#7479bd',
            pointHighlightFill: "#fff",
            pointHighlightStroke: "#7479bd",
            data: [750, 1250, 1000, 1500, 2000, 1500, 1750, 1250, 1750, 2250, 1750, 2250]
        }
    ],

};
    var option = {type: 'line'}
    var ctx = document.getElementById("lineChart").getContext("2d");
    var myLineChart = new Chart(ctx).Line(trafficData, option);
});

I'm trying to make the lines linear instead of curved. Also, I'm struggling to put the tick marks so it increments by 500. I tried putting the type in both the option and my trafficData, but no luck. If anyone can help, I would appreciate it. Thank you.

Robert Mullin
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Robert Mullin
Front End Web Development Techdegree Graduate 20,057 Points

The struggle is real man, although thorough I personally do not find the documentation well laid out at all. Very frustrating that we had to do a long Git course before project 9 but no Chart.js tutorial. Anyway, I'll try to answer your questions despite it being two weeks old.

To change the increments you need to adjust the Ticks. Search the documentation and you should be able to find something about it (which should have been clear from the beginning if the documentation was well organized.) It should look something like this:

ticks: { max: 2500, min: 0, stepSize: 500, beginAtZero: true }

Best of luck.

Thanks, I am done with this though.