vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2164 lines
87 KiB

Implementation of a week scale feature (#3009) * Add Gitter badge (#2179) * do not generate source-maps in distribution version * add 'dist' folder for deployment * added Badges * added codeclimate badge * added @Tooa to the support team * added badges from isitmaintained.com (#2517) * do not ignore dist and test folders in master * generated dist files for v4.18.0 * generated dist files for v4.18.1 * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * changed to v4.18.1-SNAPSHOT * chore(docs): general improvements (#2652) * removed NOTICE file * updated license date range to include 2017 * chore(docs): updated support team members * chore: updated dependencies and devDependencies (#2649) * Fixes instanceof Object statements for objects from other windows and iFrames. (#2631) * Replaces instanceof Object checks with typeof to prevent cross tab issues. * Adds missing space. * chore: removed google-analytics from all examples (#2670) * chore(docs): Add note that PRs should be submitted against the `develop` branch (#2623) Related to: https://github.com/almende/vis/pull/2618 Related to: https://github.com/almende/vis/pull/2620 * feat(timeline): Change setCustomTimeTitle title parameter to be a string or a function (#2611) * change setCustomTimeTitle title parameter, Now could be an string or a function * Fixed indent and spacing * feat(timeline): refactor tooltip to only use one dom-element (#2662) * feat(network): Allow for image nodes to have a selected or broken image (#2601) * feat(tests): run mocha tests in travis ci (#2687) * Added showX(YZ)Axis options to Graph3d (#2686) * Added showX(YZ)Axis to Graph3d * Added show_Axis options to docs and playground example * Resolved merge conflict * Added show_Axis options to docs and playground example * fix(build): use babel version compatible with webpack@1.14 (#2693) fixes #2685 * feat(docs): use babel preset2015 for custom builds (#2678) * add link to a mentioned example (#2709) * chore(lint): added support for eslint (#2695) * Trivial typo fix in how_to_help doc. (#2714) * fix(timeline): #2598 Flickering onUpdateTimeTooltip (#2702) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add animation to onUpdateTooltip * fix(timeline): #778 Tooltip does not work with background items in timeline (#2703) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Make items z-index default to 1 * Add initial tests for Timeline PointItem (#2716) * fix(timeline): #2679 TypeError: Cannot read property 'hasOwnProperty' of null (#2735) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix bug in item editable * feat(timeline): #2647 Dynamic rolling mode option (#2705) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add toggleRollingMode option * Update docs with toggleRollingMode option * fixes timestep next issue (#2732) * feat(timeline): added new locales for french and espanol (#2723) * Fix eslint problem on Travis. (#2744) * fix: Range.js "event" is undeclared (#2749) * fix(timeline): #2720 Problems with option editable (#2743) Clean up and centralise edit status for Timeline Items. * feat(network): Improve the performance of the network layout engine (#2729) * Improve the performance of the network layout engine Short-cut the execution of a number of methods in LayoutEngine to make them handle highly-connected graphs better. * Demonstrations of layouts of large networks * Added support to supply an end to bar charts to have them scale (#2760) * Added support to supply an X2 to bar charts to have them scale * Fixed graph2d stacking issue. It no longer takes into account hidden items * Changed x2 to end per recommendation and added this to the docs * Initial tests for timeline ItemSet. (#2750) Somewhat more complicated setup, associated with the need for a real window. * [Timeline] Modify redraw logic to treat scroll as needing restack. (#2774) This addresses #1982 and #1417. It possibly reduces performance, but correctness seems better. * fix(timeline): #2672 Item events original event (#2704) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix events returned from mouse events * Fix example * Rename censor to stringifyObject in example * [timeline] Update examples to use ISOString format. (#2791) Resolves #2790 * [timeline] Update serialization example to use ISOString dates. (#2789) Resolves #2696 * added github templates for issues and pull-requests (#2787) fixes #2418 * feat(timeline): Add item data as argument to the template function (#2799) * Fix regression introduced in #2743. (#2796) * Fix for issue #2536 (#2803) * Fix for issue #2536 * Adjusted documentation for fix. * Adjustments due to review * Grrrrr whitespace * Fixed Travis issue * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * Update to gitignore to reflect changes on remote * clean dist folder * Local gitignore update * Just a first example file for the week scale feature * Allowing sourcemap creation * Initial (non-functional) commit to ensure we insert code at the right places (check TODOs) * Functional, not bug-free version which works with locale aware week numbers. * Locale-aware implementation and simplified major labels to a full year * Trying to make the major labels show the correct start date * Working implementation of week numbers using localization. * removing development leftovers * Updated package.json * Reintagrate package.json from accidental deletion * Updates for package.json * Fixing package.json * Integrate the week numbers feature in the documentation. * Reverting local changes to .gitignore * Reverting local changes * Extending examples to cover the case when 1st day of week and 1st day of month align; Fixing display bug so that week numbers are not repeated in minorLabels * Putting the examples into a loop
7 years ago
Implementation of a week scale feature (#3009) * Add Gitter badge (#2179) * do not generate source-maps in distribution version * add 'dist' folder for deployment * added Badges * added codeclimate badge * added @Tooa to the support team * added badges from isitmaintained.com (#2517) * do not ignore dist and test folders in master * generated dist files for v4.18.0 * generated dist files for v4.18.1 * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * changed to v4.18.1-SNAPSHOT * chore(docs): general improvements (#2652) * removed NOTICE file * updated license date range to include 2017 * chore(docs): updated support team members * chore: updated dependencies and devDependencies (#2649) * Fixes instanceof Object statements for objects from other windows and iFrames. (#2631) * Replaces instanceof Object checks with typeof to prevent cross tab issues. * Adds missing space. * chore: removed google-analytics from all examples (#2670) * chore(docs): Add note that PRs should be submitted against the `develop` branch (#2623) Related to: https://github.com/almende/vis/pull/2618 Related to: https://github.com/almende/vis/pull/2620 * feat(timeline): Change setCustomTimeTitle title parameter to be a string or a function (#2611) * change setCustomTimeTitle title parameter, Now could be an string or a function * Fixed indent and spacing * feat(timeline): refactor tooltip to only use one dom-element (#2662) * feat(network): Allow for image nodes to have a selected or broken image (#2601) * feat(tests): run mocha tests in travis ci (#2687) * Added showX(YZ)Axis options to Graph3d (#2686) * Added showX(YZ)Axis to Graph3d * Added show_Axis options to docs and playground example * Resolved merge conflict * Added show_Axis options to docs and playground example * fix(build): use babel version compatible with webpack@1.14 (#2693) fixes #2685 * feat(docs): use babel preset2015 for custom builds (#2678) * add link to a mentioned example (#2709) * chore(lint): added support for eslint (#2695) * Trivial typo fix in how_to_help doc. (#2714) * fix(timeline): #2598 Flickering onUpdateTimeTooltip (#2702) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add animation to onUpdateTooltip * fix(timeline): #778 Tooltip does not work with background items in timeline (#2703) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Make items z-index default to 1 * Add initial tests for Timeline PointItem (#2716) * fix(timeline): #2679 TypeError: Cannot read property 'hasOwnProperty' of null (#2735) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix bug in item editable * feat(timeline): #2647 Dynamic rolling mode option (#2705) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add toggleRollingMode option * Update docs with toggleRollingMode option * fixes timestep next issue (#2732) * feat(timeline): added new locales for french and espanol (#2723) * Fix eslint problem on Travis. (#2744) * fix: Range.js "event" is undeclared (#2749) * fix(timeline): #2720 Problems with option editable (#2743) Clean up and centralise edit status for Timeline Items. * feat(network): Improve the performance of the network layout engine (#2729) * Improve the performance of the network layout engine Short-cut the execution of a number of methods in LayoutEngine to make them handle highly-connected graphs better. * Demonstrations of layouts of large networks * Added support to supply an end to bar charts to have them scale (#2760) * Added support to supply an X2 to bar charts to have them scale * Fixed graph2d stacking issue. It no longer takes into account hidden items * Changed x2 to end per recommendation and added this to the docs * Initial tests for timeline ItemSet. (#2750) Somewhat more complicated setup, associated with the need for a real window. * [Timeline] Modify redraw logic to treat scroll as needing restack. (#2774) This addresses #1982 and #1417. It possibly reduces performance, but correctness seems better. * fix(timeline): #2672 Item events original event (#2704) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix events returned from mouse events * Fix example * Rename censor to stringifyObject in example * [timeline] Update examples to use ISOString format. (#2791) Resolves #2790 * [timeline] Update serialization example to use ISOString dates. (#2789) Resolves #2696 * added github templates for issues and pull-requests (#2787) fixes #2418 * feat(timeline): Add item data as argument to the template function (#2799) * Fix regression introduced in #2743. (#2796) * Fix for issue #2536 (#2803) * Fix for issue #2536 * Adjusted documentation for fix. * Adjustments due to review * Grrrrr whitespace * Fixed Travis issue * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * Update to gitignore to reflect changes on remote * clean dist folder * Local gitignore update * Just a first example file for the week scale feature * Allowing sourcemap creation * Initial (non-functional) commit to ensure we insert code at the right places (check TODOs) * Functional, not bug-free version which works with locale aware week numbers. * Locale-aware implementation and simplified major labels to a full year * Trying to make the major labels show the correct start date * Working implementation of week numbers using localization. * removing development leftovers * Updated package.json * Reintagrate package.json from accidental deletion * Updates for package.json * Fixing package.json * Integrate the week numbers feature in the documentation. * Reverting local changes to .gitignore * Reverting local changes * Extending examples to cover the case when 1st day of week and 1st day of month align; Fixing display bug so that week numbers are not repeated in minorLabels * Putting the examples into a loop
7 years ago
Implementation of a week scale feature (#3009) * Add Gitter badge (#2179) * do not generate source-maps in distribution version * add 'dist' folder for deployment * added Badges * added codeclimate badge * added @Tooa to the support team * added badges from isitmaintained.com (#2517) * do not ignore dist and test folders in master * generated dist files for v4.18.0 * generated dist files for v4.18.1 * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * changed to v4.18.1-SNAPSHOT * chore(docs): general improvements (#2652) * removed NOTICE file * updated license date range to include 2017 * chore(docs): updated support team members * chore: updated dependencies and devDependencies (#2649) * Fixes instanceof Object statements for objects from other windows and iFrames. (#2631) * Replaces instanceof Object checks with typeof to prevent cross tab issues. * Adds missing space. * chore: removed google-analytics from all examples (#2670) * chore(docs): Add note that PRs should be submitted against the `develop` branch (#2623) Related to: https://github.com/almende/vis/pull/2618 Related to: https://github.com/almende/vis/pull/2620 * feat(timeline): Change setCustomTimeTitle title parameter to be a string or a function (#2611) * change setCustomTimeTitle title parameter, Now could be an string or a function * Fixed indent and spacing * feat(timeline): refactor tooltip to only use one dom-element (#2662) * feat(network): Allow for image nodes to have a selected or broken image (#2601) * feat(tests): run mocha tests in travis ci (#2687) * Added showX(YZ)Axis options to Graph3d (#2686) * Added showX(YZ)Axis to Graph3d * Added show_Axis options to docs and playground example * Resolved merge conflict * Added show_Axis options to docs and playground example * fix(build): use babel version compatible with webpack@1.14 (#2693) fixes #2685 * feat(docs): use babel preset2015 for custom builds (#2678) * add link to a mentioned example (#2709) * chore(lint): added support for eslint (#2695) * Trivial typo fix in how_to_help doc. (#2714) * fix(timeline): #2598 Flickering onUpdateTimeTooltip (#2702) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add animation to onUpdateTooltip * fix(timeline): #778 Tooltip does not work with background items in timeline (#2703) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Make items z-index default to 1 * Add initial tests for Timeline PointItem (#2716) * fix(timeline): #2679 TypeError: Cannot read property 'hasOwnProperty' of null (#2735) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix bug in item editable * feat(timeline): #2647 Dynamic rolling mode option (#2705) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add toggleRollingMode option * Update docs with toggleRollingMode option * fixes timestep next issue (#2732) * feat(timeline): added new locales for french and espanol (#2723) * Fix eslint problem on Travis. (#2744) * fix: Range.js "event" is undeclared (#2749) * fix(timeline): #2720 Problems with option editable (#2743) Clean up and centralise edit status for Timeline Items. * feat(network): Improve the performance of the network layout engine (#2729) * Improve the performance of the network layout engine Short-cut the execution of a number of methods in LayoutEngine to make them handle highly-connected graphs better. * Demonstrations of layouts of large networks * Added support to supply an end to bar charts to have them scale (#2760) * Added support to supply an X2 to bar charts to have them scale * Fixed graph2d stacking issue. It no longer takes into account hidden items * Changed x2 to end per recommendation and added this to the docs * Initial tests for timeline ItemSet. (#2750) Somewhat more complicated setup, associated with the need for a real window. * [Timeline] Modify redraw logic to treat scroll as needing restack. (#2774) This addresses #1982 and #1417. It possibly reduces performance, but correctness seems better. * fix(timeline): #2672 Item events original event (#2704) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix events returned from mouse events * Fix example * Rename censor to stringifyObject in example * [timeline] Update examples to use ISOString format. (#2791) Resolves #2790 * [timeline] Update serialization example to use ISOString dates. (#2789) Resolves #2696 * added github templates for issues and pull-requests (#2787) fixes #2418 * feat(timeline): Add item data as argument to the template function (#2799) * Fix regression introduced in #2743. (#2796) * Fix for issue #2536 (#2803) * Fix for issue #2536 * Adjusted documentation for fix. * Adjustments due to review * Grrrrr whitespace * Fixed Travis issue * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * Update to gitignore to reflect changes on remote * clean dist folder * Local gitignore update * Just a first example file for the week scale feature * Allowing sourcemap creation * Initial (non-functional) commit to ensure we insert code at the right places (check TODOs) * Functional, not bug-free version which works with locale aware week numbers. * Locale-aware implementation and simplified major labels to a full year * Trying to make the major labels show the correct start date * Working implementation of week numbers using localization. * removing development leftovers * Updated package.json * Reintagrate package.json from accidental deletion * Updates for package.json * Fixing package.json * Integrate the week numbers feature in the documentation. * Reverting local changes to .gitignore * Reverting local changes * Extending examples to cover the case when 1st day of week and 1st day of month align; Fixing display bug so that week numbers are not repeated in minorLabels * Putting the examples into a loop
7 years ago
Implementation of a week scale feature (#3009) * Add Gitter badge (#2179) * do not generate source-maps in distribution version * add 'dist' folder for deployment * added Badges * added codeclimate badge * added @Tooa to the support team * added badges from isitmaintained.com (#2517) * do not ignore dist and test folders in master * generated dist files for v4.18.0 * generated dist files for v4.18.1 * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * changed to v4.18.1-SNAPSHOT * chore(docs): general improvements (#2652) * removed NOTICE file * updated license date range to include 2017 * chore(docs): updated support team members * chore: updated dependencies and devDependencies (#2649) * Fixes instanceof Object statements for objects from other windows and iFrames. (#2631) * Replaces instanceof Object checks with typeof to prevent cross tab issues. * Adds missing space. * chore: removed google-analytics from all examples (#2670) * chore(docs): Add note that PRs should be submitted against the `develop` branch (#2623) Related to: https://github.com/almende/vis/pull/2618 Related to: https://github.com/almende/vis/pull/2620 * feat(timeline): Change setCustomTimeTitle title parameter to be a string or a function (#2611) * change setCustomTimeTitle title parameter, Now could be an string or a function * Fixed indent and spacing * feat(timeline): refactor tooltip to only use one dom-element (#2662) * feat(network): Allow for image nodes to have a selected or broken image (#2601) * feat(tests): run mocha tests in travis ci (#2687) * Added showX(YZ)Axis options to Graph3d (#2686) * Added showX(YZ)Axis to Graph3d * Added show_Axis options to docs and playground example * Resolved merge conflict * Added show_Axis options to docs and playground example * fix(build): use babel version compatible with webpack@1.14 (#2693) fixes #2685 * feat(docs): use babel preset2015 for custom builds (#2678) * add link to a mentioned example (#2709) * chore(lint): added support for eslint (#2695) * Trivial typo fix in how_to_help doc. (#2714) * fix(timeline): #2598 Flickering onUpdateTimeTooltip (#2702) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add animation to onUpdateTooltip * fix(timeline): #778 Tooltip does not work with background items in timeline (#2703) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Make items z-index default to 1 * Add initial tests for Timeline PointItem (#2716) * fix(timeline): #2679 TypeError: Cannot read property 'hasOwnProperty' of null (#2735) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix bug in item editable * feat(timeline): #2647 Dynamic rolling mode option (#2705) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add toggleRollingMode option * Update docs with toggleRollingMode option * fixes timestep next issue (#2732) * feat(timeline): added new locales for french and espanol (#2723) * Fix eslint problem on Travis. (#2744) * fix: Range.js "event" is undeclared (#2749) * fix(timeline): #2720 Problems with option editable (#2743) Clean up and centralise edit status for Timeline Items. * feat(network): Improve the performance of the network layout engine (#2729) * Improve the performance of the network layout engine Short-cut the execution of a number of methods in LayoutEngine to make them handle highly-connected graphs better. * Demonstrations of layouts of large networks * Added support to supply an end to bar charts to have them scale (#2760) * Added support to supply an X2 to bar charts to have them scale * Fixed graph2d stacking issue. It no longer takes into account hidden items * Changed x2 to end per recommendation and added this to the docs * Initial tests for timeline ItemSet. (#2750) Somewhat more complicated setup, associated with the need for a real window. * [Timeline] Modify redraw logic to treat scroll as needing restack. (#2774) This addresses #1982 and #1417. It possibly reduces performance, but correctness seems better. * fix(timeline): #2672 Item events original event (#2704) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix events returned from mouse events * Fix example * Rename censor to stringifyObject in example * [timeline] Update examples to use ISOString format. (#2791) Resolves #2790 * [timeline] Update serialization example to use ISOString dates. (#2789) Resolves #2696 * added github templates for issues and pull-requests (#2787) fixes #2418 * feat(timeline): Add item data as argument to the template function (#2799) * Fix regression introduced in #2743. (#2796) * Fix for issue #2536 (#2803) * Fix for issue #2536 * Adjusted documentation for fix. * Adjustments due to review * Grrrrr whitespace * Fixed Travis issue * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * Update to gitignore to reflect changes on remote * clean dist folder * Local gitignore update * Just a first example file for the week scale feature * Allowing sourcemap creation * Initial (non-functional) commit to ensure we insert code at the right places (check TODOs) * Functional, not bug-free version which works with locale aware week numbers. * Locale-aware implementation and simplified major labels to a full year * Trying to make the major labels show the correct start date * Working implementation of week numbers using localization. * removing development leftovers * Updated package.json * Reintagrate package.json from accidental deletion * Updates for package.json * Fixing package.json * Integrate the week numbers feature in the documentation. * Reverting local changes to .gitignore * Reverting local changes * Extending examples to cover the case when 1st day of week and 1st day of month align; Fixing display bug so that week numbers are not repeated in minorLabels * Putting the examples into a loop
7 years ago
Implementation of a week scale feature (#3009) * Add Gitter badge (#2179) * do not generate source-maps in distribution version * add 'dist' folder for deployment * added Badges * added codeclimate badge * added @Tooa to the support team * added badges from isitmaintained.com (#2517) * do not ignore dist and test folders in master * generated dist files for v4.18.0 * generated dist files for v4.18.1 * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * changed to v4.18.1-SNAPSHOT * chore(docs): general improvements (#2652) * removed NOTICE file * updated license date range to include 2017 * chore(docs): updated support team members * chore: updated dependencies and devDependencies (#2649) * Fixes instanceof Object statements for objects from other windows and iFrames. (#2631) * Replaces instanceof Object checks with typeof to prevent cross tab issues. * Adds missing space. * chore: removed google-analytics from all examples (#2670) * chore(docs): Add note that PRs should be submitted against the `develop` branch (#2623) Related to: https://github.com/almende/vis/pull/2618 Related to: https://github.com/almende/vis/pull/2620 * feat(timeline): Change setCustomTimeTitle title parameter to be a string or a function (#2611) * change setCustomTimeTitle title parameter, Now could be an string or a function * Fixed indent and spacing * feat(timeline): refactor tooltip to only use one dom-element (#2662) * feat(network): Allow for image nodes to have a selected or broken image (#2601) * feat(tests): run mocha tests in travis ci (#2687) * Added showX(YZ)Axis options to Graph3d (#2686) * Added showX(YZ)Axis to Graph3d * Added show_Axis options to docs and playground example * Resolved merge conflict * Added show_Axis options to docs and playground example * fix(build): use babel version compatible with webpack@1.14 (#2693) fixes #2685 * feat(docs): use babel preset2015 for custom builds (#2678) * add link to a mentioned example (#2709) * chore(lint): added support for eslint (#2695) * Trivial typo fix in how_to_help doc. (#2714) * fix(timeline): #2598 Flickering onUpdateTimeTooltip (#2702) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add animation to onUpdateTooltip * fix(timeline): #778 Tooltip does not work with background items in timeline (#2703) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Make items z-index default to 1 * Add initial tests for Timeline PointItem (#2716) * fix(timeline): #2679 TypeError: Cannot read property 'hasOwnProperty' of null (#2735) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix bug in item editable * feat(timeline): #2647 Dynamic rolling mode option (#2705) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add toggleRollingMode option * Update docs with toggleRollingMode option * fixes timestep next issue (#2732) * feat(timeline): added new locales for french and espanol (#2723) * Fix eslint problem on Travis. (#2744) * fix: Range.js "event" is undeclared (#2749) * fix(timeline): #2720 Problems with option editable (#2743) Clean up and centralise edit status for Timeline Items. * feat(network): Improve the performance of the network layout engine (#2729) * Improve the performance of the network layout engine Short-cut the execution of a number of methods in LayoutEngine to make them handle highly-connected graphs better. * Demonstrations of layouts of large networks * Added support to supply an end to bar charts to have them scale (#2760) * Added support to supply an X2 to bar charts to have them scale * Fixed graph2d stacking issue. It no longer takes into account hidden items * Changed x2 to end per recommendation and added this to the docs * Initial tests for timeline ItemSet. (#2750) Somewhat more complicated setup, associated with the need for a real window. * [Timeline] Modify redraw logic to treat scroll as needing restack. (#2774) This addresses #1982 and #1417. It possibly reduces performance, but correctness seems better. * fix(timeline): #2672 Item events original event (#2704) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix events returned from mouse events * Fix example * Rename censor to stringifyObject in example * [timeline] Update examples to use ISOString format. (#2791) Resolves #2790 * [timeline] Update serialization example to use ISOString dates. (#2789) Resolves #2696 * added github templates for issues and pull-requests (#2787) fixes #2418 * feat(timeline): Add item data as argument to the template function (#2799) * Fix regression introduced in #2743. (#2796) * Fix for issue #2536 (#2803) * Fix for issue #2536 * Adjusted documentation for fix. * Adjustments due to review * Grrrrr whitespace * Fixed Travis issue * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * Update to gitignore to reflect changes on remote * clean dist folder * Local gitignore update * Just a first example file for the week scale feature * Allowing sourcemap creation * Initial (non-functional) commit to ensure we insert code at the right places (check TODOs) * Functional, not bug-free version which works with locale aware week numbers. * Locale-aware implementation and simplified major labels to a full year * Trying to make the major labels show the correct start date * Working implementation of week numbers using localization. * removing development leftovers * Updated package.json * Reintagrate package.json from accidental deletion * Updates for package.json * Fixing package.json * Integrate the week numbers feature in the documentation. * Reverting local changes to .gitignore * Reverting local changes * Extending examples to cover the case when 1st day of week and 1st day of month align; Fixing display bug so that week numbers are not repeated in minorLabels * Putting the examples into a loop
7 years ago
Implementation of a week scale feature (#3009) * Add Gitter badge (#2179) * do not generate source-maps in distribution version * add 'dist' folder for deployment * added Badges * added codeclimate badge * added @Tooa to the support team * added badges from isitmaintained.com (#2517) * do not ignore dist and test folders in master * generated dist files for v4.18.0 * generated dist files for v4.18.1 * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * changed to v4.18.1-SNAPSHOT * chore(docs): general improvements (#2652) * removed NOTICE file * updated license date range to include 2017 * chore(docs): updated support team members * chore: updated dependencies and devDependencies (#2649) * Fixes instanceof Object statements for objects from other windows and iFrames. (#2631) * Replaces instanceof Object checks with typeof to prevent cross tab issues. * Adds missing space. * chore: removed google-analytics from all examples (#2670) * chore(docs): Add note that PRs should be submitted against the `develop` branch (#2623) Related to: https://github.com/almende/vis/pull/2618 Related to: https://github.com/almende/vis/pull/2620 * feat(timeline): Change setCustomTimeTitle title parameter to be a string or a function (#2611) * change setCustomTimeTitle title parameter, Now could be an string or a function * Fixed indent and spacing * feat(timeline): refactor tooltip to only use one dom-element (#2662) * feat(network): Allow for image nodes to have a selected or broken image (#2601) * feat(tests): run mocha tests in travis ci (#2687) * Added showX(YZ)Axis options to Graph3d (#2686) * Added showX(YZ)Axis to Graph3d * Added show_Axis options to docs and playground example * Resolved merge conflict * Added show_Axis options to docs and playground example * fix(build): use babel version compatible with webpack@1.14 (#2693) fixes #2685 * feat(docs): use babel preset2015 for custom builds (#2678) * add link to a mentioned example (#2709) * chore(lint): added support for eslint (#2695) * Trivial typo fix in how_to_help doc. (#2714) * fix(timeline): #2598 Flickering onUpdateTimeTooltip (#2702) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add animation to onUpdateTooltip * fix(timeline): #778 Tooltip does not work with background items in timeline (#2703) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Make items z-index default to 1 * Add initial tests for Timeline PointItem (#2716) * fix(timeline): #2679 TypeError: Cannot read property 'hasOwnProperty' of null (#2735) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix bug in item editable * feat(timeline): #2647 Dynamic rolling mode option (#2705) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add toggleRollingMode option * Update docs with toggleRollingMode option * fixes timestep next issue (#2732) * feat(timeline): added new locales for french and espanol (#2723) * Fix eslint problem on Travis. (#2744) * fix: Range.js "event" is undeclared (#2749) * fix(timeline): #2720 Problems with option editable (#2743) Clean up and centralise edit status for Timeline Items. * feat(network): Improve the performance of the network layout engine (#2729) * Improve the performance of the network layout engine Short-cut the execution of a number of methods in LayoutEngine to make them handle highly-connected graphs better. * Demonstrations of layouts of large networks * Added support to supply an end to bar charts to have them scale (#2760) * Added support to supply an X2 to bar charts to have them scale * Fixed graph2d stacking issue. It no longer takes into account hidden items * Changed x2 to end per recommendation and added this to the docs * Initial tests for timeline ItemSet. (#2750) Somewhat more complicated setup, associated with the need for a real window. * [Timeline] Modify redraw logic to treat scroll as needing restack. (#2774) This addresses #1982 and #1417. It possibly reduces performance, but correctness seems better. * fix(timeline): #2672 Item events original event (#2704) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix events returned from mouse events * Fix example * Rename censor to stringifyObject in example * [timeline] Update examples to use ISOString format. (#2791) Resolves #2790 * [timeline] Update serialization example to use ISOString dates. (#2789) Resolves #2696 * added github templates for issues and pull-requests (#2787) fixes #2418 * feat(timeline): Add item data as argument to the template function (#2799) * Fix regression introduced in #2743. (#2796) * Fix for issue #2536 (#2803) * Fix for issue #2536 * Adjusted documentation for fix. * Adjustments due to review * Grrrrr whitespace * Fixed Travis issue * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * Update to gitignore to reflect changes on remote * clean dist folder * Local gitignore update * Just a first example file for the week scale feature * Allowing sourcemap creation * Initial (non-functional) commit to ensure we insert code at the right places (check TODOs) * Functional, not bug-free version which works with locale aware week numbers. * Locale-aware implementation and simplified major labels to a full year * Trying to make the major labels show the correct start date * Working implementation of week numbers using localization. * removing development leftovers * Updated package.json * Reintagrate package.json from accidental deletion * Updates for package.json * Fixing package.json * Integrate the week numbers feature in the documentation. * Reverting local changes to .gitignore * Reverting local changes * Extending examples to cover the case when 1st day of week and 1st day of month align; Fixing display bug so that week numbers are not repeated in minorLabels * Putting the examples into a loop
7 years ago
Implementation of a week scale feature (#3009) * Add Gitter badge (#2179) * do not generate source-maps in distribution version * add 'dist' folder for deployment * added Badges * added codeclimate badge * added @Tooa to the support team * added badges from isitmaintained.com (#2517) * do not ignore dist and test folders in master * generated dist files for v4.18.0 * generated dist files for v4.18.1 * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * changed to v4.18.1-SNAPSHOT * chore(docs): general improvements (#2652) * removed NOTICE file * updated license date range to include 2017 * chore(docs): updated support team members * chore: updated dependencies and devDependencies (#2649) * Fixes instanceof Object statements for objects from other windows and iFrames. (#2631) * Replaces instanceof Object checks with typeof to prevent cross tab issues. * Adds missing space. * chore: removed google-analytics from all examples (#2670) * chore(docs): Add note that PRs should be submitted against the `develop` branch (#2623) Related to: https://github.com/almende/vis/pull/2618 Related to: https://github.com/almende/vis/pull/2620 * feat(timeline): Change setCustomTimeTitle title parameter to be a string or a function (#2611) * change setCustomTimeTitle title parameter, Now could be an string or a function * Fixed indent and spacing * feat(timeline): refactor tooltip to only use one dom-element (#2662) * feat(network): Allow for image nodes to have a selected or broken image (#2601) * feat(tests): run mocha tests in travis ci (#2687) * Added showX(YZ)Axis options to Graph3d (#2686) * Added showX(YZ)Axis to Graph3d * Added show_Axis options to docs and playground example * Resolved merge conflict * Added show_Axis options to docs and playground example * fix(build): use babel version compatible with webpack@1.14 (#2693) fixes #2685 * feat(docs): use babel preset2015 for custom builds (#2678) * add link to a mentioned example (#2709) * chore(lint): added support for eslint (#2695) * Trivial typo fix in how_to_help doc. (#2714) * fix(timeline): #2598 Flickering onUpdateTimeTooltip (#2702) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add animation to onUpdateTooltip * fix(timeline): #778 Tooltip does not work with background items in timeline (#2703) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Make items z-index default to 1 * Add initial tests for Timeline PointItem (#2716) * fix(timeline): #2679 TypeError: Cannot read property 'hasOwnProperty' of null (#2735) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix bug in item editable * feat(timeline): #2647 Dynamic rolling mode option (#2705) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add toggleRollingMode option * Update docs with toggleRollingMode option * fixes timestep next issue (#2732) * feat(timeline): added new locales for french and espanol (#2723) * Fix eslint problem on Travis. (#2744) * fix: Range.js "event" is undeclared (#2749) * fix(timeline): #2720 Problems with option editable (#2743) Clean up and centralise edit status for Timeline Items. * feat(network): Improve the performance of the network layout engine (#2729) * Improve the performance of the network layout engine Short-cut the execution of a number of methods in LayoutEngine to make them handle highly-connected graphs better. * Demonstrations of layouts of large networks * Added support to supply an end to bar charts to have them scale (#2760) * Added support to supply an X2 to bar charts to have them scale * Fixed graph2d stacking issue. It no longer takes into account hidden items * Changed x2 to end per recommendation and added this to the docs * Initial tests for timeline ItemSet. (#2750) Somewhat more complicated setup, associated with the need for a real window. * [Timeline] Modify redraw logic to treat scroll as needing restack. (#2774) This addresses #1982 and #1417. It possibly reduces performance, but correctness seems better. * fix(timeline): #2672 Item events original event (#2704) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Fix events returned from mouse events * Fix example * Rename censor to stringifyObject in example * [timeline] Update examples to use ISOString format. (#2791) Resolves #2790 * [timeline] Update serialization example to use ISOString dates. (#2789) Resolves #2696 * added github templates for issues and pull-requests (#2787) fixes #2418 * feat(timeline): Add item data as argument to the template function (#2799) * Fix regression introduced in #2743. (#2796) * Fix for issue #2536 (#2803) * Fix for issue #2536 * Adjusted documentation for fix. * Adjustments due to review * Grrrrr whitespace * Fixed Travis issue * Cheap fix for bug #2795 * Update to PR #2826 to use newline format * Update to gitignore to reflect changes on remote * clean dist folder * Local gitignore update * Just a first example file for the week scale feature * Allowing sourcemap creation * Initial (non-functional) commit to ensure we insert code at the right places (check TODOs) * Functional, not bug-free version which works with locale aware week numbers. * Locale-aware implementation and simplified major labels to a full year * Trying to make the major labels show the correct start date * Working implementation of week numbers using localization. * removing development leftovers * Updated package.json * Reintagrate package.json from accidental deletion * Updates for package.json * Fixing package.json * Integrate the week numbers feature in the documentation. * Reverting local changes to .gitignore * Reverting local changes * Extending examples to cover the case when 1st day of week and 1st day of month align; Fixing display bug so that week numbers are not repeated in minorLabels * Putting the examples into a loop
7 years ago
  1. <?js
  2. var self = this;
  3. ?>
  4. <!DOCTYPE html>
  5. <html lang="en"><head>
  6. <meta charset="utf-8">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <meta name="description" content="">
  10. <meta name="author" content="">
  11. <link rel="icon" HREF="favicon.ico">
  12. <title>timeline - vis.js - A dynamic, browser based visualization library.</title>
  13. <!-- Bootstrap core CSS -->
  14. <link href="../css/bootstrap.css" rel="stylesheet">
  15. <!-- Tipue vendor css -->
  16. <link href="../css/tipuesearch.css" rel="stylesheet">
  17. <link href="../css/style.css" rel="stylesheet">
  18. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  19. <!--[if lt IE 9]>
  20. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  21. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  22. <![endif]-->
  23. <link href="../css/prettify.css" type="text/css" rel="stylesheet"/>
  24. <script type="text/javascript" src="../js/googleAnalytics.js"></script>
  25. <script type="text/javascript" src="../js/prettify/prettify.js"></script>
  26. <script src="../js/smooth-scroll.min.js"></script>
  27. <script language="JavaScript">
  28. smoothScroll.init();
  29. </script>
  30. <!-- Tipue vendor css -->
  31. <link href="../css/tipuesearch.css" rel="stylesheet">
  32. <!-- Tipue vendor css -->
  33. <link href="../css/tipuesearch.css" rel="stylesheet">
  34. <script type="text/javascript" src="../js/toggleTable.js"></script>
  35. </head>
  36. <body onload="prettyPrint();">
  37. <?js= self.partial('tmpl/navbar.tmpl') ?>
  38. <div class="container full">
  39. <h1>Timeline</h1>
  40. <h2 id="Overview">Overview</h2>
  41. <p>
  42. The Timeline is an interactive visualization chart to visualize data in time.
  43. The data items can take place on a single date, or have a start and end date (a range).
  44. You can freely move and zoom in the timeline by dragging and scrolling in the
  45. Timeline. Items can be created, edited, and deleted in the timeline.
  46. The time scale on the axis is adjusted automatically, and supports scales ranging
  47. from milliseconds to years.
  48. </p>
  49. <p>
  50. Timeline uses regular HTML DOM to render the timeline and items put on the
  51. timeline. This allows for flexible customization using css styling.
  52. </p>
  53. <h2 id="Contents">Contents</h2>
  54. <ul>
  55. <li><a href="#Overview">Overview</a></li>
  56. <li><a href="#Example">Example</a></li>
  57. <li><a href="#Loading">Loading</a></li>
  58. <li><a href="#Data_Format">Data Format</a>
  59. <ul>
  60. <li><a href="#items">Items</a></li>
  61. <li><a href="#groups">Groups</a></li>
  62. </ul>
  63. </li>
  64. <li><a href="#Configuration_Options">Configuration Options</a></li>
  65. <li><a href="#Methods">Methods</a></li>
  66. <li><a href="#Events">Events</a></li>
  67. <li><a href="#Editing_Items">Editing Items</a></li>
  68. <li><a href="#Templates">Templates</a></li>
  69. <li><a href="#Localization">Localization</a></li>
  70. <li><a href="#Time_zone">Time zone</a></li>
  71. <li><a href="#Styles">Styles</a></li>
  72. </ul>
  73. <h2 id="Example">Example</h2>
  74. <p>
  75. The following code shows how to create a Timeline and provide it with data.
  76. More examples can be found in the <a href="../../timeline_examples.html">timeline examples</a> page.
  77. </p>
  78. <pre class="prettyprint lang-html">&lt;!DOCTYPE HTML&gt;
  79. &lt;html&gt;
  80. &lt;head&gt;
  81. &lt;title&gt;Timeline | Basic demo&lt;/title&gt;
  82. &lt;style type="text/css"&gt;
  83. body, html {
  84. font-family: sans-serif;
  85. }
  86. &lt;/style&gt;
  87. &lt;script src="../../dist/vis.js"&gt;&lt;/script&gt;
  88. &lt;link href="../../dist/vis.css" rel="stylesheet" type="text/css" /&gt;
  89. &lt;/head&gt;
  90. &lt;body&gt;
  91. &lt;div id="visualization"&gt;&lt;/div&gt;
  92. &lt;script type="text/javascript"&gt;
  93. // DOM element where the Timeline will be attached
  94. var container = document.getElementById('visualization');
  95. // Create a DataSet (allows two way data-binding)
  96. var items = new vis.DataSet([
  97. {id: 1, content: 'item 1', start: '2013-04-20'},
  98. {id: 2, content: 'item 2', start: '2013-04-14'},
  99. {id: 3, content: 'item 3', start: '2013-04-18'},
  100. {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
  101. {id: 5, content: 'item 5', start: '2013-04-25'},
  102. {id: 6, content: 'item 6', start: '2013-04-27'}
  103. ]);
  104. // Configuration for the Timeline
  105. var options = {};
  106. // Create a Timeline
  107. var timeline = new vis.Timeline(container, items, options);
  108. &lt;/script&gt;
  109. &lt;/body&gt;
  110. &lt;/html&gt;
  111. </pre>
  112. <h2 id="Loading">Loading</h2>
  113. <p>
  114. Install or download the <a href="http://visjs.org" target="_blank">vis.js</a> library
  115. in a subfolder of your project. Include the library's script and css files in the
  116. head of your html code:
  117. </p>
  118. <pre class="prettyprint lang-html">
  119. &lt;script src="vis/dist/vis.js"&gt;&lt;/script&gt;
  120. &lt;link href="vis/dist/vis.css" rel="stylesheet" type="text/css" /&gt;
  121. </pre>
  122. The constructor of the Timeline is <code>vis.Timeline</code>
  123. <pre class="prettyprint lang-js">var timeline = new vis.Timeline(container, items, options);</pre>
  124. or when using groups:
  125. <pre class="prettyprint lang-js">var timeline = new vis.Timeline(container, items, groups, options);</pre>
  126. The constructor accepts four parameters:
  127. <ul>
  128. <li>
  129. <code>container</code> is the DOM element in which to create the timeline.
  130. </li>
  131. <li>
  132. <code>items</code> is an Array containing items. The properties of an
  133. item are described in section <a href="#Data_Format">Data Format, items</a>.
  134. </li><li>
  135. <code>groups</code> is an Array containing groups. The properties of a
  136. group are described in section <a href="#groups">Data Format, groups</a>.
  137. </li>
  138. <li>
  139. <code>options</code> is an optional Object containing a name-value map
  140. with options. Options can also be set using the method
  141. <code>setOptions</code>.
  142. </li>
  143. </ul>
  144. <h2 id="Data_Format">Data Format</h2>
  145. <p>
  146. The timeline can be provided with two types of data:
  147. </p>
  148. <ul>
  149. <li><a href="#items">Items</a> containing a set of items to be displayed in time.</li>
  150. <li><a href="#groups">Groups</a> containing a set of groups used to group items
  151. together.</li>
  152. </ul>
  153. <h3 id="items">Items</h3>
  154. <p>
  155. For items, the Timeline accepts an Array, a DataSet (offering 2 way data binding),
  156. or a DataView (offering 1 way data binding).
  157. Items are regular objects and can contain the properties <code>start</code>,
  158. <code>end</code> (optional), <code>content</code>,
  159. <code>group</code> (optional), <code>className</code> (optional),
  160. <code>editable</code> (optional), and <code>style</code> (optional).
  161. </p>
  162. <p>
  163. A DataSet is constructed as:
  164. </p>
  165. <pre class="prettyprint lang-js">
  166. var items = new vis.DataSet([
  167. {
  168. start: new Date(2010, 7, 15),
  169. end: new Date(2010, 8, 2), // end is optional
  170. content: 'Trajectory A'
  171. // Optional: fields 'id', 'type', 'group', 'className', 'style'
  172. }
  173. // more items...
  174. ]);
  175. </pre>
  176. <p>
  177. The item properties are defined as:
  178. </p>
  179. <table class="properties" id="itemOptionTable">
  180. <tr>
  181. <th>Name</th>
  182. <th>Type</th>
  183. <th>Required</th>
  184. <th>Description</th>
  185. </tr>
  186. <tr>
  187. <td>className</td>
  188. <td>String</td>
  189. <td>no</td>
  190. <td>This field is optional. A className can be used to give items
  191. an individual css style. For example, when an item has className
  192. 'red', one can define a css style like:
  193. <pre class="prettyprint lang-css">
  194. .vis-item.red {
  195. color: white;
  196. background-color: red;
  197. border-color: darkred;
  198. }</pre>
  199. More details on how to style items can be found in the section
  200. <a href="#Styles">Styles</a>.
  201. </td>
  202. </tr>
  203. <tr>
  204. <td>align</td>
  205. <td>String</td>
  206. <td>no</td>
  207. <td>This field is optional. If set this overrides the global <code>align</code> configuration option for this item.
  208. </td>
  209. </tr>
  210. <tr>
  211. <td>content</td>
  212. <td>String</td>
  213. <td>yes</td>
  214. <td>The contents of the item. This can be plain text or html code.</td>
  215. </tr>
  216. <tr>
  217. <td>end</td>
  218. <td>Date or number or string or Moment</td>
  219. <td>no</td>
  220. <td>The end date of the item. The end date is optional, and can be left <code>null</code>.
  221. If end date is provided, the item is displayed as a range.
  222. If not, the item is displayed as a box.</td>
  223. </tr>
  224. <tr>
  225. <td>group</td>
  226. <td>any type</td>
  227. <td>no</td>
  228. <td>This field is optional. When the group column is provided,
  229. all items with the same group are placed on one line.
  230. A vertical axis is displayed showing the groups.
  231. Grouping items can be useful for example when showing availability of multiple
  232. people, rooms, or other resources next to each other.<br>
  233. </td>
  234. </tr>
  235. <tr>
  236. <td>id</td>
  237. <td>String or Number</td>
  238. <td>no</td>
  239. <td>An id for the item. Using an id is not required but highly
  240. recommended. An id is needed when dynamically adding, updating,
  241. and removing items in a DataSet.</td>
  242. </tr>
  243. <tr>
  244. <td>start</td>
  245. <td>Date or number or string or Moment</td>
  246. <td>yes</td>
  247. <td>The start date of the item, for example <code>new Date(2010,9,23)</code>.</td>
  248. </tr>
  249. <tr>
  250. <td>style</td>
  251. <td>String</td>
  252. <td>no</td>
  253. <td>
  254. A css text string to apply custom styling for an individual item, for
  255. example <code>"color: red; background-color: pink;"</code>.
  256. </td>
  257. </tr>
  258. <tr>
  259. <td>subgroup</td>
  260. <td>String or Number</td>
  261. <td>none</td>
  262. <td>The id of a subgroup.
  263. Groups all items within a group per subgroup, and positions them on the
  264. same height instead of staking them on top of each other. can be ordered
  265. by specifying the option <code>subgroupOrder</code> of a group.
  266. </td>
  267. </tr>
  268. <tr>
  269. <td>title</td>
  270. <td>String</td>
  271. <td>none</td>
  272. <td>Add a title for the item, displayed when holding the mouse on the item.
  273. The title can be an HTML element or a string containing plain text or HTML.
  274. </td>
  275. </tr>
  276. <tr>
  277. <td>type</td>
  278. <td>String</td>
  279. <td>no</td>
  280. <td>The type of the item. Can be 'box' (default), 'point', 'range', or 'background'.
  281. Types 'box' and 'point' need a start date, the types 'range' and 'background' needs both a start and end date.
  282. </td>
  283. </tr>
  284. <tr>
  285. <td>limitSize</td>
  286. <td>Boolean</td>
  287. <td>no</td>
  288. <td>Some browsers cannot handle very large DIVs so by default range DIVs can be truncated outside the visible area.
  289. Setting this to <code>false</code> will cause the creation of full-size DIVs.
  290. </td>
  291. </tr>
  292. <tr class='toggle collapsible' onclick="toggleTable('itemOptionTable', 'itemEditable', this);">
  293. <td><span parent="itemEditable" class="right-caret"></span> editable</td>
  294. <td>Boolean or Object</td>
  295. <td>no</td>
  296. <td>Override the editable option of the timeline for a specific item (assuming <code>timeline.editable.overrideItems</code> is false).</td>
  297. </tr>
  298. <tr parent="itemEditable" class="hidden">
  299. <td class="indent">editable.remove</td>
  300. <td>boolean</td>
  301. <td>no</td>
  302. <td>If true, item can be deleted by first selecting it, and then clicking the delete button on the top right of the item. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  303. </tr>
  304. <tr parent="itemEditable" class="hidden">
  305. <td class="indent">editable.updateGroup</td>
  306. <td>boolean</td>
  307. <td>no</td>
  308. <td>If true, item can be dragged from one group to another. Only applicable when the Timeline has groups. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  309. </tr>
  310. <tr parent="itemEditable" class="hidden">
  311. <td class="indent">editable.updateTime</td>
  312. <td>boolean</td>
  313. <td>no</td>
  314. <td>If true, items can be dragged to another moment in time. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  315. </tr>
  316. </table>
  317. <h3 id="groups">Groups</h3>
  318. <p>
  319. For the items, groups can be an Array, a DataSet (offering 2 way data binding),
  320. or a DataView (offering 1 way data binding).
  321. Using groups, items can be grouped together.
  322. Items are filtered per group, and displayed as
  323. Group items can contain the properties <code>id</code>,
  324. <code>content</code>, and <code>className</code> (optional).
  325. </p>
  326. <p>
  327. Groups can be applied to a timeline using the method <code>setGroups</code> or supplied in the constructor.
  328. A table with groups can be created like:
  329. </p>
  330. <pre class="prettyprint lang-js">
  331. var groups = [
  332. {
  333. id: 1,
  334. content: 'Group 1'
  335. // Optional: a field 'className', 'style', 'order', [properties]
  336. }
  337. // more groups...
  338. ]);
  339. </pre>
  340. <p>
  341. Groups can have the following properties:
  342. </p>
  343. <table class="properties">
  344. <tr>
  345. <th>Name</th>
  346. <th>Type</th>
  347. <th>Required</th>
  348. <th>Description</th>
  349. </tr>
  350. <tr>
  351. <td>className</td>
  352. <td>String</td>
  353. <td>no</td>
  354. <td>This field is optional. A className can be used to give groups
  355. an individual css style. For example, when a group has className
  356. 'red', one can define a css style
  357. <code>
  358. .red {
  359. color: red;
  360. }
  361. </code>.
  362. More details on how to style groups can be found in the section
  363. <a href="#Styles">Styles</a>.
  364. </td>
  365. </tr>
  366. <tr>
  367. <td>content</td>
  368. <td>String or Element</td>
  369. <td>yes</td>
  370. <td>The contents of the group. This can be plain text, html code or an html element.</td>
  371. </tr>
  372. <tr>
  373. <td>id</td>
  374. <td>String or Number</td>
  375. <td>yes</td>
  376. <td>An id for the group. The group will display all items having a
  377. property <code>group</code> which matches the <code>id</code>
  378. of the group.</td>
  379. </tr>
  380. <tr>
  381. <td>style</td>
  382. <td>String</td>
  383. <td>no</td>
  384. <td>
  385. A css text string to apply custom styling for an individual group label, for
  386. example <code>"color: red; background-color: pink;"</code>.
  387. </td>
  388. </tr>
  389. <tr>
  390. <td>subgroupOrder</td>
  391. <td>String or Function</td>
  392. <td>none</td>
  393. <td>Order the subgroups by a field name or custom sort function.
  394. By default, groups are ordered by first-come, first-show.
  395. </td>
  396. </tr>
  397. <tr>
  398. <td>subgroupStack</td>
  399. <td>Object or Boolean</td>
  400. <td>none</td>
  401. <td>Enables stacking within individual subgroups. Example: <code>{'subgroup0': true, 'subgroup1': false, 'subgroup2': true}</code>
  402. For each subgroup where stacking is enabled, items will be stacked on top of each other within that subgroup such that they do no overlap.
  403. If set to <code>true</code> all subgroups will be stacked.
  404. If a value was specified for the <code>order</code> parameter in the options, that ordering will be used when stacking the items.
  405. </td>
  406. </tr>
  407. <tr>
  408. <td>title</td>
  409. <td>String</td>
  410. <td>none</td>
  411. <td>A title for the group, displayed when holding the mouse on the groups label.
  412. The title can only contain plain text.
  413. </td>
  414. </tr>
  415. <tr>
  416. <td>visible</td>
  417. <td>Boolean</td>
  418. <td>no</td>
  419. <td>Provides a means to toggle the whether a group is displayed or not. Defaults to <code>true</code>.</td>
  420. </tr>
  421. <tr>
  422. <td>nestedGroups</td>
  423. <td>Array</td>
  424. <td>no</td>
  425. <td>Array of group ids nested in the group. Nested groups will appear under this nesting group.</td>
  426. </tr>
  427. <tr>
  428. <td>showNested</td>
  429. <td>Boolean</td>
  430. <td>no</td>
  431. <td>Assuming the group has nested groups, this will set the initial state of the group - shown or collapsed. The <code>showNested</code> is defaulted to <code>true</code>.</td>
  432. </tr>
  433. </table>
  434. <h2 id="Configuration_Options">Configuration Options</h2>
  435. <p>
  436. Options can be used to customize the timeline.
  437. Options are defined as a JSON object. All options are optional.
  438. </p>
  439. <pre class="prettyprint lang-js">
  440. var options = {
  441. width: '100%',
  442. height: '30px',
  443. margin: {
  444. item: 20
  445. }
  446. };
  447. </pre>
  448. <p>
  449. The following options are available.
  450. </p>
  451. <table class="options" id="optionTable">
  452. <tr>
  453. <th>Name</th>
  454. <th>Type</th>
  455. <th>Default</th>
  456. <th>Description</th>
  457. </tr>
  458. <tr>
  459. <td>align</td>
  460. <td>String</td>
  461. <td><code>'center'</code></td>
  462. <td>Alignment of items with type 'box', 'range', and 'background'. Available values are 'auto' (default), 'center', 'left', or 'right'. For 'box' items, the 'auto' alignment is 'center'. For 'range' items, the auto alignment is dynamic: positioned left and shifted such that the contents is always visible on screen.</td>
  463. </tr>
  464. <tr>
  465. <td>autoResize</td>
  466. <td>boolean</td>
  467. <td><code>true</code></td>
  468. <td>If true, the Timeline will automatically detect when its container is resized, and redraw itself accordingly. If false, the Timeline can be forced to repaint after its container has been resized using the function <code>redraw()</code>.</td>
  469. </tr>
  470. <tr>
  471. <td>clickToUse</td>
  472. <td>boolean</td>
  473. <td><code>false</code></td>
  474. <td>When a Timeline is configured to be <code>clickToUse</code>, it will react to mouse and touch events only when active.
  475. When active, a blue shadow border is displayed around the Timeline. The Timeline is set active by clicking on it, and is changed to inactive again by clicking outside the Timeline or by pressing the ESC key.</td>
  476. </tr>
  477. <tr>
  478. <td>configure</td>
  479. <td>boolean or function</td>
  480. <td><code>false</code></td>
  481. <td>When true, a configurator is loaded where all configuration options of the Timeline can be changed live.
  482. The displayed options can be filtered by providing a filter function. This function is invoked with two arguments: the current <code>option</code> and the <code>path</code> (an Array) of the option within the options object. The option will be displayed when the filter function returns true. For example to only display format options:
  483. <pre class="prettyprint lang-js">
  484. function (option, path) {
  485. return option === 'format' || path.indexOf('format') !== -1;
  486. }</pre>
  487. </td>
  488. </tr>
  489. <tr>
  490. <td>dataAttributes</td>
  491. <td>string[] or 'all'</string></td>
  492. <td><code>false</code></td>
  493. <td>An array of fields optionally defined on the timeline items that will be appended as <code>data-</code> attributes to the DOM element of the items.<br>
  494. If value is <code>'all'</code> then each field defined on the timeline item will become a <code>data-</code> attribute.</td>
  495. </tr>
  496. <tr class='toggle collapsible' onclick="toggleTable('optionTable','editable', this);">
  497. <td><span parent="editable" class="right-caret"></span> editable</td>
  498. <td>boolean or Object</td>
  499. <td><code>false</code></td>
  500. <td>If true, the items in the timeline can be manipulated. Only applicable when option <code>selectable</code> is <code>true</code>. See also the callbacks <code>onAdd</code>, <code>onUpdate</code>, <code>onMove</code>, and <code>onRemove</code>. When <code>editable</code> is an object, one can enable or disable individual manipulation actions.
  501. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.
  502. </td>
  503. </tr>
  504. <tr parent="editable" class="hidden">
  505. <td class="indent">editable.add</td>
  506. <td>boolean</td>
  507. <td><code>false</code></td>
  508. <td>If true, new items can be created by double tapping an empty space in the Timeline. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  509. </tr>
  510. <tr parent="editable" class="hidden">
  511. <td class="indent">editable.remove</td>
  512. <td>boolean</td>
  513. <td><code>false</code></td>
  514. <td>If true, items can be deleted by first selecting them, and then clicking the delete button on the top right of the item. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  515. </tr>
  516. <tr parent="editable" class="hidden">
  517. <td class="indent">editable.updateGroup</td>
  518. <td>boolean</td>
  519. <td><code>false</code></td>
  520. <td>If true, items can be dragged from one group to another. Only applicable when the Timeline has groups. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  521. </tr>
  522. <tr parent="editable" class="hidden">
  523. <td class="indent">editable.updateTime</td>
  524. <td>boolean</td>
  525. <td><code>false</code></td>
  526. <td>If true, items can be dragged to another moment in time. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  527. </tr>
  528. <tr parent="editable" class="hidden">
  529. <td class="indent">editable.overrideItems</td>
  530. <td>boolean</td>
  531. <td><code>false</code></td>
  532. <td>If true, item specific editable properties are overridden by timeline settings</td>
  533. </tr>
  534. <tr>
  535. <td>end</td>
  536. <td>Date or Number or String or Moment</td>
  537. <td>none</td>
  538. <td>The initial end date for the axis of the timeline.
  539. If not provided, the latest date present in the items set is taken as
  540. end date.</td>
  541. </tr>
  542. <tr>
  543. <td>format</td>
  544. <td>Object or Function</td>
  545. <td>none</td>
  546. <td>
  547. Apply custom date formatting of the labels on the time axis. The default value of <code>format</code> is:
  548. <pre class="prettyprint lang-js">{
  549. minorLabels: {
  550. millisecond:'SSS',
  551. second: 's',
  552. minute: 'HH:mm',
  553. hour: 'HH:mm',
  554. weekday: 'ddd D',
  555. day: 'D',
  556. week: 'w',
  557. month: 'MMM',
  558. year: 'YYYY'
  559. },
  560. majorLabels: {
  561. millisecond:'HH:mm:ss',
  562. second: 'D MMMM HH:mm',
  563. minute: 'ddd D MMMM',
  564. hour: 'ddd D MMMM',
  565. weekday: 'MMMM YYYY',
  566. day: 'MMMM YYYY',
  567. week: 'MMMM YYYY',
  568. month: 'YYYY',
  569. year: ''
  570. }
  571. }</pre>
  572. For values which not provided in the customized <code>options.format</code>, the default values will be used.
  573. All available formatting syntax is described in the <a href="http://momentjs.com/docs/#/displaying/format/">docs of moment.js</a>.
  574. <br>
  575. You can also use a function format for each label. The function accepts as arguments the date, scale and step in that order, and expects to return a string for the label.
  576. <pre class="prettyprint lang-js">function format({
  577. minorLabels: Function(date: Date, scale: Number, step: Number),
  578. majorLabels: Function(date: Date, scale: Number, step: Number)
  579. }</pre>
  580. </td>
  581. </tr>
  582. <tr class='toggle collapsible' onclick="toggleTable('optionTable','groupEditable', this);">
  583. <td><span parent="groupEditable" class="right-caret"></span> groupEditable</td>
  584. <td>boolean or Object</td>
  585. <td><code>false</code></td>
  586. <td>If true, the groups in the timeline can be manipulated. See also the callbacks <code>onAddGroup</code>, <code>onMoveGroup</code>, and <code>onRemoveGroup</code>. When <code>groupEditable</code> is an object, one can enable or disable individual manipulation actions.
  587. The editing of groups follows the same principles as for items, see section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.
  588. </td>
  589. </tr>
  590. <tr parent="groupEditable" class="hidden">
  591. <td class="indent">groupEditable.add</td>
  592. <td>boolean</td>
  593. <td><code>false</code></td>
  594. <td>If true, new groups can be created in the Timeline. For now adding new groups is done by the user.</td>
  595. </tr>
  596. <tr parent="groupEditable" class="hidden">
  597. <td class="indent">groupEditable.remove</td>
  598. <td>boolean</td>
  599. <td><code>false</code></td>
  600. <td>If true, groups can be deleted. For now removing groups is done by the user.</td>
  601. </tr>
  602. <tr parent="groupEditable" class="hidden">
  603. <td class="indent">groupEditable.order</td>
  604. <td>boolean</td>
  605. <td><code>false</code></td>
  606. <td>If true, groups can be dragged to change their order. Only applicable when the Timeline has groups. For this option to work properly the groupOrder and groupOrderSwap options have to be set as well.</td>
  607. </tr>
  608. <tr>
  609. <td>groupOrder</td>
  610. <td>String or Function</td>
  611. <td>'order'</td>
  612. <td>Order the groups by a field name or custom sort function.
  613. By default, groups are ordered by a property <code>order</code> (if set).
  614. If no <code>order</code> properties are provided, the order will be undetermined.
  615. </td>
  616. </tr>
  617. <tr>
  618. <td>groupOrderSwap</td>
  619. <td>Function</td>
  620. <td>none</td>
  621. <td>Swaps the positions of two groups. If groups have a custom order (via <code>groupOrder</code>) and groups are configured to be reorderable (via <code>groupEditable.order</code>), the user has to provide a function that swaps the positions of two given groups.
  622. If this option is not set, the default implementation assumes that groups hold an attribute <code>order</code> which values are changed. The signature of the <code>groupOrderWap</code> function is:
  623. <pre class="prettyprint lang-js">function groupOrderSwap(fromGroup: Object, toGroup: Object, groups: DataSet)</pre>
  624. The first to arguments hold the groups of which the positions are to be swapped and the third argument holds the DataSet with all groups.
  625. </td>
  626. </tr>
  627. <tr>
  628. <td>groupTemplate</td>
  629. <td>function</td>
  630. <td>none</td>
  631. <td>A template function used to generate the contents of the groups. The function is called by the Timeline with a groups data as the first argument and the group element as the second, and must return HTML code, a string or a template as result. When the option groupTemplate is specified, the groups do not need to have a field <code>content</code>. See section <a href="#Templates">Templates</a> for a detailed explanation.</td>
  632. </tr>
  633. <tr>
  634. <td>height</td>
  635. <td>number or String</td>
  636. <td>none</td>
  637. <td>The height of the timeline in pixels or as a percentage.
  638. When height is undefined or null, the height of the timeline is automatically
  639. adjusted to fit the contents.
  640. It is possible to set a maximum height using option <code>maxHeight</code>
  641. to prevent the timeline from getting too high in case of automatically
  642. calculated height.
  643. </td>
  644. </tr>
  645. <tr>
  646. <td>hiddenDates</td>
  647. <td>Object</td>
  648. <td>none</td>
  649. <td>This option allows you to hide specific timespans from the time axis. The dates can be supplied as an object:
  650. <code>{start: '2014-03-21 00:00:00', end: '2014-03-28 00:00:00', [repeat:'daily']}</code> or as an Array of these objects. The repeat argument is optional.
  651. The possible values are (case-sensitive): <code>daily, weekly, monthly, yearly</code>. To hide a weekend, pick any Saturday as start and the following Monday as end
  652. and set repeat to weekly.
  653. </td>
  654. </tr>
  655. <tr>
  656. <td>horizontalScroll</td>
  657. <td>Boolean</td>
  658. <td>false</td>
  659. <td>This option allows you to scroll horizontally to move backwards and forwards in the time range.
  660. Only applicable when option <code>zoomCtrl</code> is defined or <code>zoomable</code> is <code>false</code>.
  661. </td>
  662. </tr>
  663. <tr class='toggle collapsible' onclick="toggleTable('optionTable','itemsAlwaysDraggable', this);">
  664. <td><span parent="itemsAlwaysDraggable" class="right-caret"></span> itemsAlwaysDraggable</td>
  665. <td>boolean or Object</td>
  666. <td>Object</td>
  667. <td>When a boolean, applies the value only to <code>itemsAlwaysDraggable.item</code>.</td>
  668. </tr>
  669. <tr parent="itemsAlwaysDraggable" class="hidden">
  670. <td class="indent">itemsAlwaysDraggable.item</td>
  671. <td>boolean</td>
  672. <td><code>false</code></td>
  673. <td>If true, all items in the Timeline are draggable without being selected. If false, only the selected item(s) are draggable.</td>
  674. </tr>
  675. <tr parent="itemsAlwaysDraggable" class="hidden">
  676. <td class="indent">itemsAlwaysDraggable.range</td>
  677. <td>boolean</td>
  678. <td><code>false</code></td>
  679. <td>If true, range of all items in the Timeline is draggable without being selected. If false, range is only draggable for the selected item(s). Only applicable when option <code>itemsAlwaysDraggable.item</code> is set <code>true</code>. </td>
  680. </tr>
  681. <tr>
  682. <td>loadingScreenTemplate</td>
  683. <td>function</td>
  684. <td>none</td>
  685. <td>A template function used to generate the timeline initial loading screen. See section <a href="#Templates">Templates</a> for a detailed explanation.</td>
  686. </tr>
  687. <tr>
  688. <td>locale</td>
  689. <td>String</td>
  690. <td>none</td>
  691. <td>Select a locale for the Timeline. See section <a href="#Localization">Localization</a> for more information.</td>
  692. </tr>
  693. <tr>
  694. <td>locales</td>
  695. <td>Object</td>
  696. <td>none</td>
  697. <td>A map with i18n locales. See section <a href="#Localization">Localization</a> for more information.</td>
  698. </tr>
  699. <tr>
  700. <td>moment</td>
  701. <td>function</td>
  702. <td>vis.moment</td>
  703. <td>A constructor for creating a moment.js Date. Allows for applying a custom time zone. See section <a href="#Time_zone">Time zone</a> for more information.</td>
  704. </tr>
  705. <tr class='toggle collapsible' onclick="toggleTable('optionTable','margin', this);">
  706. <td><span parent="margin" class="right-caret"></span> margin</td>
  707. <td>number or Object</td>
  708. <td>Object</td>
  709. <td>When a number, applies the margin to <code>margin.axis</code>, <code>margin.item.horizontal</code>, and <code>margin.item.vertical</code>.</td>
  710. </tr>
  711. <tr parent="margin" class="hidden">
  712. <td class="indent">margin.axis</td>
  713. <td>number</td>
  714. <td><code>20</code></td>
  715. <td>The minimal margin in pixels between items and the time axis.</td>
  716. </tr>
  717. <tr parent="margin" class="hidden">
  718. <td class="indent">margin.item</td>
  719. <td>number</td>
  720. <td><code>10</code></td>
  721. <td>The minimal margin in pixels between items in both horizontal and vertical direction.</td>
  722. </tr>
  723. <tr parent="margin" class="hidden">
  724. <td class="indent2">margin.item.horizontal</td>
  725. <td>number</td>
  726. <td><code>10</code></td>
  727. <td>The minimal horizontal margin in pixels between items.</td>
  728. </tr>
  729. <tr parent="margin" class="hidden">
  730. <td class="indent2">margin.item.vertical</td>
  731. <td>number</td>
  732. <td><code>10</code></td>
  733. <td>The minimal vertical margin in pixels between items.</td>
  734. </tr>
  735. <tr>
  736. <td>max</td>
  737. <td>Date or Number or String or Moment</td>
  738. <td>none</td>
  739. <td>Set a maximum Date for the visible range.
  740. It will not be possible to move beyond this maximum.
  741. </td>
  742. </tr>
  743. <tr>
  744. <td>maxHeight</td>
  745. <td>number or String</td>
  746. <td>none</td>
  747. <td>Specifies the maximum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  748. </tr>
  749. <tr>
  750. <td>maxMinorChars</td>
  751. <td>number</td>
  752. <td>7</td>
  753. <td>
  754. Specifies the maximum number of characters that should fit in minor grid labels.
  755. If larger, less and wider grids will be drawn.
  756. </td>
  757. </tr>
  758. <tr>
  759. <td>min</td>
  760. <td>Date or Number or String or Moment</td>
  761. <td>none</td>
  762. <td>Set a minimum Date for the visible range.
  763. It will not be possible to move beyond this minimum.
  764. </td>
  765. </tr>
  766. <tr>
  767. <td>minHeight</td>
  768. <td>number or String</td>
  769. <td>none</td>
  770. <td>Specifies the minimum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  771. </tr>
  772. <tr>
  773. <td>moveable</td>
  774. <td>boolean</td>
  775. <td><code>true</code></td>
  776. <td>
  777. Specifies whether the Timeline can be moved and zoomed by dragging the window.
  778. See also option <code>zoomable</code>.
  779. </td>
  780. </tr>
  781. <tr>
  782. <td>multiselect</td>
  783. <td>boolean</td>
  784. <td><code>false</code></td>
  785. <td>
  786. If true, multiple items can be selected using ctrl+click, shift+click, or by holding items.
  787. Only applicable when option <code>selectable</code> is <code>true</code>.
  788. </td>
  789. </tr>
  790. <tr>
  791. <td style="font-size: 0.9em">multiselectPerGroup</td>
  792. <td>boolean</td>
  793. <td><code>false</code></td>
  794. <td>
  795. If true, selecting multiple items using shift+click will only select items residing in the same group as the <i>first</i> selected item.
  796. Only applicable when option <code>selectable</code> and <code>multiselect</code> are <code>true</code>.
  797. </td>
  798. </tr>
  799. <tr>
  800. <td>onAdd</td>
  801. <td>function</td>
  802. <td>none</td>
  803. <td>Callback function triggered when an item is about to be added: when the user double taps an empty space in the Timeline. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.add</code> are set <code>true</code>.
  804. </td>
  805. </tr>
  806. <tr>
  807. <td>onAddGroup</td>
  808. <td>function</td>
  809. <td>none</td>
  810. <td>Callback function triggered when a group is about to be added. The signature and semantics are the same as for <code>onAdd</code>.
  811. </td>
  812. </tr>
  813. <tr>
  814. <td>onDropObjectOnItem</td>
  815. <td>function</td>
  816. <td>none</td>
  817. <td>Callback function triggered when an object containing <code>target:'item'</code> in its drag data is dropped in to a timeline item.
  818. </td>
  819. </tr>
  820. <tr>
  821. <td>onInitialDrawComplete</td>
  822. <td>function</td>
  823. <td>none</td>
  824. <td>Callback function triggered when the timeline is initially drawn. This function fires once per timeline creation.
  825. </td>
  826. </tr>
  827. <tr>
  828. <td>onMove</td>
  829. <td>function</td>
  830. <td>none</td>
  831. <td>Callback function triggered when an item has been moved: after the user has dragged the item to an other position. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.updateTime</code> or <code>editable.updateGroup</code> are set <code>true</code>.
  832. </td>
  833. </tr>
  834. <tr>
  835. <td>onMoveGroup</td>
  836. <td>function</td>
  837. <td>none</td>
  838. <td>Callback function triggered when a group has been moved: after the user has dragged the group to an other position. The signature and semantics are the same as for <code>onMove</code>.
  839. </td>
  840. </tr>
  841. <tr>
  842. <td>onMoving</td>
  843. <td>function</td>
  844. <td>none</td>
  845. <td>Callback function triggered repeatedly when an item is being moved. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.updateTime</code> or <code>editable.updateGroup</code> are set <code>true</code>.
  846. </td>
  847. </tr>
  848. <tr>
  849. <td>onRemove</td>
  850. <td>function</td>
  851. <td>none</td>
  852. <td>Callback function triggered when an item is about to be removed: when the user tapped the delete button on the top right of a selected item. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.remove</code> are set <code>true</code>.
  853. </td>
  854. </tr>
  855. <tr>
  856. <td>onRemoveGroup</td>
  857. <td>function</td>
  858. <td>none</td>
  859. <td>Callback function triggered when a group is about to be removed. The signature and semantics are the same as for <code>onRemove</code>.
  860. </td>
  861. </tr>
  862. <tr class='toggle collapsible' onclick="toggleTable('optionTable','onTimeout', this);">
  863. <td><span parent="onTimeout" class="right-caret"></span> onTimeout</td>
  864. <td>Object</td>
  865. <td><code>Object</code></td>
  866. <td>Specify timeline bailing options when a specified timeout is reached.</td>
  867. </tr>
  868. <tr parent="onTimeout" class="hidden">
  869. <td class="indent">onTimeout.timeoutMs</td>
  870. <td>number</td>
  871. <td>none</td>
  872. <td>Number of milliseconds until the callback function should be called.
  873. The callback will not be called if the timeline gets drawn completely before the timeoutMs limit.</td>
  874. </tr>
  875. <tr parent="onTimeout" class="hidden">
  876. <td class="indent">onTimeout.callback</td>
  877. <td>function</td>
  878. <td>none</td>
  879. <td>
  880. A callback function called when <code>timeoutMs</code> milliseconds pass and the timeline has yet to be fully drawn initially.
  881. </td>
  882. </tr>
  883. <tr>
  884. <td>onUpdate</td>
  885. <td>function</td>
  886. <td>none</td>
  887. <td>Callback function triggered when an item is about to be updated, when the user double taps an item in the Timeline. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.updateTime</code> or <code>editable.updateGroup</code> are set <code>true</code>.
  888. </td>
  889. </tr>
  890. <tr>
  891. <td>order</td>
  892. <td>function</td>
  893. <td>none</td>
  894. <td>
  895. <p>Provide a custom sort function to order the items. The order of the
  896. items is determining the way they are stacked. The function
  897. order is called with two arguments containing the data of two items to be
  898. compared.
  899. </p>
  900. <p style="font-style: italic">WARNING: Use with caution. Custom ordering is not suitable for large amounts of items. On load, the Timeline will render all items once to determine their width and height. Keep the number of items in this configuration limited to a maximum of a few hundred items.</p>
  901. </td>
  902. </tr>
  903. <tr class='toggle collapsible' onclick="toggleTable('optionTable','orientation', this);">
  904. <td><span parent="orientation" class="right-caret"></span> orientation</td>
  905. <td>String or Object</td>
  906. <td><code>'bottom'</code></td>
  907. <td>Orientation of the timelines axis and items. When orientation is a string, the value is applied to both items and axis. Can be 'top', 'bottom' (default), 'both', or 'none'.</td>
  908. </tr>
  909. <tr parent="orientation" class="hidden">
  910. <td class="indent">orientation.axis</td>
  911. <td>String</td>
  912. <td><code>'bottom'</code></td>
  913. <td>Orientation of the timeline axis: 'top', 'bottom' (default), 'both', or 'none'. If orientation is 'bottom', the time axis is drawn at the bottom. When 'top', the axis is drawn on top. When 'both', two axes are drawn, both on top and at the bottom. In case of 'none', no axis is drawn at all.</td>
  914. </tr>
  915. <tr parent="orientation" class="hidden">
  916. <td class="indent">orientation.item</td>
  917. <td>String</td>
  918. <td><code>'bottom'</code></td>
  919. <td>Orientation of the timeline items: 'top' or 'bottom' (default). Determines whether items are aligned to the top or bottom of the Timeline.</td>
  920. </tr>
  921. <tr class='toggle collapsible' onclick="toggleTable('optionTable','rollingMode', this);">
  922. <td><span parent="rollingMode" class="right-caret"></span> rollingMode</td>
  923. <td>Object</td>
  924. <td><code>Object</code></td>
  925. <td>Specify how the timeline implements rolling mode.</td>
  926. </tr>
  927. <tr parent="rollingMode" class="hidden">
  928. <td class="indent">rollingMode.follow</td>
  929. <td>boolean</td>
  930. <td><code>false</code></td>
  931. <td>If true, the timeline will initial in a rolling mode - the current time will always be centered. I the user drags the timeline, the timeline will go out of rolling mode and a toggle button will appear. Clicking that button will go back to rolling mode. Zooming in rolling mode will zoom in to the center without consideration of the mouse position.</td>
  932. </tr>
  933. <tr parent="rollingMode" class="hidden">
  934. <td class="indent">rollingMode.offset</td>
  935. <td>Number</td>
  936. <td><code>'0.5'</code></td>
  937. <td>
  938. Set how far from the left the rolling mode is implemented from. A percentage (i.e. a decimal between 0 and 1)
  939. Defaults to the middle or 0.5 (50%)
  940. </td>
  941. </tr>
  942. <tr>
  943. <td>rtl</td>
  944. <td>boolean</td>
  945. <td><code>false</code></td>
  946. <td>If true, the timeline will be right-to-left. Note: you can achieve rtl timeline by defining a parent node with <code>dir="rtl"</code>. The timeline knows to take the nearest parent node direction and apply it. Notice that the timeline will prefer the <code>option.rtl</code> over any parent <code>dir="rtl"</code></td>
  947. </tr>
  948. <tr>
  949. <td>selectable</td>
  950. <td>boolean</td>
  951. <td><code>true</code></td>
  952. <td>If true, the items on the timeline can be selected. Multiple items can be selected by long pressing them, or by using ctrl+click or shift+click. The event <code>select</code> is fired each time the selection has changed (see section <a href="#Events">Events</a>).</td>
  953. </tr>
  954. <tr>
  955. <td>showCurrentTime</td>
  956. <td>boolean</td>
  957. <td><code>true</code></td>
  958. <td>Show a vertical bar at the current time.</td>
  959. </tr>
  960. <tr>
  961. <tr>
  962. <td>showMajorLabels</td>
  963. <td>boolean</td>
  964. <td><code>true</code></td>
  965. <td>By default, the timeline shows both minor and major date labels on the
  966. time axis.
  967. For example the minor labels show minutes and the major labels show hours.
  968. When <code>showMajorLabels</code> is <code>false</code>, no major labels
  969. are shown.</td>
  970. </tr>
  971. <tr>
  972. <td>showMinorLabels</td>
  973. <td>boolean</td>
  974. <td><code>true</code></td>
  975. <td>By default, the timeline shows both minor and major date labels on the
  976. time axis.
  977. For example the minor labels show minutes and the major labels show hours.
  978. When <code>showMinorLabels</code> is <code>false</code>, no minor labels
  979. are shown. When both <code>showMajorLabels</code> and
  980. <code>showMinorLabels</code> are false, no horizontal axis will be
  981. visible.</td>
  982. </tr>
  983. <tr>
  984. <td>showTooltips</td>
  985. <td>boolean</td>
  986. <td><code>true</code></td>
  987. <td>If true, items with titles will display a tooltip. If false, item tooltips are prevented from showing.</td>
  988. </tr>
  989. <tr>
  990. <td>stack</td>
  991. <td>boolean</td>
  992. <td><code>true</code></td>
  993. <td>If true (default), items will be stacked on top of each other such that they do not overlap.</td>
  994. </tr>
  995. <tr>
  996. <td>stackSubgroups</td>
  997. <td>boolean</td>
  998. <td><code>true</code></td>
  999. <td>If true (default), subgroups will be stacked on top of each other such that they do not overlap.</td>
  1000. </tr>
  1001. <tr>
  1002. <td>snap</td>
  1003. <td>function or null</td>
  1004. <td>function</td>
  1005. <td>When moving items on the Timeline, they will be snapped to nice dates like full hours or days, depending on the current scale. The <code>snap</code> function can be replaced with a custom function, or can be set to <code>null</code> to disable snapping. The signature of the snap function is:
  1006. <pre class="prettyprint lang-js">function snap(date: Date, scale: string, step: number) : Date or number</pre>
  1007. The parameter <code>scale</code> can be can be 'millisecond', 'second', 'minute', 'hour', 'weekday, 'week', 'day, 'month, or 'year'. The parameter <code>step</code> is a number like 1, 2, 4, 5.
  1008. </td>
  1009. </tr>
  1010. <tr>
  1011. <td>start</td>
  1012. <td>Date or Number or String or Moment</td>
  1013. <td>none</td>
  1014. <td>The initial start date for the axis of the timeline.
  1015. If not provided, the earliest date present in the events is taken as start date.</td>
  1016. </tr>
  1017. <tr>
  1018. <td>template</td>
  1019. <td>function</td>
  1020. <td>none</td>
  1021. <td>A template function used to generate the contents of the items. The function is called by the Timeline with an items' data as the first argument, the item element as the second argument and the edited data as the third argument, and must return HTML code, a string or a template as result. When the option template is specified, the items do not need to have a field <code>content</code>. See section <a href="#Templates">Templates</a> for a detailed explanation.</td>
  1022. </tr>
  1023. <tr>
  1024. <td>visibleFrameTemplate</td>
  1025. <td>function</td>
  1026. <td>none</td>
  1027. <td>A template function used to generate the visible frame of the items. The function is called by the Timeline with an items' data as the first argument and the item frame element as the second, and must return HTML code, a string or a template as result. When the option template is specified, the items do not need to have a field <code>content</code>. See section <a href="#Templates">Templates</a> for a detailed explanation.
  1028. This would be used as an additional way to add content that is constant in size with the visible frame of the item and does not get visibly hidden with the item's internal container: <code>vis-item-overflow</code> which is <code>overflow:hidden</code>.</td>
  1029. </tr>
  1030. <tr class='deprecated'>
  1031. <td>throttleRedraw</td>
  1032. <td>number</td>
  1033. <td><code>0</code></td>
  1034. <td>This option is <b>DEPRECATED</b> and no longer supported. It will be removed in the next MAJOR release.</td>
  1035. </tr>
  1036. <tr class='toggle collapsible' onclick="toggleTable('optionTable','timeAxis', this);">
  1037. <td><span parent="timeAxis" class="right-caret"></span> timeAxis</td>
  1038. <td>Object</td>
  1039. <td><code>Object</code></td>
  1040. <td>Specify a fixed scale and step size for the time axis.</td>
  1041. </tr>
  1042. <tr parent="timeAxis" class="hidden">
  1043. <td class="indent">timeAxis.scale</td>
  1044. <td>String</td>
  1045. <td>none</td>
  1046. <td>Set a fixed scale for the time axis of the Timeline. Choose from <code>'millisecond'</code>, <code>'second'</code>, <code>'minute'</code>, <code>'hour'</code>, <code>'weekday'</code>, <code>'week'</code>, <code>'day'</code>, <code>'month'</code>, <code>'year'</code>. Example usage:
  1047. <pre class="prettyprint lang-js">var options = {
  1048. timeAxis: {scale: 'minute', step: 5}
  1049. }</pre>
  1050. <p>Note: The 'week' scale only works properly when <a href="#Localization">locales</a> are enabled.</p>
  1051. </td>
  1052. </tr>
  1053. <tr parent="timeAxis" class="hidden">
  1054. <td class="indent">timeAxis.step</td>
  1055. <td>number</td>
  1056. <td><code>1</code></td>
  1057. <td>
  1058. Set a fixed step size for the time axis. Only applicable when used together with <code>timeAxis.scale</code>.
  1059. Choose for example 1, 2, 5, or 10.</td>
  1060. </tr>
  1061. <tr>
  1062. <td>type</td>
  1063. <td>String</td>
  1064. <td>none</td>
  1065. <td>Specifies the default type for the timeline items. Choose from 'box', 'point', 'range', and 'background'. Note that individual items can override this default type. If undefined, the Timeline will auto detect the type from the items data: if a start and end date is available, a 'range' will be created, and else, a 'box' is created. Items of type 'background' are not editable.
  1066. </td>
  1067. </tr>
  1068. <tr class='toggle collapsible' onclick="toggleTable('optionTable','tooltip', this);">
  1069. <td><span parent="tooltip" class="right-caret"></span> tooltip</td>
  1070. <td>Object</td>
  1071. <td><code>Object</code></td>
  1072. <td>Specify how the tooltip is positioned.</td>
  1073. </tr>
  1074. <tr parent="tooltip" class="hidden">
  1075. <td class="indent">tooltip.followMouse</td>
  1076. <td>boolean</td>
  1077. <td><code>false</code></td>
  1078. <td>If true, tooltips will follow the mouse as they move around in the item.</td>
  1079. </tr>
  1080. <tr parent="tooltip" class="hidden">
  1081. <td class="indent">tooltip.overflowMethod</td>
  1082. <td>String</td>
  1083. <td><code>'flip'</code></td>
  1084. <td>
  1085. Set how the tooltip should act if it is about to overflow out of the timeline.<br />
  1086. Choose from <code>'cap'</code> and <code>'flip'</code>. <br />
  1087. If it is set to <code>'cap'</code>, the tooltip will just cap its position to inside to timeline. <br />
  1088. While if it is set to <code>'flip'</code>, the position of the tooltip will flip around the cursor so that a corner is at the cursor, and the rest of it is visible. <br />
  1089. </tr>
  1090. <tr class='toggle collapsible' onclick="toggleTable('optionTable','tooltipOnItemUpdateTime', this);">
  1091. <td><span parent="tooltipOnItemUpdateTime" class="right-caret"></span> tooltipOnItemUpdateTime</td>
  1092. <td>Object/Boolean</td>
  1093. <td><code>false</code></td>
  1094. <td>Show a tooltip on updating an item's time. Note: <code>editable.updateTime</code> must be <code>true</code></td>
  1095. </tr>
  1096. <tr parent="tooltipOnItemUpdateTime" class="hidden">
  1097. <td class="indent">template</td>
  1098. <td>Function</td>
  1099. <td>none</td>
  1100. <td>A template function used to generate the contents of the tooltip. The function is called by the Timeline with an item data as the first argument, and must return HTML code, a string or a template as result. See section <a href="#Templates">Templates</a> for a detailed explanation.
  1101. </td>
  1102. </tr>
  1103. <tr>
  1104. <td>verticalScroll</td>
  1105. <td>Boolean</td>
  1106. <td><code>false</code></td>
  1107. <td> Show a vertical scroll on the side of the group list and link it to the scroll event when zoom is not triggered. Notice that defining this option as <code>true</code> will NOT override <code>horizontalScroll</code>. The scroll event will be vertically ignored, but a vertical scrollbar will be visible
  1108. </td>
  1109. </tr>
  1110. <tr>
  1111. <td>width</td>
  1112. <td>String or Number</td>
  1113. <td><code>'100%'</code></td>
  1114. <td>The width of the timeline in pixels or as a percentage.</td>
  1115. </tr>
  1116. <tr>
  1117. <td>zoomable</td>
  1118. <td>boolean</td>
  1119. <td><code>true</code></td>
  1120. <td>
  1121. Specifies whether the Timeline can be zoomed by pinching or scrolling in the window.
  1122. Only applicable when option <code>moveable</code> is set <code>true</code>.
  1123. </td>
  1124. </tr>
  1125. <tr>
  1126. <td>zoomKey</td>
  1127. <td>String</td>
  1128. <td><code>''</code></td>
  1129. <td>Specifies whether the Timeline is only zoomed when an additional key is down.
  1130. Available values are '' (does not apply), 'altKey', 'ctrlKey', or 'metaKey'.
  1131. Only applicable when option <code>moveable</code> is set <code>true</code>.
  1132. </td>
  1133. </tr>
  1134. <tr>
  1135. <td>zoomMax</td>
  1136. <td>number</td>
  1137. <td><code>315360000000000</code></td>
  1138. <td>Set a maximum zoom interval for the visible range in milliseconds.
  1139. It will not be possible to zoom out further than this maximum.
  1140. Default value equals about 10000 years.
  1141. </td>
  1142. </tr>
  1143. <tr>
  1144. <td>zoomMin</td>
  1145. <td>number</td>
  1146. <td><code>10</code></td>
  1147. <td>Set a minimum zoom interval for the visible range in milliseconds.
  1148. It will not be possible to zoom in further than this minimum.
  1149. </td>
  1150. </tr>
  1151. </table>
  1152. <h2 id="Methods">Methods</h2>
  1153. <p>
  1154. The Timeline supports the following methods.
  1155. </p>
  1156. <table class="methods">
  1157. <tr>
  1158. <th>Method</th>
  1159. <th>Return&nbsp;Type</th>
  1160. <th>Description</th>
  1161. </tr>
  1162. <tr>
  1163. <td>addCustomTime([time] [, id])</td>
  1164. <td>number or String</td>
  1165. <td>
  1166. Add new vertical bar representing a custom time that can be dragged by the user.
  1167. Parameter <code>time</code> can be a Date, Number, or String, and is <code>new Date()</code> by default.
  1168. Parameter <code>id</code> can be Number or String and is <code>undefined</code> by default.
  1169. The <code>id</code>code> is added as CSS class name of the custom time bar, allowing to style multiple time bars differently.
  1170. The method returns id of the created bar.
  1171. </td>
  1172. </tr>
  1173. <tr>
  1174. <td>destroy()</td>
  1175. <td>none</td>
  1176. <td>Destroy the Timeline. The timeline is removed from memory. all DOM elements and event listeners are cleaned up.
  1177. </td>
  1178. </tr>
  1179. <tr>
  1180. <td>fit([options])</td>
  1181. <td>none</td>
  1182. <td>Adjust the visible window such that it fits all items. See also function <code>focus(id)</code>.
  1183. Available options:
  1184. <ul>
  1185. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.
  1186. </li>
  1187. </ul>
  1188. </td>
  1189. </tr>
  1190. <tr>
  1191. <td>focus(id or ids [, options])</td>
  1192. <td>none</td>
  1193. <td>Adjust the visible window such that the selected item (or multiple items) are centered on screen. See also function <code>fit()</code>. Available options:
  1194. <ul>
  1195. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  1196. </ul>
  1197. </td>
  1198. </tr>
  1199. <tr>
  1200. <td>getCurrentTime()</td>
  1201. <td>Date</td>
  1202. <td>Get the current time. Only applicable when option <code>showCurrentTime</code> is true.
  1203. </td>
  1204. </tr>
  1205. <tr>
  1206. <td>getCustomTime([id])</td>
  1207. <td>Date</td>
  1208. <td>Retrieve the custom time from the custom time bar with given id. Id is <code>undefined</code> by default.
  1209. </td>
  1210. </tr>
  1211. <tr id="getEventProperties">
  1212. <td>getEventProperties(event)</td>
  1213. <td>Object</td>
  1214. <td>
  1215. Returns an Object with relevant properties from an event:
  1216. <ul>
  1217. <li><code>group</code> (Number or null): the id of the clicked group.</li>
  1218. <li><code>item</code> (Number or null): the id of the clicked item.</li>
  1219. <li><code>pageX</code> (Number): absolute horizontal position of the click event.</li>
  1220. <li><code>pageY</code> (Number): absolute vertical position of the click event.</li>
  1221. <li><code>x</code> (Number): relative horizontal position of the click event.</li>
  1222. <li><code>y</code> (Number): relative vertical position of the click event.</li>
  1223. <li><code>time</code> (Date): Date of the clicked event.</li>
  1224. <li><code>snappedTime</code> (Date): Date of the clicked event, snapped to a nice value.</li>
  1225. <li><code>what</code> (String or null): name of the clicked thing: <code>item</code>, <code>background</code>, <code>axis</code>, <code>group-label</code>, <code>custom-time</code>, or <code>current-time</code>.</li>
  1226. <li><code>event</code> (Object): the original click event.</li>
  1227. </ul>
  1228. Example usage:
  1229. <pre class="prettyprint lang-js">
  1230. document.getElementById('myTimeline').onclick = function (event) {
  1231. var props = timeline.getEventProperties(event)
  1232. console.log(props);
  1233. }</pre>
  1234. </td>
  1235. </tr>
  1236. <tr>
  1237. <td>getItemRange()</td>
  1238. <td>Object</td>
  1239. <td>Get the range of all the items as an object containing <code>min: Date</code> and <code>max: Date</code>.</td>
  1240. </tr>
  1241. <tr>
  1242. <td>getSelection()</td>
  1243. <td>number[]</td>
  1244. <td>Get an array with the ids of the currently selected items.</td>
  1245. </tr>
  1246. <tr>
  1247. <td>getVisibleItems()</td>
  1248. <td>number[]</td>
  1249. <td>Get an array with the ids of the currently visible items.</td>
  1250. </tr>
  1251. <tr>
  1252. <td>getWindow()</td>
  1253. <td>Object</td>
  1254. <td>Get the current visible window. Returns an object with properties <code>start: Date</code> and <code>end: Date</code>.</td>
  1255. </tr>
  1256. <tr>
  1257. <td>moveTo(time [, options, callback])</td>
  1258. <td>none</td>
  1259. <td>Move the window such that given time is centered on screen. Parameter <code>time</code> can be a <code>Date</code>, <code>Number</code>, or <code>String</code>. Available options:
  1260. <ul>
  1261. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  1262. </ul>
  1263. A callback <code>function</code> can be passed as an optional parameter. This function will be called at the end of moveTo function.
  1264. </td>
  1265. </tr>
  1266. <tr>
  1267. <td>on(event, callback)</td>
  1268. <td>none</td>
  1269. <td>Create an event listener. The callback function is invoked every time the event is triggered. Available events: <code>rangechange</code>, <code>rangechanged</code>, <code>select</code>, <code>itemover</code>, <code>itemout</code>. The callback function is invoked as <code>callback(properties)</code>, where <code>properties</code> is an object containing event specific properties. See section <a href="#Events">Events for more information</a>.</td>
  1270. </tr>
  1271. <tr>
  1272. <td>off(event, callback)</td>
  1273. <td>none</td>
  1274. <td>Remove an event listener created before via function <code>on(event, callback)</code>. See section <a href="#Events">Events for more information</a>.</td>
  1275. </tr>
  1276. <tr>
  1277. <td>redraw()</td>
  1278. <td>none</td>
  1279. <td>Force a redraw of the Timeline. The size of all items will be recalculated.
  1280. Can be useful to manually redraw when option <code>autoResize=false</code> and the window
  1281. has been resized, or when the items CSS has been changed.
  1282. </td>
  1283. </tr>
  1284. <tr>
  1285. <td>removeCustomTime(id)</td>
  1286. <td>none</td>
  1287. <td>
  1288. Remove vertical bars previously added to the timeline via <code>addCustomTime</code> method. Parameter <code>id</code> is the ID of the custom vertical bar returned by <code>addCustomTime</code> method.
  1289. </td>
  1290. </tr>
  1291. <tr>
  1292. <td>setCurrentTime(time)</td>
  1293. <td>none</td>
  1294. <td>Set a current time. This can be used for example to ensure that a client's time is synchronized with a shared server time.
  1295. <code>time</code> can be a Date object, numeric timestamp, or ISO date string.
  1296. Only applicable when option <code>showCurrentTime</code> is true.</td>
  1297. </tr>
  1298. <tr>
  1299. <td>setCustomTime(time [, id])</td>
  1300. <td>none</td>
  1301. <td>Adjust the time of a custom time bar.
  1302. Parameter <code>time</code> can be a Date object, numeric timestamp, or ISO date string.
  1303. Parameter <code>id</code> is the id of the custom time bar, and is <code>undefined</code> by default.
  1304. </td>
  1305. </tr>
  1306. <tr>
  1307. <td>setCustomTimeTitle(title [, id])</td>
  1308. <td>none</td>
  1309. <td>Adjust the title attribute of a custom time bar.
  1310. Parameter <code>title</code> is the string or function to be set as title. Use empty string to hide the title completely.
  1311. Parameter <code>id</code> is the id of the custom time bar, and is <code>undefined</code> by default.
  1312. </td>
  1313. </tr>
  1314. <tr>
  1315. <td>setData({<br>&nbsp;&nbsp;groups: groups,<br>&nbsp;&nbsp;items: items<br>})</td>
  1316. <td>none</td>
  1317. <td>Set both groups and items at once. Both properties are optional. This is a convenience method for individually calling both <code>setItems(items)</code> and <code>setGroups(groups)</code>.
  1318. Both <code>items</code> and <code>groups</code> can be an Array with Objects,
  1319. a DataSet (offering 2 way data binding), or a DataView (offering 1 way data binding).
  1320. For each of the groups, the items of the timeline are filtered on the
  1321. property <code>group</code>, which must correspond with the id of the group.
  1322. </td>
  1323. </tr>
  1324. <tr>
  1325. <td>setGroups(groups)</td>
  1326. <td>none</td>
  1327. <td>Set a data set with groups for the Timeline.
  1328. <code>groups</code> can be an Array with Objects,
  1329. a DataSet (offering 2 way data binding), or a DataView (offering 1 way data binding).
  1330. For each of the groups, the items of the timeline are filtered on the
  1331. property <code>group</code>, which must correspond with the id of the group.
  1332. </td>
  1333. </tr>
  1334. <tr>
  1335. <td>setItems(items)</td>
  1336. <td>none</td>
  1337. <td>Set a data set with items for the Timeline.
  1338. <code>items</code> can be an Array with Objects,
  1339. a DataSet (offering 2 way data binding), or a DataView (offering 1 way data binding).
  1340. </td>
  1341. </tr>
  1342. <tr>
  1343. <td>setOptions(options)</td>
  1344. <td>none</td>
  1345. <td>Set or update options. It is possible to change any option of the timeline at any time. You can for example switch orientation on the fly.
  1346. </td>
  1347. </tr>
  1348. <tr>
  1349. <td>setSelection(id or ids [, options])</td>
  1350. <td>none</td>
  1351. <td>Select one or multiple items by their id. The currently selected items will be unselected. To unselect all selected items, call `setSelection([])`. Available options:
  1352. <ul>
  1353. <li><code>focus: boolean</code><br>If true, focus will be set to the selected item(s)</li>
  1354. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Only applicable when option focus is true. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  1355. </ul>
  1356. </td>
  1357. </tr>
  1358. <tr>
  1359. <td>setWindow(start, end [, options, callback])</td>
  1360. <td>none</td>
  1361. <td>Set the current visible window. The parameters <code>start</code> and <code>end</code> can be a <code>Date</code>, <code>Number</code>, or <code>String</code>. If the parameter value of <code>start</code> or <code>end</code> is null, the parameter will be left unchanged. Available options:
  1362. <ul>
  1363. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  1364. </ul>
  1365. A callback <code>function</code> can be passed as an optional parameter. This function will be called at the end of setWindow function.
  1366. </td>
  1367. </tr>
  1368. <tr>
  1369. <td>toggleRollingMode()</td>
  1370. <td>none</td>
  1371. <td>Toggle rollingMode.
  1372. </td>
  1373. </tr>
  1374. <tr>
  1375. <td>zoomIn(percentage [, options, callback])</td>
  1376. <td>none</td>
  1377. <td>Zoom in the current visible window. The parameter <code>percentage</code> can be a <code>Number</code> and must be between 0 and 1. If the parameter value of <code>percentage</code> is null, the window will be left unchanged. Available options:
  1378. <ul>
  1379. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  1380. </ul>
  1381. A callback <code>function</code> can be passed as an optional parameter. This function will be called at the end of zoomIn function.
  1382. </td>
  1383. </tr>
  1384. <tr>
  1385. <td>zoomOut(percentage [, options, callback])</td>
  1386. <td>none</td>
  1387. <td>Zoom out the current visible window. The parameter <code>percentage</code> can be a <code>Number</code> and must be between 0 and 1. If the parameter value of <code>percentage</code> is null, the window will be left unchanged. Available options:
  1388. <ul>
  1389. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  1390. </ul>
  1391. A callback <code>function</code> can be passed as an optional parameter. This function will be called at the end of zoomOut function.
  1392. </td>
  1393. </tr>
  1394. </table>
  1395. <h2 id="Events">Events</h2>
  1396. <p>
  1397. Timeline fires events when changing the visible window by dragging, when
  1398. selecting items, and when dragging the custom time bar.
  1399. </p>
  1400. <p>
  1401. Here an example on how to listen for a <code>select</code> event.
  1402. </p>
  1403. <pre class="prettyprint lang-js">
  1404. timeline.on('select', function (properties) {
  1405. alert('selected items: ' + properties.items);
  1406. });
  1407. </pre>
  1408. <p>
  1409. A listener can be removed via the function <code>off</code>:
  1410. </p>
  1411. <pre class="prettyprint lang-js">
  1412. function onSelect (properties) {
  1413. alert('selected items: ' + properties.items);
  1414. }
  1415. // add event listener
  1416. timeline.on('select', onSelect);
  1417. // do stuff...
  1418. // remove event listener
  1419. timeline.off('select', onSelect);
  1420. </pre>
  1421. <p>
  1422. The following events are available.
  1423. </p>
  1424. <table class="events">
  1425. <tr>
  1426. <th>Name</th>
  1427. <th>Properties</th>
  1428. <th>Description</th>
  1429. </tr>
  1430. <tr>
  1431. <td>currentTimeTick</td>
  1432. <td>Has no properties</td>
  1433. <td>Fired when the current time bar redraws. The rate depends on the zoom level.</td>
  1434. </tr>
  1435. <tr>
  1436. <td>click</td>
  1437. <td>
  1438. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1439. </td>
  1440. <td>Fired when clicked inside the Timeline.
  1441. </td>
  1442. </tr>
  1443. <tr>
  1444. <td>contextmenu</td>
  1445. <td>
  1446. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1447. </td>
  1448. <td>Fired when right-clicked inside the Timeline. Note that in order to prevent the context menu from showing up, default behavior of the event must be stopped:
  1449. <pre class="prettyprint lang-js">timeline.on('contextmenu', function (props) {
  1450. alert('Right click!');
  1451. props.event.preventDefault();
  1452. });
  1453. </pre>
  1454. </td>
  1455. </tr>
  1456. <tr>
  1457. <td>doubleClick</td>
  1458. <td>
  1459. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1460. </td>
  1461. <td>Fired when double clicked inside the Timeline.
  1462. </td>
  1463. </tr>
  1464. <tr>
  1465. <td>drop</td>
  1466. <td>
  1467. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1468. </td>
  1469. <td>Fired when dropping inside the Timeline.
  1470. </td>
  1471. </tr>
  1472. <tr>
  1473. <td>mouseOver</td>
  1474. <td>
  1475. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1476. </td>
  1477. <td>Fired when the mouse hovers over a timeline element.
  1478. </td>
  1479. </tr>
  1480. <tr>
  1481. <td>mouseDown</td>
  1482. <td>
  1483. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1484. </td>
  1485. <td>Fired when the mouse down event is triggered over a timeline element.
  1486. </td>
  1487. </tr>
  1488. <tr>
  1489. <td>mouseUp</td>
  1490. <td>
  1491. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1492. </td>
  1493. <td>Fired when the mouse up event is triggered over a timeline element.
  1494. </td>
  1495. </tr>
  1496. <tr>
  1497. <td>mouseMove</td>
  1498. <td>
  1499. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1500. </td>
  1501. <td>Fired when the mouse is moved over a timeline element.
  1502. </td>
  1503. </tr>
  1504. <tr>
  1505. <td>groupDragged</td>
  1506. <td>
  1507. Passes the id of the dragged group.
  1508. </td>
  1509. <td>Fired after the dragging of a group is finished.
  1510. </td>
  1511. </tr>
  1512. <tr>
  1513. <td>changed</td>
  1514. <td>
  1515. Has no properties.
  1516. </td>
  1517. <td>Fired once after each graph redraw.
  1518. </td>
  1519. </tr>
  1520. <tr>
  1521. <td>rangechange</td>
  1522. <td>
  1523. <ul>
  1524. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  1525. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  1526. <li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
  1527. <li><code>event</code> (Object): original event triggering the rangechange.</li>
  1528. </ul>
  1529. </td>
  1530. <td>Fired repeatedly when the timeline window is being changed.
  1531. </td>
  1532. </tr>
  1533. <tr>
  1534. <td>rangechanged</td>
  1535. <td>
  1536. <ul>
  1537. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  1538. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  1539. <li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
  1540. <li><code>event</code> (Object): original event triggering the rangechanged.</li>
  1541. </ul>
  1542. </td>
  1543. <td>Fired once after the timeline window has been changed.
  1544. </td>
  1545. </tr>
  1546. <tr>
  1547. <td>select</td>
  1548. <td>
  1549. <ul>
  1550. <li><code>items</code>: an array with the ids of the selected items</li>
  1551. <li><code>event</code>: the original click event</li>
  1552. </ul>
  1553. </td>
  1554. <td>Fired after the user selects or deselects items by tapping or holding them.
  1555. When a user taps an already selected item, the select event is fired again.
  1556. Not fired when the method <code>setSelection</code>is executed.
  1557. </td>
  1558. </tr>
  1559. <tr>
  1560. <td>itemover</td>
  1561. <td>
  1562. <ul>
  1563. <li><code>item</code>: hovered item id</li>
  1564. <li><code>event</code>: the original mouseover event</li>
  1565. </ul>
  1566. </td>
  1567. <td>Fired when the user moves the mouse over an item.</td>
  1568. </tr>
  1569. <tr>
  1570. <td>itemout</td>
  1571. <td>
  1572. <ul>
  1573. <li><code>item</code>: hovered item id</li>
  1574. <li><code>event</code>: the original mouseout event</li>
  1575. </ul>
  1576. </td>
  1577. <td>Fired when the user moves the mouse out of an item.</td>
  1578. </tr>
  1579. <tr>
  1580. <td>timechange</td>
  1581. <td>
  1582. <ul>
  1583. <li><code>id</code> (Number or String): custom time bar id.</li>
  1584. <li><code>time</code> (Date): the custom time.</li>
  1585. <li><code>event</code> (Object): original event triggering the timechange.</li>
  1586. </ul>
  1587. </td>
  1588. <td>Fired repeatedly when the user is dragging the custom time bar.
  1589. Only available when the custom time bar is enabled.
  1590. </td>
  1591. </tr>
  1592. <tr>
  1593. <td>timechanged</td>
  1594. <td>
  1595. <ul>
  1596. <li><code>id</code> (Number or String): custom time bar id.</li>
  1597. <li><code>time</code> (Date): the custom time.</li>
  1598. <li><code>event</code> (Object): original event triggering the timechanged.</li>
  1599. </ul>
  1600. </td>
  1601. <td>Fired once after the user has dragged the custom time bar.
  1602. Only available when the custom time bar is enabled.
  1603. </td>
  1604. </tr>
  1605. </table>
  1606. <h2 id="Editing_Items">Editing Items</h2>
  1607. <p>
  1608. When the Timeline is configured to be editable (both options <code>selectable</code> and <code>editable</code> are <code>true</code>), the user can:
  1609. </p>
  1610. <ul>
  1611. <li>Select an item by clicking it, and use ctrl+click to or shift+click to select multiple items (when <code>multiselect: true</code>).</li>
  1612. <li>Move selected items by dragging them.</li>
  1613. <li>Create a new item by double tapping on an empty space.</li>
  1614. <li>Create a new range item by dragging on an empty space with the ctrl key down.</li>
  1615. <li>Update an item by double tapping it.</li>
  1616. <li>Delete a selected item by clicking the delete button on the top right.</li>
  1617. </ul>
  1618. <p>Option <code>editable</code> accepts a boolean or an object. When <code>editable</code> is a boolean, all manipulation actions will be either enabled or disabled. When <code>editable</code> is an object, one can enable individual manipulation actions:</p>
  1619. <pre class="prettyprint lang-js">// enable or disable all manipulation actions
  1620. var options = {
  1621. editable: true // true or false
  1622. };
  1623. // enable or disable individual manipulation actions
  1624. var options = {
  1625. editable: {
  1626. add: true, // add new items by double tapping
  1627. updateTime: true, // drag items horizontally
  1628. updateGroup: true, // drag items from one group to another
  1629. remove: true, // delete an item by tapping the delete button top right
  1630. overrideItems: false // allow these options to override item.editable
  1631. }
  1632. };</pre>
  1633. <p>
  1634. Editing can be enabled/disabled for specific items. Setting the property <code>editable</code> to <code>true</code> or <code>false</code> on a data item will override the timeline option except when <code>timeline.editable.overrideItems</code> is set to <code>true</code>.
  1635. </p>
  1636. <pre class="prettyprint lang-js">
  1637. var items = new vis.DataSet([
  1638. {id: 1, content: 'read-only item', start: '2013-04-20', editable: false},
  1639. {id: 2, content: 'editable item', start: '2013-04-14'}
  1640. ]);
  1641. </pre>
  1642. <p>
  1643. Individual manipulation actions (<code>updateTime</code>, <code>updateGroup</code> and <code>remove</code>) can also be set on individual items. If any of the item-level
  1644. actions are specified (and <code>overrideItems</code> is not <code>false</code>) then that takes precedence over the settings at the timeline level. Current behavior is
  1645. that if any of the item-level actions are not specified, those items get <code>undefined</code> value (rather than inheriting from the timeline level). This may change
  1646. in future major releases, and code that specifies all item level values will handle major release changes better. That is, instead of using
  1647. <code>editable: {updateTime : true}</code>, use <code>editable: {updateTime : true, updateGroup: false, remove: false}</code>.
  1648. </p>
  1649. <p>
  1650. One can specify callback functions to validate changes made by the user. There are a number of callback functions for this purpose:
  1651. </p>
  1652. <ul>
  1653. <li><code>onAdd(item, callback)</code> Fired when a new item is about to be added. If not implemented, the item will be added with default text contents.</li>
  1654. <li><code>onUpdate(item, callback)</code> Fired when an item is about to be updated. This function typically has to show a dialog where the user change the item. If not implemented, nothing happens.</li>
  1655. <li><code>onDropObjectOnItem(objectData, item)</code> Fired when an object is dropped in to an existing timeline item.</li>
  1656. <li><code>onMove(item, callback)</code> Fired when an item has been moved. If not implemented, the move action will be accepted.</li>
  1657. <li><code>onMoving(item, callback)</code> Fired repeatedly while an item is being moved (dragged). Can be used to adjust the items start, end, and/or group to allowed regions.</li>
  1658. <li><code>onRemove(item, callback)</code> Fired when an item is about to be deleted. If not implemented, the item will be always removed.</li>
  1659. </ul>
  1660. <p>
  1661. Each of the callbacks is invoked with two arguments:
  1662. </p>
  1663. <ul>
  1664. <li><code>item</code>: the item being manipulated</li>
  1665. <li><code>callback</code>: a callback function which must be invoked to report back. The callback must be invoked as <code>callback(item)</code> or <code>callback(null)</code>.
  1666. Here, <code>item</code> can contain changes to the passed item. Parameter <code>item</code> typically contains fields `content`, `start`, and optionally `end`. The type of `start`
  1667. and `end` is determined by the DataSet type configuration and is `Date` by default. When invoked as <code>callback(null)</code>, the action will be cancelled.</li>
  1668. </ul>
  1669. <p>
  1670. Example code:
  1671. </p>
  1672. <pre class="prettyprint lang-js">var options = {
  1673. onUpdate: function (item, callback) {
  1674. item.content = prompt('Edit items text:', item.content);
  1675. if (item.content != null) {
  1676. callback(item); // send back adjusted item
  1677. }
  1678. else {
  1679. callback(null); // cancel updating the item
  1680. }
  1681. }
  1682. };
  1683. </pre>
  1684. A full example is available here: <a href="../../examples/timeline/editing/editingItemsCallbacks.html">editingItemsCallbacks.html</a>.
  1685. <h2 id="Templates">Templates</h2>
  1686. <p>
  1687. Timeline supports templates to format item contents. Any template engine (such as <a href="http://handlebarsjs.com/">handlebars</a> or <a href="http://mustache.github.io/">mustache</a>) can be used, and one can also manually build HTML. In the options, one can provide a template handler. This handler is a function accepting an item's data as the first argument, the item element as the second argument and the edited data as the third argument, and outputs formatted HTML:
  1688. </p>
  1689. <pre class="prettyprint lang-js">var options = {
  1690. template: function (item, element, data) {
  1691. var html = ... // generate HTML markup for this item
  1692. return html;
  1693. }
  1694. };
  1695. </pre>
  1696. <h3>Create HTML manually</h3>
  1697. The HTML for an item can be created manually:
  1698. <pre class="prettyprint lang-js">var options = {
  1699. template: function (item, element, data) {
  1700. return '&lt;h1&gt;' + item.header + data.moving?' '+ data.start:'' + '&lt;/h1&gt;&lt;p&gt;' + item.description + '&lt;/p&gt;';
  1701. },
  1702. onMoving: function (item, callback) {
  1703. item.moving = true;
  1704. }
  1705. };
  1706. </pre>
  1707. <h3>Using a template engine</h3>
  1708. Using <a href="http://handlebarsjs.com/">handlebars</a>, one can write the template in HTML:
  1709. <pre class="prettyprint lang-html">
  1710. &lt;script id="item-template" type="text/x-handlebars-template"&gt;
  1711. &lt;h1&gt;{{header}}&lt;/h1&gt;
  1712. &lt;p&gt;{{description}}&lt;/p&gt;
  1713. &lt;/script&gt;
  1714. </pre>
  1715. Compile the template:
  1716. <pre class="prettyprint lang-js">
  1717. var source = document.getElementById('item-template').innerHTML;
  1718. var template = Handlebars.compile(source);
  1719. </pre>
  1720. And then specify the template in the Timeline options
  1721. <pre class="prettyprint lang-js">var options = {
  1722. template: template
  1723. };
  1724. </pre>
  1725. <h3>React templates</h3>
  1726. You can use a React component for the templates by rendering them to the templates' element directly:
  1727. <pre class="prettyprint lang-js">
  1728. template: function (item, element, data) {
  1729. return ReactDOM.render(&lt;b&gt;{item.content}&lt;/b&gt;, element);
  1730. },
  1731. </pre>
  1732. <h3>Multiple templates</h3>
  1733. In order to support multiple templates, the template handler can be extended to switch between different templates, depending on a specific item property:
  1734. <pre class="prettyprint lang-js">
  1735. var templates = {
  1736. template1: Handlebars.compile(...),
  1737. template2: Handlebars.compile(...),
  1738. template2: Handlebars.compile(...),
  1739. ...
  1740. };
  1741. var options = {
  1742. template: function (item, element, data) {
  1743. var template = templates[item.template]; // choose the right template
  1744. return template(item); // execute the template
  1745. }
  1746. };
  1747. </pre>
  1748. Now the items can be extended with a property <code>template</code>, specifying which template to use for the item.
  1749. <h2 id="Localization">Localization</h2>
  1750. <p>
  1751. Timeline can be localized. For localization, Timeline depends largely on the localization of <a href="http://momentjs.com">moment.js</a>. Locales are not included in vis.js by default. To enable localization, moment.js must be loaded with locales. Moment.js offers a bundle named "moment-with-locales.min.js" for this and there are various alternative ways to load locales.
  1752. </p>
  1753. <p>
  1754. To set a locale for the Timeline, specify the option <code>locale</code>:
  1755. </p>
  1756. <pre class="prettyprint lang-js">var options = {
  1757. locale: 'nl'
  1758. };
  1759. </pre>
  1760. <h3>Create a new locale</h3>
  1761. To load a locale (that is not supported by default) into the Timeline, one can add a new locale to the option <code>locales</code>:
  1762. <pre class="prettyprint lang-js">var options = {
  1763. locales: {
  1764. // create a new locale (text strings should be replaced with localized strings)
  1765. mylocale: {
  1766. current: 'current',
  1767. time: 'time',
  1768. }
  1769. },
  1770. // use the new locale
  1771. locale: 'mylocale'
  1772. };
  1773. </pre>
  1774. <h3 id="available-locales">Available locales</h3>
  1775. <p>
  1776. Timeline comes with support for the following locales:
  1777. </p>
  1778. <table>
  1779. <tr>
  1780. <th>Language</th>
  1781. <th>Code</th>
  1782. </tr>
  1783. <tr>
  1784. <td>English</td>
  1785. <td>
  1786. <code>en</code><br>
  1787. <code>en_EN</code><br>
  1788. <code>en_US</code>
  1789. </td>
  1790. </tr>
  1791. <tr>
  1792. <td>Italian</td>
  1793. <td>
  1794. <code>it</code><br>
  1795. <code>it_IT</code><br>
  1796. <code>it_CH</code>
  1797. </td>
  1798. </tr>
  1799. <tr>
  1800. <td>Dutch</td>
  1801. <td>
  1802. <code>nl</code><br>
  1803. <code>nl_NL</code><br>
  1804. <code>nl_BE</code>
  1805. </td>
  1806. </tr>
  1807. <tr>
  1808. <td>German</td>
  1809. <td>
  1810. <code>de</code><br>
  1811. <code>de_DE</code><br>
  1812. </td>
  1813. </tr>
  1814. </table>
  1815. <h2 id="Time_zone">Time zone</h2>
  1816. <p>
  1817. By default, the Timeline displays time in local time. To display a Timeline in another time zone or in UTC, the date constructor can be overloaded via the configuration option <code>moment</code>, which by default is the constructor function of moment.js. More information about UTC with moment.js can be found in the docs: <a href="http://momentjs.com/docs/#/parsing/utc/">http://momentjs.com/docs/#/parsing/utc/</a>.
  1818. </p>
  1819. <p>
  1820. Examples:
  1821. </p>
  1822. <pre class="prettyprint lang-js">// display in UTC
  1823. var options = {
  1824. moment: function(date) {
  1825. return vis.moment(date).utc();
  1826. }
  1827. };
  1828. // display in UTC +08:00
  1829. var options = {
  1830. moment: function(date) {
  1831. return vis.moment(date).utcOffset('+08:00');
  1832. }
  1833. };
  1834. </pre>
  1835. <h2 id="Styles">Styles</h2>
  1836. <p>
  1837. All parts of the Timeline have a class name and a default css style.
  1838. The styles can be overwritten, which enables full customization of the layout
  1839. of the Timeline.
  1840. </p>
  1841. <p>For example, to change the border and background color of all items, include the
  1842. following code inside the head of your html code or in a separate stylesheet.</p>
  1843. <pre class="prettyprint lang-html">&lt;style&gt;
  1844. .vis-item {
  1845. border-color: orange;
  1846. background-color: yellow;
  1847. }
  1848. &lt;/style&gt;
  1849. </pre>
  1850. <h3 id="Grid_Backgrounds">Grid Backgrounds</h3>
  1851. <p>
  1852. The background grid of the time axis can be styled, for example to highlight
  1853. weekends or to create grids with an alternating white/lightgray background.
  1854. </p>
  1855. <p>
  1856. Depending on the zoom level, the grids get certain css classes attached.
  1857. The following classes are available:
  1858. </p>
  1859. <table class="styles">
  1860. <tr>
  1861. <th>Description</th><th>Values</th>
  1862. </tr>
  1863. <tr>
  1864. <td>Alternating columns</td><td><code>vis-even</code>, <code>vis-odd</code></td>
  1865. </tr>
  1866. <tr>
  1867. <td>Current date</td><td><code>vis-today</code>, <code>vis-tomorrow</code>, <code>vis-yesterday</code>, <code>vis-current-week</code>, <code>vis-current-month</code>, <code>vis-current-year</code></td>
  1868. </tr>
  1869. <tr>
  1870. <td>Hours</td><td><code>vis-h0</code>, <code>vis-h1</code>, ..., <code>vis-h23</code></td>
  1871. </tr>
  1872. <tr>
  1873. <td>Grouped hours</td><td><code>vis-h0-h4</code> to <code>vis-h20-h24</code></td>
  1874. </tr>
  1875. <tr>
  1876. <td>Weekday</td><td><code>vis-monday</code>, <code>vis-tuesday</code>, <code>vis-wednesday</code>, <code>vis-thursday</code>, <code>vis-friday</code>, <code>vis-saturday</code>, <code>vis-sunday</code></td>
  1877. </tr>
  1878. <tr>
  1879. <td>Days</td><td><code>vis-day1</code>, <code>vis-day2</code>, ..., <code>vis-day31</code></td>
  1880. </tr>
  1881. <tr>
  1882. <td>Week</td><td><code>vis-week1</code>, <code>vis-week2</code>, ..., <code>vis-week53</code></td>
  1883. </tr>
  1884. <tr>
  1885. <td>Months</td><td><code>vis-january</code>, <code>vis-february</code>, <code>vis-march</code>, <code>vis-april</code>, <code>vis-may</code>, <code>vis-june</code>, <code>vis-july</code>, <code>vis-august</code>, <code>vis-september</code>, <code>vis-october</code>, <code>vis-november</code>, <code>vis-december</code></td>
  1886. </tr>
  1887. <tr>
  1888. <td>Years</td><td><code>vis-year2014</code>, <code>vis-year2015</code>, ...</td>
  1889. </tr>
  1890. </table>
  1891. <p>
  1892. Note: the 'week' scale is not included in the automatic zoom levels as its scale is not a direct logical successor of 'days' nor a logical predecessor of 'months'
  1893. </p>
  1894. <p>Examples:</p>
  1895. <pre class="prettyprint lang-html">&lt;style&gt;
  1896. /* alternating column backgrounds */
  1897. .vis-time-axis .grid.vis-odd {
  1898. background: #f5f5f5;
  1899. }
  1900. /* gray background in weekends, white text color */
  1901. .vis-time-axis .vis-grid.vis-saturday,
  1902. .vis-time-axis .vis-grid.vis-sunday {
  1903. background: gray;
  1904. }
  1905. .vis-time-axis .vis-text.vis-saturday,
  1906. .vis-time-axis .vis-text.vis-sunday {
  1907. color: white;
  1908. }
  1909. &lt;/style&gt;
  1910. </pre>
  1911. <h3 id="Performance_Tips">Performance Tips</h3>
  1912. <p>Defining a timeline with many items and/or groups might affect initial loading time and general performance.
  1913. Here are some tips to improve performance and avoid slow loading time:</p>
  1914. <ul>
  1915. <li>Define items and group with <code>DataSets</code></li>
  1916. <li>Avoid applying heavy CSS on items (such as <code>box-shadow</code>, gradient background colors, etc.)</li>
  1917. <li>Defining a <code>start</code> and an <code>end</code> in the timeline options.
  1918. This will improve initial loading time.</li>
  1919. </ul>
  1920. </div>
  1921. <?js= self.partial('tmpl/html-foot.tmpl') ?>