Skip to content

Commit

Permalink
Merge pull request #1 from metrica-sports/fran/add-frame-support
Browse files Browse the repository at this point in the history
Add frame support
  • Loading branch information
FranCarrascosaMS authored Jun 24, 2023
2 parents f289fc9 + b1b1405 commit 00d8c61
Show file tree
Hide file tree
Showing 14 changed files with 322 additions and 35 deletions.
19 changes: 18 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
},
{
"type": "node",
"request": "launch",
"name": "Test",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--exit",
"--timeout",
"999999",
"--colors",
"--require",
"vis-dev-utils/babel-register",
"${workspaceFolder}/test"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
2 changes: 2 additions & 0 deletions docs/graph2d/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ <h3 id="timelineOptions">Timeline Options</h3>
<pre class="prettyprint lang-js">{
minorLabels: {
millisecond:'SSS',
frame: 'SSS',
second: 's',
minute: 'HH:mm',
hour: 'HH:mm',
Expand All @@ -878,6 +879,7 @@ <h3 id="timelineOptions">Timeline Options</h3>
},
majorLabels: {
millisecond:'HH:mm:ss',
frame: 'HH:mm:ss,
second: 'D MMMM HH:mm',
minute: 'ddd D MMMM',
hour: 'ddd D MMMM',
Expand Down
2 changes: 2 additions & 0 deletions docs/timeline/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ <h2 id="Configuration_Options">Configuration Options</h2>
<pre class="prettyprint lang-js">{
minorLabels: {
millisecond:'SSS',
frame: 'SSS',
second: 's',
minute: 'HH:mm',
hour: 'HH:mm',
Expand All @@ -651,6 +652,7 @@ <h2 id="Configuration_Options">Configuration Options</h2>
},
majorLabels: {
millisecond:'HH:mm:ss',
frame: 'HH:mm:ss',
second: 'D MMMM HH:mm',
minute: 'ddd D MMMM',
hour: 'ddd D MMMM',
Expand Down
43 changes: 43 additions & 0 deletions lib/timeline/Graph2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ function Graph2d (container, items, groups, options) {
getStep() {
return me.timeAxis.step.step;
},
getMillisecondsPerFrame() {
return me.timeAxis.step.millisecondsPerFrame;
},


toScreen: me._toScreen.bind(me),
toGlobalScreen: me._toGlobalScreen.bind(me), // this refers to the root.width
Expand Down Expand Up @@ -362,6 +366,45 @@ Graph2d.prototype.getEventProperties = function (event) {
}
};

/**
* Convert a datetime (Date object) into a position on the screen
* @param {Date} time A date
* @return {int} x The position on the screen in pixels which corresponds
* with the given date.
*/
Graph2d.prototype.toScreen = function (time) {
return this.body.util.toScreen(time)
};

/**
* Convert a datetime (Date object) into a position on the root
* This is used to get the pixel density estimate for the screen, not the center panel
* @param {Date} time A date
* @return {int} x The position on root in pixels which corresponds
* with the given date.
*/
Graph2d.prototype.toGlobalScreen = function (time) {
return this.body.util.toGlobalScreen(time)
};

/**
* Convert a position on screen (pixels) to a datetime
* @param {int} x Position on the screen in pixels
* @return {Date} time The datetime the corresponds with given position x
*/
Graph2d.prototype.toTime = function (x) {
return this.body.util.toTime(x)
};

/**
* Convert a position on the global screen (pixels) to a datetime
* @param {int} x Position on the screen in pixels
* @return {Date} time The datetime the corresponds with given position x
*/
Graph2d.prototype.toGlobalTime = function (x) {
return this.body.util.toGlobalTime(x)
};

/**
* Load a configurator
* @return {Object}
Expand Down
Loading

0 comments on commit 00d8c61

Please sign in to comment.