Base utilities for charts
import { layer, getSVG } from "https://cdn.jsdelivr.net/npm/@gramex/chartbase@1";
// Create a new g.layer under <svg id="chart-svg"> ONLY IF it does not exist
layer(d3.select("svg#chart-svg"), "g", "layer");
// Get the viewBox width and height of <svg id="chart-svg">
const { width, height } = getSVG("svg#chart-svg");
Install via npm
:
npm install @gramex/chartbase
Use locally as an ES module:
<script type="module">
import chartbase from "./node_modules/@gramex/chartbase/dist/chartbase.js";
</script>
Use via CDN as an ES Module:
<script type="module">
import chartbase from "https://cdn.jsdelivr.net/npm/@gramex/chartbase@1";
</script>
- 1.0.4: 28 Oct 2024. Deploy at gramex-chartbase.straive.app ensure https://cdn.jsdelivr.net/npm/@gramex/chartbase@1 works
- 1.0.3: 18 Aug 2024. Security update
- 1.0.2: 24 Nov 2023. Fix
getSVG()
width and height calculation - 1.0.0: 31 Oct 2023. Initial release
Anand S s.anand@gramener.com