|
|
@ -15,7 +15,7 @@ const DEFAULT_LINE_TYPE = LineType.NONE; |
|
|
|
const DEFAULT_LINE_DASHED_AMOUNT = 4; |
|
|
|
const DEFAULT_LINE_DASHED_AMOUNT = 4; |
|
|
|
|
|
|
|
|
|
|
|
export class ChartwerkScatterPod extends ChartwerkPod<ScatterData, ScatterOptions> { |
|
|
|
export class ChartwerkScatterPod extends ChartwerkPod<ScatterData, ScatterOptions> { |
|
|
|
_metricsContainer: any; |
|
|
|
metricContainer: any; |
|
|
|
_delaunayDiagram: DelaunayDiagram; |
|
|
|
_delaunayDiagram: DelaunayDiagram; |
|
|
|
|
|
|
|
|
|
|
|
constructor(el: HTMLElement, _series: ScatterData[] = [], _options: ScatterOptions = {}) { |
|
|
|
constructor(el: HTMLElement, _series: ScatterData[] = [], _options: ScatterOptions = {}) { |
|
|
@ -28,7 +28,6 @@ export class ChartwerkScatterPod extends ChartwerkPod<ScatterData, ScatterOption |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.updateCrosshair(); |
|
|
|
this.updateCrosshair(); |
|
|
|
this.renderMetricContainer(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._delaunayDiagram = new DelaunayDiagram(this.series, this.xScale, this.getYScale.bind(this)); |
|
|
|
this._delaunayDiagram = new DelaunayDiagram(this.series, this.xScale, this.getYScale.bind(this)); |
|
|
|
|
|
|
|
|
|
|
@ -36,19 +35,13 @@ export class ChartwerkScatterPod extends ChartwerkPod<ScatterData, ScatterOption |
|
|
|
this.renderPoints(); |
|
|
|
this.renderPoints(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderMetricContainer(): void { |
|
|
|
clearAllMetrics(): void { |
|
|
|
// container for clip path
|
|
|
|
// TODO: temporary hack before it will be implemented in core.
|
|
|
|
const clipContatiner = this.chartContainer |
|
|
|
this.chartContainer.selectAll('.metric-el').remove(); |
|
|
|
.append('g') |
|
|
|
|
|
|
|
.attr('clip-path', `url(#${this.rectClipId})`) |
|
|
|
|
|
|
|
.attr('class', 'metrics-container'); |
|
|
|
|
|
|
|
// container for panning
|
|
|
|
|
|
|
|
this._metricsContainer = clipContatiner |
|
|
|
|
|
|
|
.append('g') |
|
|
|
|
|
|
|
.attr('class', ' metrics-rect'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected updateCrosshair(): void { |
|
|
|
protected updateCrosshair(): void { |
|
|
|
|
|
|
|
this.crosshair.selectAll('circle').remove(); |
|
|
|
// TODO: Crosshair class, which can be used as Pod
|
|
|
|
// TODO: Crosshair class, which can be used as Pod
|
|
|
|
this.appendCrosshairPoints(); |
|
|
|
this.appendCrosshairPoints(); |
|
|
|
} |
|
|
|
} |
|
|
@ -109,10 +102,10 @@ export class ChartwerkScatterPod extends ChartwerkPod<ScatterData, ScatterOption |
|
|
|
strokeDasharray = DEFAULT_LINE_DASHED_AMOUNT; |
|
|
|
strokeDasharray = DEFAULT_LINE_DASHED_AMOUNT; |
|
|
|
} |
|
|
|
} |
|
|
|
const lineGenerator = this.d3.line() |
|
|
|
const lineGenerator = this.d3.line() |
|
|
|
.x((d: [number, number]) => this.xScale(d[1])) |
|
|
|
.x((d: [number, number]) => this.xScale(d[0])) |
|
|
|
.y((d: [number, number]) => this.getYScale(orientation)(d[0])); |
|
|
|
.y((d: [number, number]) => this.getYScale(orientation)(d[1])); |
|
|
|
|
|
|
|
|
|
|
|
this._metricsContainer |
|
|
|
this.metricContainer |
|
|
|
.append('path') |
|
|
|
.append('path') |
|
|
|
.datum(datapoints) |
|
|
|
.datum(datapoints) |
|
|
|
.attr('class', 'metric-path') |
|
|
|
.attr('class', 'metric-path') |
|
|
@ -130,7 +123,7 @@ export class ChartwerkScatterPod extends ChartwerkPod<ScatterData, ScatterOption |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this._metricsContainer.selectAll(null) |
|
|
|
this.metricContainer.selectAll(null) |
|
|
|
.data(this._delaunayDiagram.data) |
|
|
|
.data(this._delaunayDiagram.data) |
|
|
|
.enter() |
|
|
|
.enter() |
|
|
|
.append('circle') |
|
|
|
.append('circle') |
|
|
@ -139,10 +132,10 @@ export class ChartwerkScatterPod extends ChartwerkPod<ScatterData, ScatterOption |
|
|
|
.attr('r', (d: number[]) => this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) |
|
|
|
.attr('r', (d: number[]) => this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) |
|
|
|
.style('fill', (d: number[]) => this.getSerieColor(_.last(d))) |
|
|
|
.style('fill', (d: number[]) => this.getSerieColor(_.last(d))) |
|
|
|
.style('pointer-events', 'none') |
|
|
|
.style('pointer-events', 'none') |
|
|
|
.attr('cx', (d: any[]) => this.xScale(d[1])) |
|
|
|
.attr('cx', (d: any[]) => this.xScale(d[0])) |
|
|
|
.attr('cy', (d: any[]) => this.getYScale(this.series[_.last(d)].yOrientation)(d[0])); |
|
|
|
.attr('cy', (d: any[]) => this.getYScale(this.series[_.last(d)].yOrientation)(d[1])); |
|
|
|
|
|
|
|
|
|
|
|
this._metricsContainer.selectAll(null) |
|
|
|
this.metricContainer.selectAll(null) |
|
|
|
.data(this._delaunayDiagram.data) |
|
|
|
.data(this._delaunayDiagram.data) |
|
|
|
.enter() |
|
|
|
.enter() |
|
|
|
.append('rect') |
|
|
|
.append('rect') |
|
|
@ -151,8 +144,8 @@ export class ChartwerkScatterPod extends ChartwerkPod<ScatterData, ScatterOption |
|
|
|
.attr('r', (d: number[]) => this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) |
|
|
|
.attr('r', (d: number[]) => this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) |
|
|
|
.style('fill', (d: number[]) => this.getSerieColor(_.last(d))) |
|
|
|
.style('fill', (d: number[]) => this.getSerieColor(_.last(d))) |
|
|
|
.style('pointer-events', 'none') |
|
|
|
.style('pointer-events', 'none') |
|
|
|
.attr('x', (d: number[]) => this.xScale(d[1]) - (this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) / 2) |
|
|
|
.attr('x', (d: number[]) => this.xScale(d[0]) - (this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) / 2) |
|
|
|
.attr('y', (d: number[]) => this.getYScale(this.series[_.last(d)].yOrientation)(d[0]) - (this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) / 2) |
|
|
|
.attr('y', (d: number[]) => this.getYScale(this.series[_.last(d)].yOrientation)(d[1]) - (this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) / 2) |
|
|
|
.attr('width', (d: number[]) => this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) |
|
|
|
.attr('width', (d: number[]) => this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE) |
|
|
|
.attr('height', (d: number[]) => this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE); |
|
|
|
.attr('height', (d: number[]) => this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE); |
|
|
|
} |
|
|
|
} |
|
|
@ -185,10 +178,10 @@ export class ChartwerkScatterPod extends ChartwerkPod<ScatterData, ScatterOption |
|
|
|
const size = this.getCrosshairCircleBackgroundSize(serieIdx); |
|
|
|
const size = this.getCrosshairCircleBackgroundSize(serieIdx); |
|
|
|
const colorFormatter = this.series[serieIdx].colorFormatter; |
|
|
|
const colorFormatter = this.series[serieIdx].colorFormatter; |
|
|
|
this.crosshair.selectAll(`.crosshair-point-${serieIdx}`) |
|
|
|
this.crosshair.selectAll(`.crosshair-point-${serieIdx}`) |
|
|
|
.attr('cx', this.xScale(datapoint[1])) |
|
|
|
.attr('cx', this.xScale(datapoint[0])) |
|
|
|
.attr('cy', this.getYScale(serieOrientation)(datapoint[0])) |
|
|
|
.attr('cy', this.getYScale(serieOrientation)(datapoint[1])) |
|
|
|
.attr('x', this.xScale(datapoint[1]) - size / 2) |
|
|
|
.attr('x', this.xScale(datapoint[0]) - size / 2) |
|
|
|
.attr('y', this.getYScale(serieOrientation)(datapoint[0]) - size / 2) |
|
|
|
.attr('y', this.getYScale(serieOrientation)(datapoint[1]) - size / 2) |
|
|
|
.attr('fill', colorFormatter !== undefined ? colorFormatter(datapoint) : this.series[serieIdx].color) |
|
|
|
.attr('fill', colorFormatter !== undefined ? colorFormatter(datapoint) : this.series[serieIdx].color) |
|
|
|
.style('display', null); |
|
|
|
.style('display', null); |
|
|
|
} |
|
|
|
} |
|
|
|