Chart.js
Chart.js copied to clipboard
Line Chart always starts drawing at [0,0]
This is the config i am usign in 2.0.0-beta2:
var lineChartData = {
labels : ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November", "Dezember"],
datasets : [
{
label: "My First dataset",
fill: false,
borderColor : "#97DBF2",
pointBorderColor : "#97DBF2",
pointBackgroundColor : "#97DBF2",
pointBorderWidth: 1,
// Number or array - Radius of point when hovered
pointHoverRadius: 5,
// String or array - point background color when hovered
pointHoverBackgroundColor: "rgba(220,220,220,1)",
// Point border color when hovered
pointHoverBorderColor: "rgba(220,220,220,1)",
// Number or array - border width of point when hovered
pointHoverBorderWidth: 2,
tension: -1,
data : [12,13,14,15,16,16,17,18,19,13,12,9],
yAxisID: "y-axis-0",
},
{
label: "My Second dataset",
fill: false,
borderColor : "#DE4E33",
pointBorderColor : "#DE4E33",
pointBackgroundColor : "#DE4E33",
pointBorderWidth: 1,
// Number or array - Radius of point when hovered
pointHoverRadius: 5,
// String or array - point background color when hovered
pointHoverBackgroundColor: "rgba(220,220,220,1)",
// Point border color when hovered
pointHoverBorderColor: "rgba(220,220,220,1)",
// Number or array - border width of point when hovered
pointHoverBorderWidth: 2,
tension: -1,
data : [100,90,80,50,60,50,40,70,90,110,100,130],
yAxisID: "y-axis-1",
}
]
},
options = {
scales: {
yAxes: [{
id: "y-axis-0",
type:"linear",
position: "left",
ticks: {
beginAtZero:true
},
scaleLabel: {
show: true,
labelString: "Temperatur"
}
},
{
id: "y-axis-1",
position: "right",
type:"linear",
ticks: {
beginAtZero:true
},
scaleLabel: {
show: true,
labelString: "Niederschlag"
}
}]
},
line: {
tension:false
},
'animation': {
duration:60,
easing: "easeOutQuart"
},
// Boolean - whether or not the chart should be responsive and resize when the browser does.
responsive: true,
// Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: true,
}
//Get the context of the canvas element we want to select
var ctx = document.getElementById("myChart").getContext("2d");
var myNewChart = new Chart(ctx, {type: 'line',data:lineChartData, options:options});
This is the result:
I can't get the unexpected additional line from ["Januar",0] to ["Januar", 14] to disappear.
Any Idea?
Ok, i found out why: Bower gets me a 2.0.0-alpha build of Chart.js when using the 2.0.0-beta tag
Ok, nevermind, you can delete this. After using the beta2 tag everything went fine -.-
Thanks for coming back to post the answer @kwuerl