Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9b6b8ad
change fallback font to chartjs standard
ThomasBrodt Apr 14, 2021
04230cb
var instead of const for better browser backward compatibility
ThomasBrodt Apr 15, 2021
9af90a9
reorder to better compare with bar controller code
ThomasBrodt Apr 15, 2021
94557e1
let helper function be clearer
ThomasBrodt Apr 15, 2021
eab9804
set/remove hover style already works as inherited
ThomasBrodt Apr 15, 2021
f16c1eb
initial commit for colors by dataset option
ThomasBrodt Apr 15, 2021
68729cc
add options specification for controller
ThomasBrodt Apr 15, 2021
d3441d4
work in progress - use _resolveElementOptions
ThomasBrodt Apr 15, 2021
7f7d833
example with colors per element
ThomasBrodt Apr 18, 2021
4aca13e
categoryPercentage and barPercentage on dataset example
ThomasBrodt Apr 24, 2021
a15f6f3
rename to TimelineScaleConfig
ThomasBrodt Apr 24, 2021
8baca9a
rename minBarWidht to minBarLength (same as in regular bars)
ThomasBrodt Apr 24, 2021
ae852b2
minor
ThomasBrodt Apr 24, 2021
c7f5f36
barThickness is still mandatory, categoryPercentage and barPercentage…
ThomasBrodt Apr 24, 2021
b07fa27
works
ThomasBrodt Apr 24, 2021
1f6ffe1
determineDataLimits
ThomasBrodt Apr 24, 2021
e5cff4b
resolveElementOptions
ThomasBrodt Apr 24, 2021
10227f2
scale _parseValue and getValueForPixel
ThomasBrodt Apr 24, 2021
c490d5c
on the way to support categoryPercentage, barPercentage, still mispla…
ThomasBrodt Apr 25, 2021
b7778f9
clipping text to the inner rectangle
ThomasBrodt Apr 25, 2021
2d40e46
options extended, update renewed
ThomasBrodt Apr 28, 2021
f3b4cec
again options, console.log
ThomasBrodt Apr 28, 2021
629a3b5
_updateElementGeometry with console log, still wrong offset
ThomasBrodt Apr 28, 2021
759215a
y-placing works
ThomasBrodt Apr 28, 2021
380359c
commented out console logs
ThomasBrodt Apr 28, 2021
9aeb166
several different categoryPercentages and barPercentages
ThomasBrodt Apr 28, 2021
d8bedda
make tooltips work (again)
ThomasBrodt Apr 28, 2021
02bf392
override rectangle.getArea()
ThomasBrodt Apr 28, 2021
92b7127
adapted examples to color definition on dataset
ThomasBrodt Apr 29, 2021
567600a
cleanup options, move keyStart/End/Value to dataset, move to element:…
ThomasBrodt Apr 29, 2021
1a85d5b
cleanup font options processing
ThomasBrodt Apr 29, 2021
8f0ada7
use font string in vm
ThomasBrodt Apr 29, 2021
f7eabd9
color option fallback to global defaults
ThomasBrodt Apr 29, 2021
6b0ab16
minimize diff to forked base, part 1 timeline scale
ThomasBrodt May 1, 2021
2387e0a
minimize diffs, part 2 controller
ThomasBrodt May 1, 2021
47b6847
removed unnecessary overrides
ThomasBrodt May 1, 2021
b1668f4
tooltip and options
ThomasBrodt May 1, 2021
db84822
options
ThomasBrodt May 1, 2021
8089cc1
demo file html correction
ThomasBrodt May 1, 2021
649ce4b
fix labeltext not printed if inner === outer
ThomasBrodt May 1, 2021
c88f62c
use dataset options in scale determineDataLimits
ThomasBrodt May 2, 2021
da91fe2
update demo for use of alternate keyStart, keyEnd and keyValue on one…
ThomasBrodt May 2, 2021
db8f8fb
removed debug file
ThomasBrodt May 2, 2021
21fb05c
packaging: split src into files, use /dist, use name chartjs-plugin-t…
ThomasBrodt May 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
.history
.vscode
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 2-Clause License

Copyright (c) 2017, Boyi C
Copyright (c) 2021, Boyi C
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
123 changes: 123 additions & 0 deletions demo/dataset-colors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Bar Chart</title>
<script src="https://cdn.jsdelivr.net/npm/moment/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.js"></script>
<script src="../dist/chartjs-plugin-timeline.js"></script>

<style>
canvas {
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
</style>
</head>

<body>
<div id="container" style="width: 75%">
<canvas id="canvas"></canvas>
</div>
<script>
var ctx = document.getElementById("canvas").getContext("2d");
var chart = new Chart(ctx, {
type: "timeline",
options: {
elements: {
showText: true,
textPadding: 4,
},
},
"data": {
"labels": ["", "Worker 1", "", "Worker 2", "Worker 3", "Worker 4"],
"datasets": [
{
"data": [["2021-04-08T22:00:00Z", "2021-04-09T22:00:00Z", "Team 1"]],
"backgroundColor": "rgba(175,195,221,0.3)",
"borderColor": "rgba(175,195,221,1)",
"borderWidth": 0,
"hoverBackgroundColor": "rgba(175,195,221,0.8)",
"hoverBorderColor": "rgba(175,195,221,0.8)",
"hoverBorderWidth": 0,
"categoryPercentage": 1,
"barPercentage": 1
},
{
"data": [
["2021-04-09T01:00:00Z", "2021-04-09T11:00:00Z", "03:00 - 13:00 Bill"],
["2021-04-09T13:00:00Z", "2021-04-09T15:00:00Z", "15:00 - 17:00 Bill"]
],
"backgroundColor": [
"rgba(0,204,102,0.3)",
"rgba(0,128,254,0.3)"
],
"borderColor": [
"rgba(254,133,0,0.7)",
"rgba(204,0,153,0.7)"
],
"borderWidth": [2, 4],
"hoverBackgroundColor": "rgba(254,133,0,0.8)",
"hoverBorderColor": "rgba(255,0,0,1)",
"hoverBorderWidth": 1,
"categoryPercentage": 1,
"barPercentage": 0.5
},
{
"data": [["2021-04-08T22:00:00Z", "2021-04-09T22:00:00Z", "Team 2"]],
"backgroundColor": "rgba(175,195,221,0.3)",
"borderColor": "rgba(175,195,221,1)",
"borderWidth": 0,
"hoverBackgroundColor": "rgba(175,195,221,0.8)",
"hoverBorderColor": "rgba(175,195,221,0.8)",
"hoverBorderWidth": 0,
"categoryPercentage": 1,
"barPercentage": 1
}, {
"data": [
["2021-04-09T06:00:00Z", "2021-04-09T14:00:00Z", "08:00 - 16:00 Greg"],
["2021-04-09T01:00:00Z", "2021-04-09T04:35:00Z", "03:00 - 05:35 Greg"]
],
"backgroundColor": "rgba(254,214,0,0.3)",
"borderColor": "rgba(254,214,0,1)",
"borderWidth": 2,
"hoverBackgroundColor": "rgba(254,214,0,0.5)",
"hoverBorderColor": "rgba(255,0,0,1)",
"hoverBorderWidth": 1,
"barThickness": 45
}, {
"data": [
["ignored", "ignored", "2021-04-09T00:00:00Z", "2021-04-09T02:00:00Z", "02:00 - 04:00 Michael", "Michael 1"],
["ignored", "ignored", "2021-04-09T09:00:00Z", "2021-04-09T17:00:00Z", "11:00 - 19:00 Michael", "Michael 2"],
["ignored", "ignored", "2021-04-09T19:00:00Z", "2021-04-09T21:00:00Z", "21:00 - 23:00 Michael", "Michael 3"],
],
"backgroundColor": "rgba(254,171,163,0.5)",
"borderColor": "rgba(254,133,0,0.7)",
"borderWidth": 2,
"hoverBackgroundColor": "rgba(254,133,0,0.7)",
"hoverBorderColor": "rgba(171,133,0,1)",
"hoverBorderWidth": 1,
"categoryPercentage": 0.5,
"barPercentage": 0.5,
"keyStart": 2,
"keyEnd": 3,
"keyValue": 5
}, {
"data": [["2021-04-09T10:00:00Z", "2021-04-09T17:30:00Z", "12:00 - 19:30 Jonathan"]],
"backgroundColor": "rgba(254,214,0,0.3)",
"borderColor": "rgba(254,214,0,1)",
"borderWidth": 2,
"hoverBackgroundColor": "rgba(254,214,0,0.5)",
"hoverBorderColor": "rgba(254,214,0,0.9)",
"hoverBorderWidth": 1,
"categoryPercentage": 0.5,
"barPercentage": 0.8
}
],
},
});
</script>
</body>
</html>
15 changes: 11 additions & 4 deletions demo/index_28.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<head>
<title>Bar Chart</title>
<script src="https://cdn.jsdelivr.net/npm/moment/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0/dist/Chart.js"></script>
<script src="../timeline.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.js"></script>
<script src="../dist/chartjs-plugin-timeline.js"></script>

<style>
canvas {
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
Expand Down Expand Up @@ -43,13 +44,19 @@
"Unknown",
],
],
backgroundColor: '#606080',
borderColor: 'black',
borderWidth: 5,
},
{
data: [
["2018-01-22T16:00:00.000Z", "2018-01-23T04:57:43.736Z", "On"],
["2018-01-23T04:57:43.736Z", "2018-01-23T04:57:55.437Z", "Off"],
["2018-01-22T16:00:00.000Z", "2018-01-23T03:57:43.736Z", "On"],
["2018-01-23T03:57:43.736Z", "2018-01-23T04:57:55.437Z", "Off"],
["2018-01-23T04:57:55.437Z", "2018-01-23T05:40:44.626Z", "On"],
],
backgroundColor: ['darkGreen', 'darkRed', 'darkGreen'],
borderColor: 'black',
borderWidth: 2,
},
],
},
Expand Down
16 changes: 12 additions & 4 deletions demo/index_29.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<head>
<title>Bar Chart</title>
<script src="https://cdn.jsdelivr.net/npm/moment/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/Chart.js"></script>
<script src="../timeline.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].4/dist/Chart.js"></script>
<script src="../dist/chartjs-plugin-timeline.js"></script>

<style>
canvas {
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
Expand Down Expand Up @@ -43,13 +44,20 @@
"Unknown",
],
],
backgroundColor: '#606080',
borderColor: 'black',
borderWidth: 5,
textPadding: 20,
},
{
data: [
["2018-01-22T16:00:00.000Z", "2018-01-23T04:57:43.736Z", "On"],
["2018-01-23T04:57:43.736Z", "2018-01-23T04:57:55.437Z", "Off"],
["2018-01-22T16:00:00.000Z", "2018-01-23T03:57:43.736Z", "On"],
["2018-01-23T03:57:43.736Z", "2018-01-23T04:57:55.437Z", "Off"],
["2018-01-23T04:57:55.437Z", "2018-01-23T05:40:44.626Z", "On"],
],
backgroundColor: ['darkGreen', 'darkRed', 'darkGreen'],
borderColor: 'black',
borderWidth: 2,
},
],
},
Expand Down
Loading