Working on stacked buttons.

This commit is contained in:
2019-07-30 16:56:29 +02:00
parent 0bcf931465
commit 5f46b4feae
115 changed files with 3277 additions and 5134 deletions
+12 -75
View File
@@ -89,24 +89,13 @@ export class Ticks {
return date.toLocaleDateString('de', format)
}
draw(
timeline,
range,
width,
height,
available,
format,
nextFormat,
level,
extraTicks = false
) {
draw(timeline, range, width, height, available, format, nextFormat, level, extraTicks = false) {
let first = null
let last = null
let keyedFormat = format ? format[this.formatKey] : null
let keyedNextFormat = nextFormat ? nextFormat[this.formatKey] : null
let redundant = nextFormat ? this.formatKey in nextFormat : false
let fullyRedundant =
keyedFormat != null && keyedFormat == keyedNextFormat
let fullyRedundant = keyedFormat != null && keyedFormat == keyedNextFormat
let y = timeline.getY()
for (let { start, end } of this.iterRanges(range)) {
let x = timeline.toX(start)
@@ -131,12 +120,7 @@ export class Ticks {
}
if (!fullyRedundant) {
timeline.ensureLabel(
key,
text,
{ x: xx, y: yy, align },
FontInfo.small
)
timeline.ensureLabel(key, text, { x: xx, y: yy, align }, FontInfo.small)
}
if (extraTicks) timeline.drawTick(x, -level)
}
@@ -286,11 +270,7 @@ export class DayTicks extends Ticks {
}
iterStart(start) {
return Dates.create(
start.getFullYear(),
start.getMonth(),
start.getDate()
)
return Dates.create(start.getFullYear(), start.getMonth(), start.getDate())
}
next(date) {
@@ -331,22 +311,11 @@ export class HourTicks extends Ticks {
}
dateKey(date) {
return (
this.key +
date.getFullYear() +
date.getMonth() +
date.getDate() +
date.getHours()
)
return this.key + date.getFullYear() + date.getMonth() + date.getDate() + date.getHours()
}
iterStart(start) {
return Dates.create(
start.getFullYear(),
start.getMonth(),
start.getDate(),
start.getHours()
)
return Dates.create(start.getFullYear(), start.getMonth(), start.getDate(), start.getHours())
}
next(date) {
@@ -388,14 +357,7 @@ export class MinuteTicks extends Ticks {
}
dateKey(date) {
return (
this.key +
date.getFullYear() +
date.getMonth() +
date.getDate() +
date.getHours() +
date.getMinutes()
)
return this.key + date.getFullYear() + date.getMonth() + date.getDate() + date.getHours() + date.getMinutes()
}
iterStart(start) {
@@ -450,10 +412,7 @@ export class TimeTicks {
let available = amount * size
availables.set(ticks, available)
if (available < ticks.minWidth) break
formats.set(
ticks,
available < ticks.minLabelWidth ? null : ticks.format(available)
)
formats.set(ticks, available < ticks.minLabelWidth ? null : ticks.format(available))
nextFormats.set(previous, formats.get(ticks))
previous = ticks
visible.push(ticks)
@@ -522,16 +481,7 @@ export class ColorRanges {
}
export default class Timeline extends BitmapLabeledGraphics {
constructor(
width,
height,
{
ticks = null,
baseLine = 0.5,
showRange = true,
throwDamping = 0.95
} = {}
) {
constructor(width, height, { ticks = null, baseLine = 0.5, showRange = true, throwDamping = 0.95 } = {}) {
super()
this.wantedWidth = width
this.wantedHeight = height
@@ -548,12 +498,7 @@ export default class Timeline extends BitmapLabeledGraphics {
this.deltas = []
this.labelDates = []
this.colorRanges = []
this.rangeColors = new Cycle(
Colors.eminence,
Colors.steelblue,
Colors.ochre,
Colors.turquoise
)
this.rangeColors = new Cycle(Colors.eminence, Colors.steelblue, Colors.ochre, Colors.turquoise)
this.callbacks = []
this.onTapCallbacks = []
this.onDoubleTapCallbacks = []
@@ -565,14 +510,7 @@ export default class Timeline extends BitmapLabeledGraphics {
this.autoScroll = false
this.direction = -1
this.throwDamping = throwDamping
this.timeticks =
ticks ||
new TimeTicks(
new DecadeTicks(),
new YearTicks(),
new MonthTicks(),
new DayTicks()
)
this.timeticks = ticks || new TimeTicks(new DecadeTicks(), new YearTicks(), new MonthTicks(), new DayTicks())
this.labelPrefix = '__'
}
@@ -729,8 +667,7 @@ export default class Timeline extends BitmapLabeledGraphics {
prepareLabels() {
for (let key of this.labels.keys()) {
if (!key.startsWith(this.labelPrefix))
this.labels.get(key).visible = false
if (!key.startsWith(this.labelPrefix)) this.labels.get(key).visible = false
}
}