@barchart/chart-lib

中文文档
2.416.0发布于 2026/11/06UNLICENSEDTypeScriptCommonJS零依赖近 30 天下载 2514

Barchart HTML5 Streaming Chart

原始使用文档
文档目录5 节
  1. The contents of the package
  2. How to run the example
  3. Browser support
  4. Using the library with npm
  5. Where to find more information

Barchart HTML5 chart SDK

The contents of the package

The archive contains the following files:

  1. barchart.chart.js - the chart component you're integrating into your product(s)
  2. barchart.chart.d.ts - TypeScript declaration file for the library; please note that this is useful for both TypeScript and JavaScript projects
  3. index.html - a web page hosting a single chart; please note that you may host many charts inside a single page, we've tested dozens of charts shown simultaneously
  4. index.js - the script needed to add a chart to the page using a custom data feed (complete implementation is provided) for demonstration purposes; in practice, the feed is provided by Barchart and using the chart requires only a few lines of code
  5. style.css - a simple CSS for styling some elements of the UI using a dark theme
  6. chart.def.json - a default chart definition (its state) with one symbol plot and the volume study using a dark theme
  7. AMZN_Daily.json - a snapshot of Amazon's daily data for demonstration purposes
  8. AMZN_Events.json - a snapshot of Amazon's events data for demonstration purposes
  9. package.json - an npm package definition

How to run the example

Please note that because the timeseries data is loaded using JavaScript fetch functionality, the web page must be served using a web server (in other words, you can't just open index.html from the local filesystem). You could use a very mature and popular one that we like on NPM. Assuming you've decompressed the SDK into the chart-lib folder, simply go into the chart-lib folder and run serve .. By default, the server will serve the index.html on a port 5000. In order to keep the example running, please contact Barchart and obtain an API key, which should replace the <YOUR_API_KEY> in the index.js.

Browser support

In order to keep the chart component's size reasonably small, we have built the component for the last EcmaScript (JavaScript) standard. The last 2 versions of all major browsers support this standard, so you will need a modern browser to use the component.

Please note that the component can be made to support older browsers (for example IE 11, we have not tested older versions) at the expense of its size which typically grows significantly for very old browsers.

Using the library with npm

While the example code (index.html and related files) is complete and works, it does not show a modern JavaScript development scenario - it's more akin to a traditional approach where you'd reference the library in your HTML, then use the resources from the Barchart "namespace" in your scripts.

However, this is just one and definitely not the only way of using the library. If you would like to reference and build the library with your code and you are using npm - which practically all modern approaches do - and any of the modern bundlers (Webpack, Rollup, Parcel or Vite) and transpilers like Babel, then please do one of the two:

  1. If you have network access, install our library from npm as usual, that is to say npm i @barchart/chart-lib or yarn add @barchart/chart-lib
  2. If you don't have network access, you may install the package directly from this very archive (no need to decompress) by running npm i /path/to/chart-lib.tgz or yarn add file:/path/to/chart-lib.tgz

You are now able to import any of the functions/classes/constants the chart library exports; these are all documented in the above mentioned TypeScript declaration file. Our module name is @barchart/chart-lib.

The chart component is framework-agnostic and works equally well with any modern JS framework as well as with no framework at all.

Where to find more information

The chart component/SDK does not ship with any form of UI. The API the chart responds to is documented here. We're busy at work making the docs clearer and easier to use, please check back often.

We do have a product - called widget - which includes the UI. A UI builder producing the small snippet of the HTML needed to get the widget on your page can be seen at the widget site. The very same widget powers our demo site. The widget is written using Barchart's cutting edge (proprietary) library which produces Web Components, helping keep the package size small and efficient.

Please note that we're using the component as-is in many of Barchart's products. The component is in production since 2016 and is battle tested across several different scenarios - both page based and SPA based. We're happy to help you integrate the component into your product(s).

版本与发布记录

@barchart/chart-lib 共发布 630 个版本,首次发布于 2020/03/18;过去 12 个月发布了 218 个版本。

版本发布日期距今
2.416.0latest2026/11/061 天前
2.415.42026/11/062 天前
2.415.32026/11/052 天前
2.415.22026/11/052 天前
2.415.12026/11/043 天前
2.415.02026/11/034 天前

关于 @barchart/chart-lib 的常见问题

@barchart/chart-lib 是什么?

Barchart HTML5 Streaming Chart

如何安装 @barchart/chart-lib?

在项目目录运行 npm install @barchart/chart-lib,或使用 pnpm add / yarn add / bun add。

@barchart/chart-lib 支持 TypeScript 吗?

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

@barchart/chart-lib 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@barchart/chart-lib 可以商用吗?

@barchart/chart-lib 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@barchart/chart-lib 的下载量有多少?

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

@barchart/chart-lib 还在维护吗?

最新版本 2.416.0 发布于 2026/11/06(1 天前);至今共发布 630 个版本,其中过去 12 个月发布了 218 个;首次发布于 2020/03/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。