Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
112 lines (105 sloc) 4.47 KB
<!doctype html>
<html >
<head>
<meta charset="utf-8">
<title>Vega Visualization examples</title>
<link rel="canonical" href="amps.html">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Questrial" rel="stylesheet" type="text/css">
<script async custom-element="amp-lightbox" src="https://cdn.ampproject.org/v0/amp-lightbox-0.1.js"></script>
<script async custom-element="amp-viz-vega" src="https://cdn.ampproject.org/v0/amp-viz-vega-0.1.js"></script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<style amp-custom>
amp-lightbox amp-viz-vega {
background-color: yellow;
}
</style>
</head>
<body>
<h1>Vega Visualization</h1>
<h2>Responsive size with remote data</h2>
<amp-viz-vega width="400" height="200" layout="responsive" src="vega-data/bar.json">
</amp-viz-vega>
<h2>Responsive size with inline data</h2>
<amp-viz-vega width="400" height="400" layout="responsive">
<!-- https://github.com/vega/vega/blob/master/examples/arc.json -->
<script type="application/json">
{
"width": 400,
"height": 400,
"data": [
{
"name": "table",
"values": [12, 23, 47, 6, 52, 19],
"transform": [{"type": "pie", "field": "data"}]
}
],
"scales": [
{
"name": "r",
"type": "sqrt",
"domain": {"data": "table", "field": "data"},
"range": [20, 100]
}
],
"marks": [
{
"type": "arc",
"from": {"data": "table"},
"properties": {
"enter": {
"x": {"field": {"group": "width"}, "mult": 0.5},
"y": {"field": {"group": "height"}, "mult": 0.5},
"startAngle": {"field": "layout_start"},
"endAngle": {"field": "layout_end"},
"innerRadius": {"value": 20},
"outerRadius": {"scale": "r", "field": "data"},
"stroke": {"value": "#fff"}
},
"update": {
"fill": {"value": "#ccc"}
},
"hover": {
"fill": {"value": "pink"}
}
}
},
{
"type": "text",
"from": {"data": "table"},
"properties": {
"enter": {
"x": {"field": {"group": "width"}, "mult": 0.5},
"y": {"field": {"group": "height"}, "mult": 0.5},
"radius": {"scale": "r", "field": "data", "offset": 8},
"theta": {"field": "layout_mid"},
"fill": {"value": "#000"},
"align": {"value": "center"},
"baseline": {"value": "middle"},
"text": {"field": "data"}
}
}
}
]
}
</script>
</amp-viz-vega>
<h2>fixed-height size world map with remote data pointing to remote data using topojson</h2>
<amp-viz-vega use-data-width height="500" layout="fixed-height" src="vega-data/map.json">
<amp-img placeholder height="500" layout="fixed-height" src="https://placehold.it/400x200?text=Custom Placeholder">
</amp-img>
</amp-viz-vega>
<h2>Responsive size interactive graph with remote data</h2>
<amp-viz-vega width="2" height="1.5" layout="responsive" src="vega-data/nodes.json">
</amp-viz-vega>
<h2>Responsive size inside lightbox</h2>
<button on="tap:vega-lightbox.activate">
Open Lightbox
</button>
<amp-lightbox id="vega-lightbox" layout="nodisplay">
<amp-viz-vega width="400" height="200" layout="responsive" src="vega-data/bar.json">
</amp-viz-vega>
</amp-lightbox>
</body>
</html>
You can’t perform that action at this time.