@tetacom/ng-components 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/component/chart/model/enum/drag-point-type.d.ts +5 -0
- package/component/chart/model/point/marker-options.d.ts +2 -0
- package/esm2020/component/chart/core/chart.mjs +3 -3
- package/esm2020/component/chart/drawer/line-drawer.mjs +47 -37
- package/esm2020/component/chart/model/enum/drag-point-type.mjs +7 -0
- package/esm2020/component/chart/model/point/marker-options.mjs +1 -1
- package/fesm2015/tetacom-ng-components.mjs +53 -37
- package/fesm2015/tetacom-ng-components.mjs.map +1 -1
- package/fesm2020/tetacom-ng-components.mjs +54 -38
- package/fesm2020/tetacom-ng-components.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -9985,6 +9985,13 @@ var DispatchType;
|
|
|
9985
9985
|
DispatchType["movePoint"] = "movePoint";
|
|
9986
9986
|
})(DispatchType || (DispatchType = {}));
|
|
9987
9987
|
|
|
9988
|
+
var DragPointType;
|
|
9989
|
+
(function (DragPointType) {
|
|
9990
|
+
DragPointType[DragPointType["x"] = 0] = "x";
|
|
9991
|
+
DragPointType[DragPointType["y"] = 1] = "y";
|
|
9992
|
+
DragPointType[DragPointType["xy"] = 2] = "xy";
|
|
9993
|
+
})(DragPointType || (DragPointType = {}));
|
|
9994
|
+
|
|
9988
9995
|
class LineDrawer {
|
|
9989
9996
|
constructor() {
|
|
9990
9997
|
this.dispatch = d3.dispatch(DispatchType.moveLine, DispatchType.movePoint);
|
|
@@ -9999,44 +10006,9 @@ class LineDrawer {
|
|
|
9999
10006
|
.x((d) => scaleX(d.x))
|
|
10000
10007
|
.y((d) => scaleY(d.y));
|
|
10001
10008
|
const seriesIndex = options.series.findIndex((_) => _.id === series.id);
|
|
10002
|
-
if (markerPoints?.length) {
|
|
10003
|
-
const emit = (event, target) => {
|
|
10004
|
-
this.dispatch.apply(DispatchType.movePoint, {
|
|
10005
|
-
target: series,
|
|
10006
|
-
point: {
|
|
10007
|
-
...target,
|
|
10008
|
-
},
|
|
10009
|
-
event,
|
|
10010
|
-
});
|
|
10011
|
-
};
|
|
10012
|
-
context
|
|
10013
|
-
.selectAll('circle')
|
|
10014
|
-
.data(markerPoints)
|
|
10015
|
-
.enter()
|
|
10016
|
-
.append('circle')
|
|
10017
|
-
.attr('class', 'draggable-marker')
|
|
10018
|
-
.attr('r', (d) => d.marker?.style?.radius || 5)
|
|
10019
|
-
.attr('cx', function (d) {
|
|
10020
|
-
return scaleX(d.x);
|
|
10021
|
-
})
|
|
10022
|
-
.attr('cy', function (d) {
|
|
10023
|
-
return scaleY(d.y);
|
|
10024
|
-
})
|
|
10025
|
-
.style('cursor', 'pointer')
|
|
10026
|
-
.style('fill', (d) => d.marker?.style?.color || 'red')
|
|
10027
|
-
.attr('stroke', (d) => d.marker?.style?.stroke || 'none')
|
|
10028
|
-
.attr('stroke-width', (d) => d.marker?.style?.strokeWidth || 0);
|
|
10029
|
-
context.selectAll('.draggable-marker').call(d3.drag().on('drag start end', function dragged(event, d) {
|
|
10030
|
-
d.x = scaleX.invert(event.sourceEvent?.offsetX);
|
|
10031
|
-
d.y = scaleY.invert(event.sourceEvent?.offsetY);
|
|
10032
|
-
d3.select(this).attr('cx', scaleX(d.x)).attr('cy', scaleY(d.y));
|
|
10033
|
-
context.select('path').attr('d', path);
|
|
10034
|
-
emit(event, d);
|
|
10035
|
-
}));
|
|
10036
|
-
}
|
|
10037
10009
|
context
|
|
10038
10010
|
.append('path')
|
|
10039
|
-
.attr('class', (d) => series?.drag.enable ? 'draggable' :
|
|
10011
|
+
.attr('class', (d) => series?.drag.enable ? 'draggable' : `series-${seriesIndex}`)
|
|
10040
10012
|
.attr('data-draggable-id', seriesIndex)
|
|
10041
10013
|
.attr('fill', 'none')
|
|
10042
10014
|
.attr('stroke', series.color)
|
|
@@ -10122,6 +10094,50 @@ class LineDrawer {
|
|
|
10122
10094
|
if (series?.drag?.extendLine && points?.length) {
|
|
10123
10095
|
drawExtendedLine();
|
|
10124
10096
|
}
|
|
10097
|
+
if (markerPoints?.length) {
|
|
10098
|
+
const emit = (event, target) => {
|
|
10099
|
+
this.dispatch.apply(DispatchType.movePoint, {
|
|
10100
|
+
target: series,
|
|
10101
|
+
point: {
|
|
10102
|
+
...target,
|
|
10103
|
+
},
|
|
10104
|
+
event,
|
|
10105
|
+
});
|
|
10106
|
+
};
|
|
10107
|
+
context
|
|
10108
|
+
.selectAll(`draggable-marker-${seriesIndex}`)
|
|
10109
|
+
.data(markerPoints)
|
|
10110
|
+
.enter()
|
|
10111
|
+
.append('circle')
|
|
10112
|
+
.attr('class', `draggable-marker-${seriesIndex}`)
|
|
10113
|
+
.attr('r', (d) => d.marker?.style?.radius || 5)
|
|
10114
|
+
.attr('cx', function (d) {
|
|
10115
|
+
return scaleX(d.x);
|
|
10116
|
+
})
|
|
10117
|
+
.attr('cy', function (d) {
|
|
10118
|
+
return scaleY(d.y);
|
|
10119
|
+
})
|
|
10120
|
+
.style('cursor', 'pointer')
|
|
10121
|
+
.style('fill', (d) => d.marker?.style?.color || 'red')
|
|
10122
|
+
.attr('stroke', (d) => d.marker?.style?.stroke || 'none')
|
|
10123
|
+
.attr('stroke-width', (d) => d.marker?.style?.strokeWidth || 0);
|
|
10124
|
+
context.selectAll(`.draggable-marker-${seriesIndex}`).call(d3.drag().on('drag start end', function dragged(event, d) {
|
|
10125
|
+
const node = d3.select(this);
|
|
10126
|
+
if (event.type === 'start') {
|
|
10127
|
+
node.raise().classed('active', true);
|
|
10128
|
+
}
|
|
10129
|
+
if (d.marker?.dragType === DragPointType.x) {
|
|
10130
|
+
d.x = scaleX.invert(event.sourceEvent?.offsetX);
|
|
10131
|
+
node.attr('cx', scaleX(d.x));
|
|
10132
|
+
}
|
|
10133
|
+
if (d.marker?.dragType === DragPointType.y) {
|
|
10134
|
+
d.y = scaleY.invert(event.sourceEvent?.offsetY);
|
|
10135
|
+
node.attr('cy', scaleY(d.y));
|
|
10136
|
+
}
|
|
10137
|
+
context.select(`.series-${seriesIndex}`).attr('d', path);
|
|
10138
|
+
emit(event, d);
|
|
10139
|
+
}));
|
|
10140
|
+
}
|
|
10125
10141
|
}
|
|
10126
10142
|
}
|
|
10127
10143
|
|
|
@@ -10631,11 +10647,11 @@ class TetaChart {
|
|
|
10631
10647
|
this.visibleChartWindowWidth = this.caluclateChartWidth();
|
|
10632
10648
|
}
|
|
10633
10649
|
_redraw() {
|
|
10650
|
+
this.drawPlotBands();
|
|
10651
|
+
this.drawPlotLines();
|
|
10634
10652
|
this.drawChart();
|
|
10635
10653
|
this.drawAxis();
|
|
10636
10654
|
this.drawGridLines();
|
|
10637
|
-
this.drawPlotBands();
|
|
10638
|
-
this.drawPlotLines();
|
|
10639
10655
|
this.drawAnnotations();
|
|
10640
10656
|
}
|
|
10641
10657
|
addZoom() {
|