Installation
Choose your integration and build your first complete chart.
Current distribution
Install the package for your integration from your project root. The calculation engine is resolved as a dependency of the renderer.
| Package | Role | Installation |
|---|---|---|
| @neural-charts/web | SVG and browser interaction. | Install this package. |
| @neural-charts/core | Calculation and geometry. | Renderer dependency. |
JavaScript or TypeScript
Install @neural-charts/web. It includes TypeScript types and declares the compatible Core version, which npm installs automatically. Use the example in your application entry point and call dispose when removing its view.
Example
npm install @neural-charts/webindex.html
<div id="chart"></div>
<button type="button" id="remove-chart">Remove chart</button>
<script type="module" src="/src/main.ts"></script>main.ts
import { createChart, type ChartData, type ChartOptions } from '@neural-charts/web';
const data: ChartData = {
"type": "line",
"axes": {
"x": {
"type": "linear"
},
"y": {
"type": "linear",
"includeZero": true
}
},
"series": [
{
"id": "visits",
"name": "Visits",
"data": [
{
"id": "mon",
"x": 1,
"y": 12
},
{
"id": "tue",
"x": 2,
"y": 18
},
{
"id": "wed",
"x": 3,
"y": 15
}
]
}
]
};
const options: ChartOptions = {
"title": "Weekly activity",
"locale": "en",
"height": 360,
"tooltip": {
"enabled": true,
"crosshair": true
}
};
const host = document.getElementById('chart');
if (!host) throw new Error('Chart host missing');
const result = createChart(host, data, options, {
instanceId: 'weekly-visits',
onPointActivate: event => console.log(event.id, event.observation.value),
onDiagnostic: diagnostic => console.error(diagnostic)
});
if (result.status === 'invalid') throw new Error(result.diagnostic.message);
const chart = result.value;
document.getElementById('remove-chart')?.addEventListener('click', () => {
chart.destroy();
}, { once: true });main.js
// @ts-check
import { createChart } from '@neural-charts/web';
/** @type {import('@neural-charts/web').ChartData} */
const data = {
"type": "line",
"axes": {
"x": {
"type": "linear"
},
"y": {
"type": "linear",
"includeZero": true
}
},
"series": [
{
"id": "visits",
"name": "Visits",
"data": [
{
"id": "mon",
"x": 1,
"y": 12
},
{
"id": "tue",
"x": 2,
"y": 18
},
{
"id": "wed",
"x": 3,
"y": 15
}
]
}
]
};
/** @type {import('@neural-charts/web').ChartOptions} */
const options = {
"title": "Weekly activity",
"locale": "en",
"height": 360,
"tooltip": {
"enabled": true,
"crosshair": true
}
};
const host = document.getElementById('chart');
if (!host) throw new Error('Chart host missing');
const result = createChart(host, data, options, {
instanceId: 'weekly-visits',
onPointActivate: event => console.log(event.id, event.observation.value),
onDiagnostic: diagnostic => console.error(diagnostic)
});
if (result.status === 'invalid') throw new Error(result.diagnostic.message);
const chart = result.value;
document.getElementById('remove-chart')?.addEventListener('click', () => {
chart.destroy();
}, { once: true });Public imports
Do not link repository sources, import private dist paths or copy the calculation engine into your application.
Example
import { createChart } from '@neural-charts/web';