Skip to content

Instantly share code, notes, and snippets.

@pangyuteng
Created June 15, 2018 06:44
Show Gist options
  • Save pangyuteng/33c319a24c5da55d7b0a78f2c664a4a2 to your computer and use it in GitHub Desktop.
Save pangyuteng/33c319a24c5da55d7b0a78f2c664a4a2 to your computer and use it in GitHub Desktop.
plot example with chartjs
<!DOCTYPE html>
<html>
<style>
body {
font-family: Helvetica Neue, Arial, sans-serif;
text-align: center;
}
.wrapper {
max-width: 800px;
margin: 50px auto;
}
h1 {
font-weight: 200;
font-size: 3em;
margin: 0 0 0.1em 0;
}
h2 {
font-weight: 200;
font-size: 0.9em;
margin: 0 0 50px;
color: #999;
}
a {
margin-top: 50px;
display: block;
color: #3e95cd;
}
</style>>
<head>
<title>cvib</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="wrapper">
<h1>mRECIST Assessment</h1>
<h2>Subject ABC, Reader XYZ</h2>
<canvas id="myChart" width="1600" height="900"></canvas>
</div>
<script>
// Our labels along the x-axis
var years = [new Date(2016,11,15),new Date(2017,1,10),new Date(2017,2,30),new Date(2017,3,10)];
// For drawing the lines
var tgls1 = [40,40,60,70];
var tgls2 = [20,21,24,18];
var tgls3 = [50,46,51,70];
var chartOptions = {
animation: false
};
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'line',
options: {
animation: {
duration: 0
}
},
data: {
labels: years,
datasets: [
{
data: tgls1,
label: "tgls 1",
borderColor: "#3cba9f",
fill: false
},
{
data: tgls2,
label: "tgls 3",
borderColor: "#e8c3b9",
fill: false
},
{
data: tgls3,
label: "tgls 2",
borderColor: "#c45850",
fill: false
}
]
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment