plot: add dots option
This commit is contained in:
parent
74bf5bc85d
commit
bb35dbee98
3 changed files with 24 additions and 2 deletions
|
|
@ -21,6 +21,7 @@
|
|||
- property maths: added support for math expressions everywhere via `#{}`
|
||||
- input: add glass effect when `editable` is `false`
|
||||
- `linkId` can now be set as an array of linkIds
|
||||
- plot: added `dots` options
|
||||
|
||||
## 0.23.1
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,10 @@ module.exports = class _plots_base extends Canvas {
|
|||
if (this.getProp('bars')) {
|
||||
this.draw_bars()
|
||||
} else {
|
||||
this.draw_line()
|
||||
var points = this.draw_line()
|
||||
if (this.getProp('dots')) {
|
||||
this.draw_dots(points)
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getProp('pips')) this.draw_pips()
|
||||
|
|
@ -123,7 +126,7 @@ module.exports = class _plots_base extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
if (points.length < 4) return
|
||||
if (points.length < 4) return points
|
||||
|
||||
this.ctx.beginPath()
|
||||
|
||||
|
|
@ -147,6 +150,23 @@ module.exports = class _plots_base extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
return points
|
||||
|
||||
}
|
||||
|
||||
draw_dots(points) {
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.colors.custom
|
||||
this.ctx.strokeStyle = this.colors.track
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
for (var i = 0; i < points.length; i += 2) {
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(points[i], points[i + 1], 4 * PXSCALE, 0, 2*Math.PI)
|
||||
this.ctx.fill()
|
||||
this.ctx.stroke()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
draw_bars() {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ module.exports = class Plot extends _plots_base {
|
|||
rangeX: {min:0,max:1},
|
||||
rangeY: {min:0,max:1},
|
||||
origin: 'auto',
|
||||
dots: true,
|
||||
bars: false,
|
||||
logScaleX: false,
|
||||
logScaleY: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue