![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@barchart/chart-lib
Advanced tools
The archive contains the following files:
barchart.chart.js
- the chart component you're integrating into your product(s)barchart.chart.d.ts
- TypeScript declaration file for the library; please note that this is useful for both TypeScript and JavaScript projectsindex.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 simultaneouslyindex.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 codestyle.css
- a simple CSS for styling some elements of the UI using a dark themechart.def.json
- a default chart definition (its state) with one symbol plot and the volume study using a dark themeAMZN_Daily.json
- a snapshot of Amazon's daily data for demonstration purposesAMZN_Events.json
- a snapshot of Amazon's events data for demonstration purposespackage.json
- an npm package definitionPlease 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
.
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.
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:
npm i @barchart/chart-lib
or yarn add @barchart/chart-lib
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.
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).
FAQs
Barchart HTML5 Streaming Chart
We found that @barchart/chart-lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.