Skip to content

Instantly share code, notes, and snippets.

@GordonSmith
Last active February 4, 2016 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GordonSmith/8aeb5d704fa014f7260e to your computer and use it in GitHub Desktop.
Save GordonSmith/8aeb5d704fa014f7260e to your computer and use it in GitHub Desktop.
Custom Ordinal Palette

HPCC Palettes

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="http://viz.hpccsystems.com/v1.8.4/dist-amd-src/hpcc-viz.js"></script>
<script src="http://viz.hpccsystems.com/v1.8.4/dist-amd-src/hpcc-bundles.js"></script>
<script>
require.config({
paths: {
"src": "http://viz.hpccsystems.com/v1.8.4/dist-amd-src",
"font-awesome": "http://viz.hpccsystems.com/v1.8.4/dist-amd-src/font-awesome/css/font-awesome.min"
}
});
</script>
</head>
<body>
<div id="placeholder" style="width:100%; height:100vh">
</div>
<script>
require(["src/chart/Pie", "src/common/Palette"], function (Pie, Palette) {
var newPal = Palette.ordinal("RBI", ["green", "antiquewhite", "navy", "red"]);
// If you want to force a colour to a known value, just request them in order after creation:
newPal("Ireland"); //Green
newPal("England"); //white
newPal("Scotland"); //navy
newPal("Wales"); //red
var widget = new Pie()
.target("placeholder")
.paletteID("RBI")
.columns(["Location", "Score"])
.data([["England", 22], ["Wales", 88], ["Scotland", 88], ["Ireland", 88]])
.render()
;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment