Selaa lähdekoodia

add maxAnchorSize for drawing ployline

tags/2.13.0
Caven Chen 3 vuotta sitten
vanhempi
commit
2c3a746ecc
3 muutettua tiedostoa jossa 10 lisäystä ja 1 poistoa
  1. 3
    0
      modules/plot/Plot.js
  2. 5
    0
      modules/plot/draw/DrawPolyline.js
  3. 2
    1
      modules/tools/DrawTool.js

+ 3
- 0
modules/plot/Plot.js Näytä tiedosto

@@ -160,8 +160,11 @@ class Plot {
if (this._currentWorker) {
this._currentWorker.stop()
}
let maxAnchorSize = style?.maxAnchorSize || 999
style && delete style['maxAnchorSize']
this._currentWorker = this._createDrawWorker(type, style)?.start(this, {
...this._options,
maxAnchorSize: maxAnchorSize,
onDrawStop: callback,
clampToModel: clampToModel ?? this._options.clampToModel
})

+ 5
- 0
modules/plot/draw/DrawPolyline.js Näytä tiedosto

@@ -61,8 +61,13 @@ class DrawPolyline extends Draw {
* @private
*/
_onDrawAnchor(position) {
let len = this._positions.length
this._positions.push(position)
this.drawTool.fire(PlotEventType.CREATE_ANCHOR, { position })
if (len >= this._options.maxAnchorSize) {
this._positions.pop()
this.drawTool.fire(PlotEventType.DRAW_STOP)
}
}
}


+ 2
- 1
modules/tools/DrawTool.js Näytä tiedosto

@@ -14,7 +14,8 @@ const DEF_OPTS = {
icon_center: IMG_CIRCLE_YELLOW,
icon_anchor: IMG_CIRCLE_RED,
icon_size: [12, 12],
clampToModel: false
clampToModel: false,
maxAnchorSize: 999
}

class DrawTool {

Loading…
Peruuta
Tallenna