RIFT-15726 - optimize download size -> lodash usage in UI
[osm/UI.git] / skyquake / plugins / composer / src / src / libraries / graph / DescriptorGraphGrid.js
1
2 /*
3 *
4 * Copyright 2016 RIFT.IO Inc
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19 /**
20 * Created by onvelocity on 12/3/15.
21 */
22
23 import d3 from 'd3'
24
25 const defaults = {
26 size: 15,
27 padding: 5
28 };
29
30 export default class DescriptorGraphGrid {
31
32 constructor(graph, props) {
33 this.graph = graph;
34 Object.assign(props, defaults);
35 this.size = props.size;
36 this.padding = props.padding;
37 }
38
39 render() {
40
41 const grid = this.graph.grid;
42 const width = 2 * this.graph.svg.attr('width');
43 const height = 2 * this.graph.svg.attr('height');
44 const yAxis = d3.range(0, height, this.size);
45 const xAxis = d3.range(0, width, this.size);
46
47 grid.selectAll('line.vertical')
48 .data(xAxis)
49 .enter().append('svg:line')
50 .classed('vertical', true)
51 .attr('x1', (d) => d)
52 .attr('y1', 0)
53 .attr('x2', (d) => d)
54 .attr('y2', height);
55
56 grid.selectAll('line.horizontal')
57 .data(yAxis)
58 .enter().append('svg:line')
59 .classed('horizontal', true)
60 .attr('x1', 0)
61 .attr('y1', (d) => d)
62 .attr('x2', width)
63 .attr('y2', (d) => d);
64
65 }
66
67 }