plot: add dots option

This commit is contained in:
jean-emmanuel 2018-02-12 17:30:57 +01:00
parent 74bf5bc85d
commit bb35dbee98
3 changed files with 24 additions and 2 deletions

View file

@ -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() {

View file

@ -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,