This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvega-element.html
111 lines (100 loc) · 2.93 KB
/
vega-element.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<html><head><link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../paper-styles/shadow.html">
<link rel="import" href="../neon-animation/neon-animations.html">
<link rel="import" href="../neon-animation/neon-animatable-behavior.html">
<link rel="import" href="./vega-behavior.html">
</head><body><dom-module id="vega-element">
<template>
<style include="iron-flex iron-flex-alignment">
<style>
:host {
display: block;
}
:host.shadow .container{
background-color: var(--vega-bgcolor,#fafafa);
@apply(--shadow-elevation-2dp);
}
.container {
min-width: 100px;
min-height: 100px;
}
</style>
<div class="container">
<section class="layout horizontal">
<section>
<content select=".left"></content>
</section>
<section class="flex">
<content select=".top"></content>
<div id="vega"></div>
<content select=".bottom"></content>
</section>
<section>
<content select=".right"></content>
</section>
<div>
</div></section></div></template>
</dom-module>
<script>
'use strict';
(function () {
'use strict';
/**
* Custom element that wraps around [Vega](https://github.com/vega/vega).
*
* ### Example code
* ```
* <vega-element class="shadow"
* renderer="svg"
* spec="./vega-spec.json">
* <h1 class="top">Vega Element</h1>
* </vega-element>
* ```
*
* The following classes can be applied on *light DOM* to control the insertion points for **vega-element**:
*
* Class | Description
* :--- | :---
* `top` | Inserts above the Vega canvas/svg
* `bottom` | Inserts below the Vega canvas/svg
* `left` | Inserts to the left of the Vega canvas/svg
* `right` | Inserts to the right of the Vega canvas/svg
*
* The following class can be applied to the **vega-element** for styling:
*
* Class | Description
* :--- | :---
* `shadow` | Applies a shadow effect
*
* The following custom properties and mixins are also available for styling:
*
* Custom property | Description | Default
* :--- | :--- | :---
* `--vega-bgcolor` | Background color of the Vega element | `#FAFAFA`
*
* @demo demo/index.html
*/
Polymer({
is: 'vega-element',
properties: {},
behaviors: [Polymer.NeonAnimatableBehavior, Hiveoss.VegaBehavior],
observers: ["render(_chart)"],
/*
* Renders Vega.
*/
render: function render(_chart, data) {
data = data || this.data;
var self = this,
el = this.$.vega,
renderer = this.renderer;
this.view = _chart({
el: el,
data: data,
renderer: renderer
}).update();
this.loading = false;
}
});
})();
</script></body></html>