Skip to content

Commit 9214be5

Browse files
authored
feat: add current date marker flag (#27)
Refs: nodejs/nodejs.org#8101
1 parent eab9ef7 commit 9214be5

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ jspm_packages
3737
.node_repl_history
3838

3939
.eslintcache
40+
41+
# Artifacts
42+
*.html
43+
*.png
44+
*.svg

bin/lts.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ const cliArgs = {
8080
require: false,
8181
multiple: false,
8282
default: 'Node.js'
83+
},
84+
'c': {
85+
description: 'Current date marker',
86+
alias: 'currentDateMarker',
87+
type: 'string',
88+
require: false,
89+
multiple: false,
90+
default: null
8391
}
8492
};
8593

@@ -99,7 +107,8 @@ const options = {
99107
png: args.png ? Path.resolve(args.png) : null,
100108
animate: args.animate,
101109
excludeMain: args.excludeMain,
102-
projectName: args.projectName
110+
projectName: args.projectName,
111+
currentDateMarker: args.currentDateMarker
103112
};
104113

105114
Lib.create(options);

lib/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const styles = `
3838
text-transform: uppercase;
3939
}`;
4040

41-
4241
function parseInput (data, queryStart, queryEnd, excludeMain, projectName) {
4342
const output = [];
4443

@@ -93,7 +92,7 @@ function parseInput (data, queryStart, queryEnd, excludeMain, projectName) {
9392

9493

9594
function create (options) {
96-
const { queryStart, queryEnd, html, svg: svgFile, png, animate, excludeMain, projectName, margin: marginInput } = options;
95+
const { queryStart, queryEnd, html, svg: svgFile, png, animate, excludeMain, projectName, margin: marginInput, currentDateMarker } = options;
9796
const data = parseInput(options.data, queryStart, queryEnd, excludeMain, projectName);
9897
const d3n = new D3Node({ svgStyles: styles, d3Module: D3 });
9998
const margin = marginInput || { top: 30, right: 30, bottom: 30, left: 110 };
@@ -149,6 +148,21 @@ function create (options) {
149148
.attr('stroke', '#89a19d');
150149
}
151150

151+
if (currentDateMarker) {
152+
const currentDate = new Date();
153+
154+
// Add a vertical red line for the current date
155+
const currentX = xScale(currentDate);
156+
svg.append('line')
157+
.attr('x1', currentX)
158+
.attr('x2', currentX)
159+
.attr('stroke-width', 2)
160+
.attr('y1', 0)
161+
.attr('y2', height)
162+
.attr('stroke', currentDateMarker)
163+
.attr('opacity', 1);
164+
}
165+
152166
svg.append('g')
153167
.attr('class', 'axis axis--x')
154168
.call(customXAxis);

0 commit comments

Comments
 (0)