mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-07 12:49:07 +02:00
100 lines
2.9 KiB
HTML
100 lines
2.9 KiB
HTML
|
<!doctype html>
|
||
|
<html>
|
||
|
|
||
|
<head>
|
||
|
<title>Line Chart</title>
|
||
|
<script src="../../dist/Chart.bundle.js"></script>
|
||
|
<script src="../chartColors.js"></script>
|
||
|
<style>
|
||
|
canvas {
|
||
|
-moz-user-select: none;
|
||
|
-webkit-user-select: none;
|
||
|
-ms-user-select: none;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<div style="width:75%;">
|
||
|
<canvas id="canvas"></canvas>
|
||
|
</div>
|
||
|
<script>
|
||
|
var randomScalingFactor = function() {
|
||
|
return Math.round(Math.random() * 100);
|
||
|
};
|
||
|
|
||
|
var config = {
|
||
|
type: 'line',
|
||
|
data: {
|
||
|
labels: ["January", "February", "March", "April", "May", "June", "July"],
|
||
|
datasets: [{
|
||
|
label: "My First dataset",
|
||
|
borderColor: window.chartColors.red,
|
||
|
fill: false,
|
||
|
// Skip a point in the middle
|
||
|
data: [
|
||
|
randomScalingFactor(),
|
||
|
randomScalingFactor(),
|
||
|
NaN,
|
||
|
randomScalingFactor(),
|
||
|
randomScalingFactor(),
|
||
|
randomScalingFactor(),
|
||
|
randomScalingFactor()
|
||
|
],
|
||
|
|
||
|
}, {
|
||
|
label: "My Second dataset",
|
||
|
borderColor: window.chartColors.blue,
|
||
|
fill: false,
|
||
|
// Skip first and last points
|
||
|
data: [
|
||
|
NaN,
|
||
|
randomScalingFactor(),
|
||
|
randomScalingFactor(),
|
||
|
randomScalingFactor(),
|
||
|
randomScalingFactor(),
|
||
|
randomScalingFactor(),
|
||
|
NaN
|
||
|
],
|
||
|
}]
|
||
|
},
|
||
|
options: {
|
||
|
responsive: true,
|
||
|
title:{
|
||
|
display:true,
|
||
|
text:'Chart.js Line Chart - Skip Points'
|
||
|
},
|
||
|
tooltips: {
|
||
|
mode: 'index',
|
||
|
},
|
||
|
hover: {
|
||
|
mode: 'index'
|
||
|
},
|
||
|
scales: {
|
||
|
xAxes: [{
|
||
|
display: true,
|
||
|
scaleLabel: {
|
||
|
display: true,
|
||
|
labelString: 'Month'
|
||
|
}
|
||
|
}],
|
||
|
yAxes: [{
|
||
|
display: true,
|
||
|
scaleLabel: {
|
||
|
display: true,
|
||
|
labelString: 'Value'
|
||
|
},
|
||
|
}]
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
window.onload = function() {
|
||
|
var ctx = document.getElementById("canvas").getContext("2d");
|
||
|
window.myLine = new Chart(ctx, config);
|
||
|
};
|
||
|
</script>
|
||
|
</body>
|
||
|
|
||
|
</html>
|