plot, eq: unclip line on y axis
This commit is contained in:
parent
9d79e857f8
commit
6dbbc9318d
2 changed files with 9 additions and 5 deletions
|
|
@ -131,14 +131,14 @@ export default class Plot extends StaticProperties(Canvas, {bypass: true}) {
|
|||
|
||||
if (this.value[i].length) {
|
||||
points.push(mapToScale(this.value[i][0], [this.rangeX.min, this.rangeX.max], [padding, this.width - padding], -1, this.logScaleX, true))
|
||||
points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true))
|
||||
points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true, true))
|
||||
} else {
|
||||
|
||||
if (i < length - 2 && this.value[i] === previousValue && this.value[i+1] === previousValue) {
|
||||
continue
|
||||
}
|
||||
nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], -1, this.logScaleX, true)
|
||||
ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true)
|
||||
ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true, true)
|
||||
|
||||
if (x !== nx || y !== ny) {
|
||||
points.push(nx)
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@ export function clip(value,range) {
|
|||
// decimals: number (-1 to bypass)
|
||||
// log: true, or manual log scale (max log value)
|
||||
// revertLog: boolean
|
||||
export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog) {
|
||||
export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog, noClip) {
|
||||
|
||||
// clip in
|
||||
value = clip(value,[rangeIn[0], rangeIn[1]])
|
||||
if (!noClip) {
|
||||
value = clip(value,[rangeIn[0], rangeIn[1]])
|
||||
}
|
||||
|
||||
|
||||
// normalize
|
||||
|
|
@ -48,7 +50,9 @@ export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog) {
|
|||
value = value * (rangeOut[1] - rangeOut[0]) + rangeOut[0]
|
||||
|
||||
// clip out
|
||||
value = clip(value, [rangeOut[0], rangeOut[1]])
|
||||
if (!noClip) {
|
||||
value = clip(value, [rangeOut[0], rangeOut[1]])
|
||||
}
|
||||
|
||||
// decimals
|
||||
if (decimals !== -1) value = parseFloat(value.toFixed(decimals))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue