1.2.1 • Published 7 years ago

ameasurejs-timeline v1.2.1

Weekly downloads
3
License
-
Repository
-
Last release
7 years ago

A-Measure Timeline


A timeline service and screen for PM Engine results.

Getting Started

Install the timeline via npm.

npm install ameasurejs-timeline --registry http://nuget.ma.aptima.com/npm/AMeasureJSNPM

Add 'ameasure.timeline' module as dependency.

angular.module('orcid', ['ameasure.timeline'])

Include the vendor.js and timeline.js files in your index.

<script src="node_modules/ameasurejs-timeline/dist/vendor.js"></script>
<script src="node_modules/ameasurejs-timeline/dist/timeline.js"></script>

Setting Configuration Options

In your module's .run() function, include the 'timelineConfig' constant. Ex:

angular.module('orcid', ['ameasure.timeline'])
    .run(function(timelineConfig) {
        timelineConfig.autoUpdateTime = false;
    })

Available Options

NameTypeDescription
autoUpdateTimebooleanAutomatically adjusts the time domain if a bar, line, tick extends beyond it.

Creating the Timeline

Timeline

Construct the timeline object.

.controller('orcidCtrl', function ($scope, Timeline) {
    $scope.timeline = new Timeline();
})

Use the default timeline.

<timeline data="timeline"></timeline>

Or construct your own timeline with individual directives.

<timeline-zoom data="timeline"></timeline-zoom>
<timeline-phases data="timeline"></timeline-phases>
<timeline-row ng-repeat="row in timeline.rows" datarow="row" data="timeline"></timeline-row>

Listening to events

These are $rootScope events that are broadcasted based on interactions with the timeline.

NameArgumentsDescription
rowHoverstring name, Date timeWhenever a bar, line, or tick is hovered over in that row, it returns the name of the row and the time where the mouse is hovered over.
commentClickstring text, Date timeThis is broadcasted when a comment is clicked on. It returns any text associated and the time of the comment.

Objects API

Timeline

Properties

NameTypeDescription
rowsTimelineRow[]Array that stores all of the rows on the timeline.
phasesArrayArray that stores all of the phases on the timeline. Can be a TimelineBar or a tick.
commentsArrayArray that stores all of the comments on the timeline.
timeServiceTimeServiceA service object that handles the timing (i.e. time domain, current time)
adjustDomainCbfunctionA callback related to adjusting the domain in time service that is saved to rows/bars to handle auto-adjustment of the time domain when data is added.

Methods

FunctionDescription
addPhaseTick(Date startTime, string imageUrl)Adds a phase tick to the phase row at the given time, display the given image.
addPhaseBar(TimelineBar bar)Adds a bar to the phase row.
addComment(Date startTime[, string text])Adds a comment at the given time. Can be provided with comment text.
addRow(string name)Creates a TimelineRow with the given measure name and adds it to the timeline.
createSubRow(string name)Creates a TimelineRow with the given measure name and returns it.
createLine(Date start, Date end[, string fill, string text])Creates a TimelineBar with the start and end time and returns it.
createBar(Date start, Date end[, string fill, string text])Creates a TimelineBar with the start and end time and returns it.
autoSetTimeDomain()Will automatically generate the time domain with the start at the earliest piece of data, and end at the latest piece of data currently in the system.

TimeService

Properties

NameTypeDescription
updateZoomDomainCallbacksArrayStores callbacks for zoom updates.
updateTimeDomainCallbacksArrayStores callbacks for time domain updates.
currentTimeCallbacksArrayStores callbacks for current time callbacks.
currentTimeDateCurrent time on the timeline.
timeDomain[Date, Date]Time domain of the entire timeline.
zoom[Date, Date]Domain of the zoomed in zone.
sharedPropertiesObjectHolds properties that are shared between timeline individual component directives.

Methods

FunctionDescription
reset()Zooms out and calls all redraw callbacks.
createTimeScaleAndAxis(int rowWidth)Creates the time scale (D3) and corresponding axis for the zoom based on the width (in pixels) of the timeline.
updateZoomDomain(Date[] time)Takes in a time domain (array of two Date objects) and updates the zoom domain.
updateTimeDomain(Date start, Date end)Takes a start and end time and updates the overall time domain of the timeline.
updateCurrentTime(Date time)Updates the current time marker to that time.

TimelineRow

Properties

NameTypeDescription
namestringName of the row/measure.
barsTimelineBar[]Array that stores all of the bars.
ticksArrayArray that stores all of the ticks in the row.
linesArrayArray that stores all of the lines in the row.
subRowsTimelineRows[]Array that stores any sub-rows/sub-measures.
checkedBooleanFlag that will hide/show the row.

Methods

FunctionDescription
addBar(TimelineBar bar)Stores a TimelineBar in its array of bars. Autoupdates the time domain if configuration option is on.
addLine(TimelineBar line)Stores a TimelineBar in its array of lines. Autoupdates the time domain if configuration option is on.
addRow(TimelineRow row)Stores a TimelineRow in its array of sub-rows.
addTick(Date time, string image)Saves a tick which takes a Date and the url of the image to display. Autoupdates the time domain if configuration option is on.

TimelineBar

Properties

NameTypeDescription
startDateStarting time of the bar
endDateEnd time of the bar
fillstringThe fill color of the bar.
textstringThe text that is displayed inside the bar in the case of a phase bar.

Methods

FunctionDescription
addTime(int duration)Stores a TimelineBar in its array of bars. Autoupdates the time domain if configuration option is on.

Examples

Adding a row with a bar, line, and tick

$scope.timeline.addRow('Measure 1')
    .addBar($scope.timeline.createBar(new Date(2016, 8, 31, 10, 40), new Date(2016, 8, 31, 10, 50)))
    .addLine($scope.timeline.createLine(new Date(2016, 8, 31, 11), new Date(2016, 8, 31, 11, 15), 'red'))
    .addTick(new Date(2016, 8, 31, 11, 20), 'images/threatdestroyed.png');

Adding a sub-row with a bar to a row

row
    .addRow($scope.timeline.createSubRow('Sub measure 1')
        .addBar($scope.timeline.createBar(new Date(2016, 8, 31, 11), new Date(2016, 8, 31, 12), 'green')));

Listening to a rowHover event

$rootScope.$on('rowHover', function (e, args) {
    console.log(args.name, args.time);
});