Skip to content

Commit 92206fb

Browse files
committed
limits x and y axis, further style adjustments
1 parent c971c6d commit 92206fb

File tree

3 files changed

+14231
-10
lines changed

3 files changed

+14231
-10
lines changed

data.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,48 @@ import {
55
setAutoHeight
66
} from "@formsort/custom-question-api";
77

8+
// Need a function that can transform: current weight, weight loss time horizon into a data object
89
const allAnswers = getAnswerValue();
910

1011
(async function () {
1112
const data = [
1213
{ month: "Jan", weight: 250 },
1314
{ month: "Feb", weight: 250 },
14-
{ month: "Mar", weight: 200 },
15-
{ month: "Apr", weight: 150 },
16-
{ month: "May", weight: 50 },
17-
{ month: "Jun", weight: 0 }
15+
{ month: "Jun", weight: 200 }
1816
];
1917

2018
new Chart(document.getElementById("data"), {
2119
type: "line",
2220
options: {
2321
pointStyle: false,
24-
pointRadius: 5,
2522
fill: true,
26-
backgroundColor: "rgb(254,250,224,0.8)",
27-
borderColor: "rgb(188,108,37,0.8 )",
23+
backgroundColor: "rgb(229,229,229,0.8)",
24+
borderColor: "#00000",
2825
borderWidth: 3,
29-
legend: { display: false },
3026
scales: {
3127
x: {
28+
type: "category",
29+
max: 2,
30+
labels: ["January", "February", "March", "April", "May"],
31+
// min: "February",
3232
grid: {
3333
display: false
3434
}
3535
},
3636
y: {
37+
type: "linear",
38+
// beginAtZero: true,
3739
grid: {
3840
display: false
41+
},
42+
ticks: {
43+
count: 2
3944
}
4045
}
4146
}
4247
},
48+
plugins: {},
4349
data: {
44-
labels: data.map((row) => row.month),
4550
datasets: [
4651
{
4752
label: "Weight loss prediction",

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<title>Chart.js</title>
77
</head>
88
<body>
9-
<div style="width: 800px">
9+
<div style="width: 500px">
1010
<canvas id="data"></canvas>
1111
</div>
1212

0 commit comments

Comments
 (0)