-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot-x-axis.html
59 lines (48 loc) · 1.36 KB
/
plot-x-axis.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
<link rel="import" href="../polymer/polymer.html">
<dom-module id="plot-x-axis">
<template>
<style>
:host {
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0;
bottom: 0;
}
#x_axis {
width: 100%;
height: 100%;
display: block;
background-color: transparent !important;
}
</style>
<div id="x_axis"></div>
</template>
<script>
Polymer({
is: 'plot-x-axis',
computeXMin: function(){
return this.root.host.parentNode.xmin;
},
computeXMax: function(){
return this.root.host.parentNode.xmax;
},
attached: function(){
let w = Polymer.dom(this.root).node.host.offsetWidth;
let h = Polymer.dom(this.root).node.host.offsetHeight;
// Definimos el eje x
var x_scale = d3.scaleLinear()
.domain([this.computeXMin(), this.computeXMax()])
.range([0, this.root.host.parentNode.width]);
var svg = d3.select(this.$.x_axis)
.append("svg")
.attr("width", w)
.attr("height", h)
.append("g")
.attr("transform", "translate(25, " + (h-25) + ")") // Jst in line with plots
.call(d3.axisBottom(x_scale)); // Just add the damn scale
}
});
</script>
</dom-module>