@anderson-fv/vis-timeline

中文文档
1.1.0发布于 2024/04/10(Apache-2.0 OR MIT)TypeScriptESM + CJS零依赖近 30 天下载 6096

Create a fully customizable, interactive timeline with items and ranges.

原始使用文档
文档目录15 节
  1. Badges
  2. Install
  3. Example
  4. Builds
  5. Standalone build
  6. Peer build
  7. ESNext build
  8. Legacy build
  9. Build
  10. Excluding external dependencies
  11. Test
  12. Contribute
  13. Backers
  14. Sponsors
  15. License

vis-timeline - FORK

NOTE: This is a fork of the original vis-timeline found here: https://github.com/visjs/vis-timeline


example chart

The Timeline/Graph2D is an interactive visualization chart to visualize data in time. The data items can take place on a single date, or have a start and end date (a range). You can freely move and zoom in the timeline by dragging and scrolling in the Timeline. Items can be created, edited, and deleted in the timeline. The time scale on the axis is adjusted automatically, and supports scales ranging from milliseconds to years.

Badges

GitHub contributors GitHub stars

Backers on Open Collective Sponsors on Open Collective

Install

Install via npm:

$ npm install vis-timeline

Example

A basic example on loading a Timeline is shown below. More examples can be found in the examples directory of the project.

<!DOCTYPE html>
<html>
  <head>
    <title>Timeline</title>
    <script
      type="text/javascript"
      src="https://unpkg.com/vis-timeline@latest/standalone/umd/vis-timeline-graph2d.min.js"
    ></script>
    <link
      href="https://unpkg.com/vis-timeline@latest/styles/vis-timeline-graph2d.min.css"
      rel="stylesheet"
      type="text/css"
    />
    <style type="text/css">
      #visualization {
        width: 600px;
        height: 400px;
        border: 1px solid lightgray;
      }
    </style>
  </head>
  <body>
    <div id="visualization"></div>
    <script type="text/javascript">
      // DOM element where the Timeline will be attached
      var container = document.getElementById("visualization");

      // Create a DataSet (allows two way data-binding)
      var items = new vis.DataSet([
        { id: 1, content: "item 1", start: "2014-04-20" },
        { id: 2, content: "item 2", start: "2014-04-14" },
        { id: 3, content: "item 3", start: "2014-04-18" },
        { id: 4, content: "item 4", start: "2014-04-16", end: "2014-04-19" },
        { id: 5, content: "item 5", start: "2014-04-25" },
        { id: 6, content: "item 6", start: "2014-04-27", type: "point" },
      ]);

      // Configuration for the Timeline
      var options = {};

      // Create a Timeline
      var timeline = new vis.Timeline(container, items, options);
    </script>
  </body>
</html>

Builds

There are four builds provided at the moment.

Standalone build

<script
  type="text/javascript"
  src="https://unpkg.com/vis-timeline@latest/standalone/umd/vis-timeline-graph2d.min.js"
></script>
import { Timeline } from "vis-timeline/standalone";

This has no dependencies and therefore is great for things like MWEs but has more issues with interoperability and bundle bloat. For more information see the following example.

Peer build

<script
  type="text/javascript"
  src="https://unpkg.com/vis-timeline@latest/peer/umd/vis-timeline-graph2d.min.js"
></script>
import { Timeline } from "vis-timeline/peer";

For this build to work you have to load Vis Data and Moment (including locales except English) packages yourself. The advantage here is that it works well with other packages. For more information see the following example.

ESNext build

<script
  type="text/javascript"
  src="https://unpkg.com/vis-timeline@latest/esnext/umd/vis-timeline-graph2d.min.js"
></script>
import { Timeline } from "vis-timeline/esnext";

This is the same as the peer build but without any bundled dependencies or pollyfills. It's indented to be used with bundlers like Rollup or Webpack which will fetch the dependencies, prevent duplicate dependencies in the bundle, use transpilers to add necessary polyfills etc.

Legacy build

<script
  type="text/javascript"
  src="https://unpkg.com/vis-timeline@latest/dist/vis-timeline-graph2d.min.js"
></script>
import { Timeline } from "vis-timeline";

This is solely kept for backwards compatibility. It is deprecated and will be removed in case of URLs and replaced by the peer build in case of Node.js/bundlers. Don't use this, please.

Build

To build the library from source, clone the project from github

$ git clone git://github.com/visjs/vis-timeline.git

The source code uses the module style of node (require and module.exports) to organize dependencies. To install all dependencies and build the library, run npm install in the root of the project.

$ cd vis-timeline
$ npm install

Then, the project can be build running:

$ npm run build

Excluding external dependencies

External dependencies such as moment, hammerjs can be excluded in the build by running:

$ npm run build -- -e [comma separated module names]

Example:

$ npm run build -- -e moment,hammerjs

Test

To test the library, install the project dependencies once:

$ npm install

Then run the tests:

$ npm run test

Contribute

Contributions to the vis.js library are very welcome! We can't do this alone!

Backers

Thank you to all our backers! 🙏

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

License

Copyright (c) 2014-2017 Almende B.V. and contributors Copyright (c) 2017-2019 vis.js contributors

This work is dual-licensed under Apache-2.0 and MIT. You can choose between one of them if you use this work.

SPDX-License-Identifier: Apache-2.0 OR MIT

版本与发布记录

@anderson-fv/vis-timeline 共发布 3 个版本,首次发布于 2024/04/09;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.0latest2024/04/102 年前
1.0.12024/04/092 年前
1.0.02024/04/092 年前

关于 @anderson-fv/vis-timeline 的常见问题

@anderson-fv/vis-timeline 是什么?

Create a fully customizable, interactive timeline with items and ranges.

如何安装 @anderson-fv/vis-timeline?

在项目目录运行 npm install @anderson-fv/vis-timeline,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@egjs/hammerjs(^2.0.0)、component-emitter(^1.3.0)、keycharm(^0.2.0 || ^0.3.0 || ^0.4.0)、moment(^2.24.0)、propagating-hammerjs(^1.4.0 || ^2.0.0)、uuid(^3.4.0 || ^7.0.0 || ^8.0.0 || ^9.0.0)、vis-data(^6.3.0 || ^7.0.0)、vis-util(^5.0.1)、xss(^1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anderson-fv/vis-timeline 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anderson-fv/vis-timeline 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@anderson-fv/vis-timeline 可以商用吗?

@anderson-fv/vis-timeline 使用 (Apache-2.0 OR MIT) 许可。可在 Apache-2.0、MIT 中任选其一遵守。选择 Apache-2.0 时,宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@anderson-fv/vis-timeline 的下载量有多少?

根据 npm 官方下载统计,@anderson-fv/vis-timeline 在 2026/10/06 – 2026/11/04 这 30 天内被下载 6,096 次,日均约 203 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anderson-fv/vis-timeline 还在维护吗?

最新版本 1.1.0 发布于 2024/04/10(2 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/04/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。