1

Cleanup, work on brackets

This commit is contained in:
Alex Yatskov 2015-06-27 14:41:56 +09:00
parent af91fbc5ae
commit 735dc18581

View File

@ -142,37 +142,11 @@
'text-anchor': 'middle' 'text-anchor': 'middle'
}); });
// indicator // indiciator
var range = computeIndicatorRange(_data.value); updateIndicator(_data.value);
_elements.indicator = _canvas.rect(
_tickSize,
range.min,
_width - (_densitySize + _tickSize),
(range.max - range.min)
).attr({
cursor: 'crosshair',
fill: computeIndicatorColor(_data.value)
}).click(clicked);
console.log(_data); // bracket
updateBracket();
// bracketMin
_elements.bracketMin = _canvas.circle(
_width - _bracketSize / 2,
valueToIndicator(_data.bracket.min),
5
).attr({
fill: '#0000ff'
});
// bracketMax
_elements.bracketMax = _canvas.circle(
_width - _bracketSize / 2,
valueToIndicator(_data.bracket.max),
5
).attr({
fill: '#ff0000'
});
// tick // tick
if (_range.contains(0.0)) { if (_range.contains(0.0)) {
@ -207,23 +181,68 @@
function updateIndicator(value) { function updateIndicator(value) {
var range = computeIndicatorRange(value); var range = computeIndicatorRange(value);
_elements.indicator.attr({ var fill = computeIndicatorColor(value);
y: range.min,
height: range.max - range.min,
fill: computeIndicatorColor(value)
});
_valueAnimated = value; if (_.has(_elements, 'indicator')) {
_elements.indicator.attr({
y: range.min,
height: range.max - range.min,
fill: fill
});
_valueAnimated = value;
}
else {
_elements.indicator = _canvas.rect(
_tickSize,
range.min,
_width - (_densitySize + _tickSize),
(range.max - range.min)
).attr({
cursor: 'crosshair',
fill: fill
}).click(clicked);
}
} }
function updateBracket() { function updateBracket() {
_elements.bracketMin.attr({ var vis = _data.bracket.min < _data.bracket.max ? 'visible' : 'hidden';
y: _data.bracket.min var minY = valueToIndicator(_data.bracket.min);
}); var maxY = valueToIndicator(_data.bracket.max);
_elements.bracketMax.attr({ if (_.has(_elements, 'bracketMin')) {
y: _data.bracket.max _elements.bracketMin.attr({
}); visibility: vis,
cy: minY
});
}
else {
_elements.bracketMin = _canvas.circle(
_width - _bracketSize / 2,
minY,
5
).attr({
visibility: vis,
fill: '#0000ff'
});
}
if (_.has(_elements, 'bracketMax')) {
_elements.bracketMax.attr({
visibility: vis,
cy: maxY
});
}
else {
_elements.bracketMax = _canvas.circle(
_width - _bracketSize / 2,
maxY,
5
).attr({
visibility: vis,
fill: '#ff0000'
});
}
} }
function updateDensity() { function updateDensity() {