-
Install Loon:
npm install loon
Or for yarn:
yarn install loon
-
Create an HTML File:
<html> <head> <title>Loon Example</title> </head> <body> <script src="https://cdn.jsdelivr.net/npm/loonyjs/3...js"></script> <script> const loon = require('loony'); const app = loon.AGGREGATE().create({ container: 'index.html' }); app chart: 'myChart' app.myChart: { chart: { type: 'bar' }, axes: { x: { labels: { data: { get: () => { return this.data } } } }, y: { labels: { data: { get: () => { return this.data } } } } }, tooltips: { callback: (event) => { return this.data[event.y] as { value, id }; } } } </script> <script id="chartScript" src="https://cdn.jsdelivr.net/npm/loonyjs/3...js"></script> <script> const data = { value: [19, 25, 15, 28, 3] }; loon.myChart.data = data; </script> </body> </html> -
Open the Page:
- Save the file as
index.html. - Use a web server like
node http://localhost:3orhttp://localhost:88to serve the page.
- Save the file as
-
Test the Code:
- Open your browser and navigate to the URL where the page is served.
- The chart should display the data with tooltips showing the values.
This example creates a simple bar chart displaying the number of visitors over five days. You can customize the chart by modifying the Loon configuration options to suit your needs.


