Tutorial 6: HPCC Platform Roxie Data + Column Chart
Fetching data from a HPCC Platform Roxie Query and rendering it in a Visualization:
1 - Create an empty Column chart and render it:
var columnChart = new Column()
.target("placeholder")
.columns(["Location", "male"])
.yAxisTitle("male")
.render()
;
2 - Attach to an existing Query:
var query = Query.attach({ baseUrl: "https://play.hpccsystems.com:18002" }, "roxie", "ie_pop");
3 - Submit a request to the Roxie service (returns a Promise
):
query.submit({
pop_type: popType // male, female, total
}).then(response => {
...
});
4 - Map
the rows to a data array:
var data = response.ie_population.map(function (row) { return [row.location, row.total]; });
5 - Update the Column chart with the mapped data:
columnChart
.columns(["Location", popType])
.yAxisTitle(popType)
.data(data)
.render()
;
xxxxxxxxxx
•
<html>
<head>
<title>Roxie Column Chart</title>
<meta charset="utf-8">
<link rel="stylesheet" href="index.css">
<!-- GetLibs: An in-browser module loader for quick demos -->
<script src="https://unpkg.com/getlibs"></script>
</head>
<body>
<div id="placeholder">
<!-- Placeholder for Visualization -->
</div>
<select id="popType" class="topcorner" onchange="doQuery()">
<option value="male">Males</option>
<option value="female">Females</option>
<option value="total">Total</option>
</select>
<script>
// Load Example JavaScript (via GetLibs)---
System.import('./index.js');
</script>
</body>
</html>
https://unpkg.com/getlibs