-
Notifications
You must be signed in to change notification settings - Fork 13
/
nvd3-multi-bar-horizontal.html
119 lines (108 loc) · 2.51 KB
/
nvd3-multi-bar-horizontal.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
112
113
114
115
116
117
118
119
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="nvd3-behavior.html">
<!--
An element to create multi bar horizontal chart using nvd3.
Example:
<nvd3-multi-bar-horizontal
data="[[data]]"
height="100"
width="400"
auto-resize
show-legend></nvd3-multi-bar-horizontal>
Data Format:
```
[{
"key": "Series1",
"color": "#d62728",
"values": [{
"label": "Group A",
"value": -1.8746444827653
}, {
"label": "Group B",
"value": -8.0961543492239
}, {
"label": "Group C",
"value": -0.57072943117674
}]
}, {
"key": "Series2",
"color": "#1f77b4",
"values": [{
"label": "Group A",
"value": 25.307646510375
}, {
"label": "Group B",
"value": 16.756779544553
}, {
"label": "Group C",
"value": 18.451534877007
}]
}]
```
@group NVD3 Elements
@element nvd3-multi-bar-horizontal
@demo demo/nvd3-multi-bar-horizontal.html
@hero hero.svg
-->
<dom-module id="nvd3-multi-bar-horizontal">
<template>
<style include="nvd3-shared-styles"></style>
<!-- We need to put svg tag inside a div to set correct margins -->
<div>
<svg id="svg"></svg>
</div>
</template>
<script>
Polymer({
is: 'nvd3-multi-bar-horizontal',
behaviors: [NVD3.ChartBehavior],
properties: {
/**
* NVD3 chart object.
*/
_chart: {
type: Object,
value: function() {
var that = this;
return nv.models.multiBarHorizontalChart()
.x(function(d) {
return d[that.xProp];
})
.y(function(d) {
return d[that.yProp];
});
}
},
/**
* Configurable x-axis property key
*/
xProp: {
type: String,
value: 'label'
},
/**
* Configurable y-axis property key
*/
yProp: {
type: String,
value: 'value'
},
/**
* Whether to display the legend or not
*/
showLegend: {
type: Boolean,
value: false
},
/**
* NVD3 components which are used in this chart.
* It's required for binding events.
*/
_components: {
type: Array,
value: ['multibar', 'legend', 'controls', 'xAxis', 'yAxis', 'tooltip']
}
}
});
</script>
</dom-module>