forked from Makanz/chartjs-plugin-trendline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can use also XY data for scatter-graphs
- Loading branch information
Showing
3 changed files
with
184 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>LineChart Example</title> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script> | ||
<script src="../src/chartjs-plugin-trendline.js"></script> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function(event) { | ||
new Chart(document.getElementById("line-chart"), { | ||
type: 'scatter', | ||
data: { | ||
datasets: [{ | ||
data: [{x: 1500, y: 86},{x: 1600, y: 114},{x: 1700, y: 106},{x: 1750, y: 106},{x: 1800, y: 107},{x: 1850, y: 111},{x: 1900, y: 133},{x: 1950, y: 221},{x: 1999, y: 783},{x: 2050, y: 2478}], | ||
label: "Africa", | ||
borderColor: "#3e95cd", | ||
fill: false, | ||
trendlineLinear: { | ||
style: "#3e95cd", | ||
lineStyle: "line", | ||
width: 1 | ||
} | ||
}, { | ||
data: [{x: 1500, y: 282},{x: 1600, y: 350},{x: 1700, y: 411},{x: 1750, y: 502},{x: 1800, y: 635},{x: 1850, y: 809},{x: 1900, y: 947},{x: 1950, y: 1402},{x: 1999, y: 3700},{x: 2050, y: 5267}], | ||
label: "Asia", | ||
borderColor: "#8e5ea2", | ||
fill: false, | ||
trendlineLinear: { | ||
style: "#8e5ea2", | ||
lineStyle: "line", | ||
width: 1 | ||
} | ||
}, { | ||
data: [{x: 1500, y: 168},{x: 1600, y: 170},{x: 1700, y: 178},{x: 1750, y: 190},{x: 1800, y: 203},{x: 1850, y: 276},{x: 1900, y: 408},{x: 1950, y: 547},{x: 1999, y: 675},{x: 2050, y: 734}], | ||
label: "Europe", | ||
borderColor: "#3cba9f", | ||
fill: false | ||
}, { | ||
data: [{x: 1500, y: 40},{x: 1600, y: 20},{x: 1700, y: 10},{x: 1750, y: 16},{x: 1800, y: 24},{x: 1850, y: 38},{x: 1900, y: 74},{x: 1950, y: 167},{x: 1999, y: 508},{x: 2050, y: 784}], | ||
label: "Latin America", | ||
borderColor: "#e8c3b9", | ||
fill: false | ||
}, { | ||
data: [{x: 1500, y: 6},{x: 1600, y: 3},{x: 1700, y: 2},{x: 1750, y: 2},{x: 1800, y: 7},{x: 1850, y: 26},{x: 1900, y: 82},{x: 1950, y: 172},{x: 1999, y: 312},{x: 2050, y: 433}], | ||
label: "North America", | ||
borderColor: "#c45850", | ||
fill: false | ||
} | ||
] | ||
}, | ||
options: { | ||
title: { | ||
display: true, | ||
text: 'World population per region (in millions)', | ||
}, | ||
maintainAspectRatio: false, | ||
responsive: true, | ||
scales: { | ||
xAxes: [{ type: 'linear', position: 'bottom', scaleLabel: { labelString: 'year', display: true} }], | ||
yAxes: [{ type: 'linear', position: 'left', scaleLabel: { labelString: 'population/1M', display: true}, display: true }], | ||
} | ||
} | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<h1>Line Chart</h1> | ||
<canvas id="line-chart" width="600" height="450"></canvas> | ||
|
||
<p>Using example code from <a href="http://tobiasahlin.com/blog/chartjs-charts-to-get-you-started/" target="_blank">tobiasahlin.com.</a></p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>LineChart Example</title> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script> | ||
<script src="../src/chartjs-plugin-trendline.js"></script> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function(event) { | ||
new Chart(document.getElementById("line-chart"), { | ||
type: 'line', | ||
data: { | ||
datasets: [{ | ||
data: [{x: 1500, y: 86},{x: 1600, y: 114},{x: 1700, y: 106},{x: 1750, y: 106},{x: 1800, y: 107},{x: 1850, y: 111},{x: 1900, y: 133},{x: 1950, y: 221},{x: 1999, y: 783},{x: 2050, y: 2478}], | ||
label: "Africa", | ||
borderColor: "#3e95cd", | ||
fill: false, | ||
trendlineLinear: { | ||
style: "#3e95cd", | ||
lineStyle: "line", | ||
width: 1 | ||
} | ||
}, { | ||
data: [{x: 1500, y: 282},{x: 1600, y: 350},{x: 1700, y: 411},{x: 1750, y: 502},{x: 1800, y: 635},{x: 1850, y: 809},{x: 1900, y: 947},{x: 1950, y: 1402},{x: 1999, y: 3700},{x: 2050, y: 5267}], | ||
label: "Asia", | ||
borderColor: "#8e5ea2", | ||
fill: false, | ||
trendlineLinear: { | ||
style: "#8e5ea2", | ||
lineStyle: "line", | ||
width: 1 | ||
} | ||
}, { | ||
data: [{x: 1500, y: 168},{x: 1600, y: 170},{x: 1700, y: 178},{x: 1750, y: 190},{x: 1800, y: 203},{x: 1850, y: 276},{x: 1900, y: 408},{x: 1950, y: 547},{x: 1999, y: 675},{x: 2050, y: 734}], | ||
label: "Europe", | ||
borderColor: "#3cba9f", | ||
fill: false | ||
}, { | ||
data: [{x: 1500, y: 40},{x: 1600, y: 20},{x: 1700, y: 10},{x: 1750, y: 16},{x: 1800, y: 24},{x: 1850, y: 38},{x: 1900, y: 74},{x: 1950, y: 167},{x: 1999, y: 508},{x: 2050, y: 784}], | ||
label: "Latin America", | ||
borderColor: "#e8c3b9", | ||
fill: false | ||
}, { | ||
data: [{x: 1500, y: 6},{x: 1600, y: 3},{x: 1700, y: 2},{x: 1750, y: 2},{x: 1800, y: 7},{x: 1850, y: 26},{x: 1900, y: 82},{x: 1950, y: 172},{x: 1999, y: 312},{x: 2050, y: 433}], | ||
label: "North America", | ||
borderColor: "#c45850", | ||
fill: false | ||
} | ||
] | ||
}, | ||
options: { | ||
title: { | ||
display: true, | ||
text: 'World population per region (in millions)', | ||
}, | ||
maintainAspectRatio: false, | ||
responsive: true, | ||
scales: { | ||
xAxes: [{ type: 'linear', position: 'bottom', scaleLabel: { labelString: 'year', display: true} }], | ||
yAxes: [{ type: 'linear', position: 'left', scaleLabel: { labelString: 'population/1M', display: true}, display: true }], | ||
} | ||
} | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<h1>Line Chart</h1> | ||
<canvas id="line-chart" width="600" height="450"></canvas> | ||
|
||
<p>Using example code from <a href="http://tobiasahlin.com/blog/chartjs-charts-to-get-you-started/" target="_blank">tobiasahlin.com.</a></p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters