Column Chart
This example demonstrates a column chart displaying five school subjects and their corresponding exam results. Built with the @hpcc-js/chart framework, it uses a `Column` widget imported from the library to render the visualization. The code defines columns and data via the widget’s `.columns()` and `.data()` methods, then targets an HTML placeholder and calls `.render()`. While the data is hardcoded in the script, the approach highlights how switching from a Pie to a Column chart requires only a single class change, showcasing the framework’s interchangeable visualization components.
AI-generated descriptionTutorial 3: Switch from Pie to Column.
So Pie Charts are so last year, lets switch it up to a Column Chart:
1 - Import the required visualization:
import { Column } from "@hpcc-js/chart";
2 - Instantiate and render the visualisation:
var widget = new Column() // Create new instance of Column
.target("placeholder") // Nominate target on web page
.columns(["Subject", "Result"]) // Set "Columns"
.data([ // Set "Data"
["English", 45],
["Irish", 28],
["Math", 98],
["Geography", 48],
["Science", 82]
])
.render() // Render
;
Note 1: The only difference between this example and the previous one is the change from "Pie" to "Column" this demonstrates one of the key features of the @hpcc-js visualization framework - the ability to switch easily between visualisations for a single data "shape".
Note 2: To discover all the available "published properties" for the Column Widget see: Dermatology-Column and enable the "Properties" view.