(protected configuration: XYGraphConfiguration, private datasource: GraphDataSource)
| 49 | private points: XYGraphPoint[]; |
| 50 | |
| 51 | constructor(protected configuration: XYGraphConfiguration, private datasource: GraphDataSource) { |
| 52 | this.span = configuration.timespan * 1000; |
| 53 | |
| 54 | this.x = d3.scaleLinear().range([0, this.width]).domain([configuration.xMinimum || 0, configuration.xMaximum || 65535]); |
| 55 | this.y = d3.scaleLinear().range([this.height, 0]).domain([configuration.yMinimum || 0, configuration.yMaximum || 65535]); |
| 56 | |
| 57 | this.currentX = configuration.initialX || (((configuration.xMinimum || 0) + (configuration.xMaximum || 65535)) / 2); |
| 58 | this.currentY = configuration.initialY || (((configuration.yMinimum || 0) + (configuration.yMaximum || 65535)) / 2); |
| 59 | |
| 60 | this.line = d3.line<XYGraphPoint>().x((d) => this.x(d.x)).y((d) => this.y(d.y)); |
| 61 | |
| 62 | const wrapper = d3.select('.graph-container').append('div').attr('class', 'graph-wrapper'); |
| 63 | wrapper.append('h3').text(configuration.label); |
| 64 | |
| 65 | // tslint:disable-next-line:max-line-length |
| 66 | this.svg = wrapper.append('svg').attr('width', this.width + this.margins.left + this.margins.right).attr('height', this.height + this.margins.top + this.margins.bottom); |
| 67 | this.g = this.svg.append('g').attr('transform', `translate(${this.margins.left},${this.margins.top})`); |
| 68 | |
| 69 | this.xAxis = this.g.append('g').attr('transform', `translate(0,${this.height})`).call(d3.axisBottom(this.x)); |
| 70 | this.yAxis = this.g.append('g').call(d3.axisLeft(this.y)); |
| 71 | |
| 72 | datasource.subscribe(configuration.xGraphId, this.receivedX.bind(this)); |
| 73 | datasource.subscribe(configuration.yGraphId, this.receivedY.bind(this)); |
| 74 | |
| 75 | this.path = this.g.append('path') |
| 76 | .attr('fill', 'none') |
| 77 | .attr('stroke', 'steelblue') |
| 78 | .attr('stroke-linejoin', 'round') |
| 79 | .attr('stroke-linecap', 'round') |
| 80 | .attr('stroke-width', 1.5); |
| 81 | |
| 82 | window.requestAnimationFrame(this.updateGraph.bind(this)); |
| 83 | |
| 84 | this.points = []; |
| 85 | } |
| 86 | |
| 87 | public stop() { |
| 88 | this.stopped = true; |
nothing calls this directly
no test coverage detected