@d3fc/d3fc-annotation
Advanced tools
Comparing version 2.4.1 to 2.4.2
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-scale'), require('d3-selection'), require('d3-path'), require('d3-shape'), require('d3-array')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-scale', 'd3-selection', 'd3-path', 'd3-shape', 'd3-array'], factory) : | ||
(factory((global.fc = global.fc || {}),global.d3,global.d3,global.d3,global.d3,global.d3)); | ||
}(this, (function (exports,d3Scale,d3Selection,d3Path,d3Shape,d3Array) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-scale'), require('d3-selection'), require('d3-path'), require('d3-shape'), require('d3-array')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-scale', 'd3-selection', 'd3-path', 'd3-shape', 'd3-array'], factory) : | ||
(global = global || self, factory(global.fc = global.fc || {}, global.d3, global.d3, global.d3, global.d3, global.d3)); | ||
}(this, function (exports, d3Scale, d3Selection, d3Path, d3Shape, d3Array) { 'use strict'; | ||
// "Caution: avoid interpolating to or from the number zero when the interpolator is used to generate | ||
// a string (such as with attr). | ||
// Very small values, when stringified, may be converted to scientific notation and | ||
// cause a temporarily invalid attribute or style property value. | ||
// For example, the number 0.0000001 is converted to the string "1e-7". | ||
// This is particularly noticeable when interpolating opacity values. | ||
// To avoid scientific notation, start or end the transition at 1e-6, | ||
// which is the smallest value that is not stringified in exponential notation." | ||
// - https://github.com/mbostock/d3/wiki/Transitions#d3_interpolateNumber | ||
var effectivelyZero = 1e-6; | ||
// "Caution: avoid interpolating to or from the number zero when the interpolator is used to generate | ||
// a string (such as with attr). | ||
// Very small values, when stringified, may be converted to scientific notation and | ||
// cause a temporarily invalid attribute or style property value. | ||
// For example, the number 0.0000001 is converted to the string "1e-7". | ||
// This is particularly noticeable when interpolating opacity values. | ||
// To avoid scientific notation, start or end the transition at 1e-6, | ||
// which is the smallest value that is not stringified in exponential notation." | ||
// - https://github.com/mbostock/d3/wiki/Transitions#d3_interpolateNumber | ||
var effectivelyZero = 1e-6; | ||
// Wrapper around d3's selectAll/data data-join, which allows decoration of the result. | ||
// This is achieved by appending the element to the enter selection before exposing it. | ||
// A default transition of fade in/out is also implicitly added but can be modified. | ||
var dataJoin = (function (element, className) { | ||
element = element || 'g'; | ||
// Wrapper around d3's selectAll/data data-join, which allows decoration of the result. | ||
// This is achieved by appending the element to the enter selection before exposing it. | ||
// A default transition of fade in/out is also implicitly added but can be modified. | ||
var dataJoin = (function (element, className) { | ||
element = element || 'g'; | ||
var key = function key(_, i) { | ||
return i; | ||
}; | ||
var explicitTransition = null; | ||
var dataJoin = function dataJoin(container, data) { | ||
data = data || function (d) { | ||
return d; | ||
var key = function key(_, i) { | ||
return i; | ||
}; | ||
var explicitTransition = null; | ||
var implicitTransition = container.selection ? container : null; | ||
if (implicitTransition) { | ||
container = container.selection(); | ||
} | ||
var dataJoin = function dataJoin(container, data) { | ||
data = data || function (d) { | ||
return d; | ||
}; | ||
var selected = container.selectAll(function (d, i, nodes) { | ||
return Array.from(nodes[i].childNodes).filter(function (node) { | ||
return node.nodeType === 1; | ||
}); | ||
}).filter(className == null ? element : element + '.' + className); | ||
var update = selected.data(data, key); | ||
var implicitTransition = container.selection ? container : null; | ||
if (implicitTransition) { | ||
container = container.selection(); | ||
} | ||
var enter = update.enter().append(element).attr('class', className); | ||
var selected = container.selectAll(function (d, i, nodes) { | ||
return Array.from(nodes[i].childNodes).filter(function (node) { | ||
return node.nodeType === 1; | ||
}); | ||
}).filter(className == null ? element : element + '.' + className); | ||
var update = selected.data(data, key); | ||
var exit = update.exit(); | ||
var enter = update.enter().append(element).attr('class', className); | ||
// automatically merge in the enter selection | ||
update = update.merge(enter); | ||
var exit = update.exit(); | ||
// if transitions are enabled apply a default fade in/out transition | ||
var transition = implicitTransition || explicitTransition; | ||
if (transition) { | ||
update = update.transition(transition).style('opacity', 1); | ||
enter.style('opacity', effectivelyZero); | ||
exit = exit.transition(transition).style('opacity', effectivelyZero); | ||
} | ||
// automatically merge in the enter selection | ||
update = update.merge(enter); | ||
exit.remove(); | ||
// if transitions are enabled apply a default fade in/out transition | ||
var transition = implicitTransition || explicitTransition; | ||
if (transition) { | ||
update = update.transition(transition).style('opacity', 1); | ||
enter.style('opacity', effectivelyZero); | ||
exit = exit.transition(transition).style('opacity', effectivelyZero); | ||
} | ||
update.enter = function () { | ||
return enter; | ||
exit.remove(); | ||
update.enter = function () { | ||
return enter; | ||
}; | ||
update.exit = function () { | ||
return exit; | ||
}; | ||
return update; | ||
}; | ||
update.exit = function () { | ||
return exit; | ||
dataJoin.element = function () { | ||
if (!arguments.length) { | ||
return element; | ||
} | ||
element = arguments.length <= 0 ? undefined : arguments[0]; | ||
return dataJoin; | ||
}; | ||
dataJoin.className = function () { | ||
if (!arguments.length) { | ||
return className; | ||
} | ||
className = arguments.length <= 0 ? undefined : arguments[0]; | ||
return dataJoin; | ||
}; | ||
dataJoin.key = function () { | ||
if (!arguments.length) { | ||
return key; | ||
} | ||
key = arguments.length <= 0 ? undefined : arguments[0]; | ||
return dataJoin; | ||
}; | ||
dataJoin.transition = function () { | ||
if (!arguments.length) { | ||
return explicitTransition; | ||
} | ||
explicitTransition = arguments.length <= 0 ? undefined : arguments[0]; | ||
return dataJoin; | ||
}; | ||
return update; | ||
}; | ||
dataJoin.element = function () { | ||
if (!arguments.length) { | ||
return element; | ||
} | ||
element = arguments.length <= 0 ? undefined : arguments[0]; | ||
return dataJoin; | ||
}; | ||
dataJoin.className = function () { | ||
if (!arguments.length) { | ||
return className; | ||
} | ||
className = arguments.length <= 0 ? undefined : arguments[0]; | ||
return dataJoin; | ||
}; | ||
dataJoin.key = function () { | ||
if (!arguments.length) { | ||
return key; | ||
} | ||
key = arguments.length <= 0 ? undefined : arguments[0]; | ||
return dataJoin; | ||
}; | ||
dataJoin.transition = function () { | ||
if (!arguments.length) { | ||
return explicitTransition; | ||
} | ||
explicitTransition = arguments.length <= 0 ? undefined : arguments[0]; | ||
return dataJoin; | ||
}; | ||
}); | ||
return dataJoin; | ||
}); | ||
var functor = (function (v) { | ||
return typeof v === 'function' ? v : function () { | ||
return v; | ||
}; | ||
}); | ||
var functor = (function (v) { | ||
return typeof v === 'function' ? v : function () { | ||
return v; | ||
}; | ||
}); | ||
// Renders a bar series as an SVG path based on the given array of datapoints. Each | ||
// bar has a fixed width, whilst the x, y and height are obtained from each data | ||
// point via the supplied accessor functions. | ||
var shapeBar = (function () { | ||
// Renders an OHLC as an SVG path based on the given array of datapoints. Each | ||
// OHLC has a fixed width, whilst the x, open, high, low and close positions are | ||
// obtained from each point via the supplied accessor functions. | ||
var context = null; | ||
var x = function x(d) { | ||
return d.x; | ||
}; | ||
var y = function y(d) { | ||
return d.y; | ||
}; | ||
var horizontalAlign = 'center'; | ||
var verticalAlign = 'center'; | ||
var height = function height(d) { | ||
return d.height; | ||
}; | ||
var width = functor(3); | ||
// Renders a bar series as an SVG path based on the given array of datapoints. Each | ||
// bar has a fixed width, whilst the x, y and height are obtained from each data | ||
// point via the supplied accessor functions. | ||
var shapeBar = (function () { | ||
var bar = function bar(data, index) { | ||
var context = null; | ||
var x = function x(d) { | ||
return d.x; | ||
}; | ||
var y = function y(d) { | ||
return d.y; | ||
}; | ||
var horizontalAlign = 'center'; | ||
var verticalAlign = 'center'; | ||
var height = function height(d) { | ||
return d.height; | ||
}; | ||
var width = functor(3); | ||
var drawingContext = context || d3Path.path(); | ||
var bar = function bar(data, index) { | ||
data.forEach(function (d, i) { | ||
var xValue = x.call(this, d, index || i); | ||
var yValue = y.call(this, d, index || i); | ||
var barHeight = height.call(this, d, index || i); | ||
var barWidth = width.call(this, d, index || i); | ||
var drawingContext = context || d3Path.path(); | ||
var horizontalOffset = void 0; | ||
switch (horizontalAlign) { | ||
case 'left': | ||
horizontalOffset = barWidth; | ||
break; | ||
case 'right': | ||
horizontalOffset = 0; | ||
break; | ||
case 'center': | ||
horizontalOffset = barWidth / 2; | ||
break; | ||
default: | ||
throw new Error('Invalid horizontal alignment ' + horizontalAlign); | ||
} | ||
data.forEach(function (d, i) { | ||
var xValue = x.call(this, d, index || i); | ||
var yValue = y.call(this, d, index || i); | ||
var barHeight = height.call(this, d, index || i); | ||
var barWidth = width.call(this, d, index || i); | ||
var verticalOffset = void 0; | ||
switch (verticalAlign) { | ||
case 'bottom': | ||
verticalOffset = -barHeight; | ||
break; | ||
case 'top': | ||
verticalOffset = 0; | ||
break; | ||
case 'center': | ||
verticalOffset = barHeight / 2; | ||
break; | ||
default: | ||
throw new Error('Invalid vertical alignment ' + verticalAlign); | ||
} | ||
var horizontalOffset = void 0; | ||
switch (horizontalAlign) { | ||
case 'left': | ||
horizontalOffset = barWidth; | ||
break; | ||
case 'right': | ||
horizontalOffset = 0; | ||
break; | ||
case 'center': | ||
horizontalOffset = barWidth / 2; | ||
break; | ||
default: | ||
throw new Error('Invalid horizontal alignment ' + horizontalAlign); | ||
} | ||
drawingContext.rect(xValue - horizontalOffset, yValue - verticalOffset, barWidth, barHeight); | ||
}, this); | ||
var verticalOffset = void 0; | ||
switch (verticalAlign) { | ||
case 'bottom': | ||
verticalOffset = -barHeight; | ||
break; | ||
case 'top': | ||
verticalOffset = 0; | ||
break; | ||
case 'center': | ||
verticalOffset = barHeight / 2; | ||
break; | ||
default: | ||
throw new Error('Invalid vertical alignment ' + verticalAlign); | ||
return context ? null : drawingContext.toString(); | ||
}; | ||
bar.context = function () { | ||
if (!arguments.length) { | ||
return context; | ||
} | ||
context = arguments.length <= 0 ? undefined : arguments[0]; | ||
return bar; | ||
}; | ||
bar.x = function () { | ||
if (!arguments.length) { | ||
return x; | ||
} | ||
x = functor(arguments.length <= 0 ? undefined : arguments[0]); | ||
return bar; | ||
}; | ||
bar.y = function () { | ||
if (!arguments.length) { | ||
return y; | ||
} | ||
y = functor(arguments.length <= 0 ? undefined : arguments[0]); | ||
return bar; | ||
}; | ||
bar.width = function () { | ||
if (!arguments.length) { | ||
return width; | ||
} | ||
width = functor(arguments.length <= 0 ? undefined : arguments[0]); | ||
return bar; | ||
}; | ||
bar.horizontalAlign = function () { | ||
if (!arguments.length) { | ||
return horizontalAlign; | ||
} | ||
horizontalAlign = arguments.length <= 0 ? undefined : arguments[0]; | ||
return bar; | ||
}; | ||
bar.height = function () { | ||
if (!arguments.length) { | ||
return height; | ||
} | ||
height = functor(arguments.length <= 0 ? undefined : arguments[0]); | ||
return bar; | ||
}; | ||
bar.verticalAlign = function () { | ||
if (!arguments.length) { | ||
return verticalAlign; | ||
} | ||
verticalAlign = arguments.length <= 0 ? undefined : arguments[0]; | ||
return bar; | ||
}; | ||
drawingContext.rect(xValue - horizontalOffset, yValue - verticalOffset, barWidth, barHeight); | ||
}, this); | ||
return context ? null : drawingContext.toString(); | ||
}; | ||
bar.context = function () { | ||
if (!arguments.length) { | ||
return context; | ||
} | ||
context = arguments.length <= 0 ? undefined : arguments[0]; | ||
return bar; | ||
}; | ||
bar.x = function () { | ||
if (!arguments.length) { | ||
return x; | ||
} | ||
x = functor(arguments.length <= 0 ? undefined : arguments[0]); | ||
return bar; | ||
}; | ||
bar.y = function () { | ||
if (!arguments.length) { | ||
return y; | ||
} | ||
y = functor(arguments.length <= 0 ? undefined : arguments[0]); | ||
return bar; | ||
}; | ||
bar.width = function () { | ||
if (!arguments.length) { | ||
return width; | ||
} | ||
width = functor(arguments.length <= 0 ? undefined : arguments[0]); | ||
return bar; | ||
}; | ||
bar.horizontalAlign = function () { | ||
if (!arguments.length) { | ||
return horizontalAlign; | ||
} | ||
horizontalAlign = arguments.length <= 0 ? undefined : arguments[0]; | ||
return bar; | ||
}; | ||
bar.height = function () { | ||
if (!arguments.length) { | ||
return height; | ||
} | ||
height = functor(arguments.length <= 0 ? undefined : arguments[0]); | ||
return bar; | ||
}; | ||
bar.verticalAlign = function () { | ||
if (!arguments.length) { | ||
return verticalAlign; | ||
} | ||
verticalAlign = arguments.length <= 0 ? undefined : arguments[0]; | ||
return bar; | ||
}; | ||
}); | ||
return bar; | ||
}); | ||
var constant = (function (value) { | ||
return typeof value === 'function' ? value : function () { | ||
return value; | ||
}; | ||
}); | ||
// Renders a candlestick as an SVG path based on the given array of datapoints. Each | ||
// candlestick has a fixed width, whilst the x, open, high, low and close positions are | ||
// obtained from each point via the supplied accessor functions. | ||
var band = (function () { | ||
// Renders a box plot series as an SVG path based on the given array of datapoints. | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var orient = 'horizontal'; | ||
var fromValue = function fromValue(d) { | ||
return d.from; | ||
}; | ||
var toValue = function toValue(d) { | ||
return d.to; | ||
}; | ||
var decorate = function decorate() {}; | ||
// Renders an error bar series as an SVG path based on the given array of datapoints. | ||
var join = dataJoin('g', 'annotation-band'); | ||
var constant = (function (value) { | ||
return typeof value === 'function' ? value : function () { | ||
return value; | ||
}; | ||
}); | ||
var pathGenerator = shapeBar().horizontalAlign('center').verticalAlign('center').x(0).y(0); | ||
var band = (function () { | ||
var instance = function instance(selection) { | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var orient = 'horizontal'; | ||
var fromValue = function fromValue(d) { | ||
return d.from; | ||
}; | ||
var toValue = function toValue(d) { | ||
return d.to; | ||
}; | ||
var decorate = function decorate() {}; | ||
if (selection.selection) { | ||
join.transition(selection); | ||
} | ||
var join = dataJoin('g', 'annotation-band'); | ||
if (orient !== 'horizontal' && orient !== 'vertical') { | ||
throw new Error('Invalid orientation'); | ||
} | ||
var pathGenerator = shapeBar().horizontalAlign('center').verticalAlign('center').x(0).y(0); | ||
var horizontal = orient === 'horizontal'; | ||
var translation = horizontal ? function (a, b) { | ||
return 'translate(' + a + ', ' + b + ')'; | ||
} : function (a, b) { | ||
return 'translate(' + b + ', ' + a + ')'; | ||
}; | ||
// the value scale which the annotation 'value' relates to, the crossScale | ||
// is the other. Which is which depends on the orienation! | ||
var crossScale = horizontal ? xScale : yScale; | ||
var valueScale = horizontal ? yScale : xScale; | ||
var crossScaleRange = crossScale.range(); | ||
var crossScaleSize = crossScaleRange[1] - crossScaleRange[0]; | ||
var valueAxisDimension = horizontal ? 'height' : 'width'; | ||
var crossAxisDimension = horizontal ? 'width' : 'height'; | ||
var containerTransform = function containerTransform() { | ||
return translation((crossScaleRange[1] + crossScaleRange[0]) / 2, (valueScale(toValue.apply(undefined, arguments)) + valueScale(fromValue.apply(undefined, arguments))) / 2); | ||
}; | ||
var instance = function instance(selection$$1) { | ||
pathGenerator[crossAxisDimension](crossScaleSize); | ||
pathGenerator[valueAxisDimension](function () { | ||
return valueScale(toValue.apply(undefined, arguments)) - valueScale(fromValue.apply(undefined, arguments)); | ||
}); | ||
if (selection$$1.selection) { | ||
join.transition(selection$$1); | ||
} | ||
selection.each(function (data, index, nodes) { | ||
if (orient !== 'horizontal' && orient !== 'vertical') { | ||
throw new Error('Invalid orientation'); | ||
} | ||
var g = join(d3Selection.select(nodes[index]), data); | ||
var horizontal = orient === 'horizontal'; | ||
var translation = horizontal ? function (a, b) { | ||
return 'translate(' + a + ', ' + b + ')'; | ||
} : function (a, b) { | ||
return 'translate(' + b + ', ' + a + ')'; | ||
}; | ||
// the value scale which the annotation 'value' relates to, the crossScale | ||
// is the other. Which is which depends on the orienation! | ||
var crossScale = horizontal ? xScale : yScale; | ||
var valueScale = horizontal ? yScale : xScale; | ||
var crossScaleRange = crossScale.range(); | ||
var crossScaleSize = crossScaleRange[1] - crossScaleRange[0]; | ||
var valueAxisDimension = horizontal ? 'height' : 'width'; | ||
var crossAxisDimension = horizontal ? 'width' : 'height'; | ||
var containerTransform = function containerTransform() { | ||
return translation((crossScaleRange[1] + crossScaleRange[0]) / 2, (valueScale(toValue.apply(undefined, arguments)) + valueScale(fromValue.apply(undefined, arguments))) / 2); | ||
}; | ||
g.enter().attr('transform', containerTransform).append('path').classed('band', true); | ||
pathGenerator[crossAxisDimension](crossScaleSize); | ||
pathGenerator[valueAxisDimension](function () { | ||
return valueScale(toValue.apply(undefined, arguments)) - valueScale(fromValue.apply(undefined, arguments)); | ||
}); | ||
g.attr('class', 'annotation-band ' + orient).attr('transform', containerTransform).select('path') | ||
// the path generator is being used to render a single path, hence | ||
// an explicit index is provided | ||
.attr('d', function (d, i) { | ||
return pathGenerator([d], i); | ||
}); | ||
selection$$1.each(function (data, index, nodes) { | ||
var g = join(d3Selection.select(nodes[index]), data); | ||
g.enter().attr('transform', containerTransform).append('path').classed('band', true); | ||
g.attr('class', 'annotation-band ' + orient).attr('transform', containerTransform).select('path') | ||
// the path generator is being used to render a single path, hence | ||
// an explicit index is provided | ||
.attr('d', function (d, i) { | ||
return pathGenerator([d], i); | ||
decorate(g, data, index); | ||
}); | ||
}; | ||
decorate(g, data, index); | ||
}); | ||
}; | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.fromValue = function () { | ||
if (!arguments.length) { | ||
return fromValue; | ||
} | ||
fromValue = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.toValue = function () { | ||
if (!arguments.length) { | ||
return toValue; | ||
} | ||
toValue = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
}); | ||
var createReboundMethod = (function (target, source, name) { | ||
var method = source[name]; | ||
if (typeof method !== 'function') { | ||
throw new Error('Attempt to rebind ' + name + ' which isn\'t a function on the source object'); | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.fromValue = function () { | ||
if (!arguments.length) { | ||
return fromValue; | ||
} | ||
fromValue = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.toValue = function () { | ||
if (!arguments.length) { | ||
return toValue; | ||
} | ||
toValue = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return instance; | ||
}); | ||
var value = method.apply(source, args); | ||
return value === source ? target : value; | ||
}; | ||
}); | ||
var createReboundMethod = (function (target, source, name) { | ||
var method = source[name]; | ||
if (typeof method !== 'function') { | ||
throw new Error('Attempt to rebind ' + name + ' which isn\'t a function on the source object'); | ||
} | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
var rebind = (function (target, source) { | ||
for (var _len = arguments.length, names = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
names[_key - 2] = arguments[_key]; | ||
} | ||
var value = method.apply(source, args); | ||
return value === source ? target : value; | ||
}; | ||
}); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
var rebind = (function (target, source) { | ||
for (var _len = arguments.length, names = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
names[_key - 2] = arguments[_key]; | ||
} | ||
try { | ||
for (var _iterator = names[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var name = _step.value; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = names[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var name = _step.value; | ||
target[name] = createReboundMethod(target, source, name); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
target[name] = createReboundMethod(target, source, name); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
} | ||
return target; | ||
}); | ||
return target; | ||
}); | ||
var createTransform = function createTransform(transforms) { | ||
return function (name) { | ||
return transforms.reduce(function (name, fn) { | ||
return name && fn(name); | ||
}, name); | ||
var createTransform = function createTransform(transforms) { | ||
return function (name) { | ||
return transforms.reduce(function (name, fn) { | ||
return name && fn(name); | ||
}, name); | ||
}; | ||
}; | ||
}; | ||
var rebindAll = (function (target, source) { | ||
for (var _len = arguments.length, transforms = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
transforms[_key - 2] = arguments[_key]; | ||
} | ||
var rebindAll = (function (target, source) { | ||
for (var _len = arguments.length, transforms = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
transforms[_key - 2] = arguments[_key]; | ||
} | ||
var transform = createTransform(transforms); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
var transform = createTransform(transforms); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = Object.keys(source)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var name = _step.value; | ||
try { | ||
for (var _iterator = Object.keys(source)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var name = _step.value; | ||
var result = transform(name); | ||
if (result) { | ||
target[result] = createReboundMethod(target, source, name); | ||
var result = transform(name); | ||
if (result) { | ||
target[result] = createReboundMethod(target, source, name); | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
} | ||
return target; | ||
}); | ||
return target; | ||
}); | ||
var regexify = (function (strsOrRegexes) { | ||
return strsOrRegexes.map(function (strOrRegex) { | ||
return typeof strOrRegex === 'string' ? new RegExp('^' + strOrRegex + '$') : strOrRegex; | ||
var regexify = (function (strsOrRegexes) { | ||
return strsOrRegexes.map(function (strOrRegex) { | ||
return typeof strOrRegex === 'string' ? new RegExp('^' + strOrRegex + '$') : strOrRegex; | ||
}); | ||
}); | ||
}); | ||
var exclude = (function () { | ||
for (var _len = arguments.length, exclusions = Array(_len), _key = 0; _key < _len; _key++) { | ||
exclusions[_key] = arguments[_key]; | ||
} | ||
var exclude = (function () { | ||
for (var _len = arguments.length, exclusions = Array(_len), _key = 0; _key < _len; _key++) { | ||
exclusions[_key] = arguments[_key]; | ||
} | ||
exclusions = regexify(exclusions); | ||
return function (name) { | ||
return exclusions.every(function (exclusion) { | ||
return !exclusion.test(name); | ||
}) && name; | ||
}; | ||
}); | ||
exclusions = regexify(exclusions); | ||
return function (name) { | ||
return exclusions.every(function (exclusion) { | ||
return !exclusion.test(name); | ||
}) && name; | ||
}; | ||
}); | ||
var include = (function () { | ||
for (var _len = arguments.length, inclusions = Array(_len), _key = 0; _key < _len; _key++) { | ||
inclusions[_key] = arguments[_key]; | ||
} | ||
var include = (function () { | ||
for (var _len = arguments.length, inclusions = Array(_len), _key = 0; _key < _len; _key++) { | ||
inclusions[_key] = arguments[_key]; | ||
} | ||
inclusions = regexify(inclusions); | ||
return function (name) { | ||
return inclusions.some(function (inclusion) { | ||
return inclusion.test(name); | ||
}) && name; | ||
inclusions = regexify(inclusions); | ||
return function (name) { | ||
return inclusions.some(function (inclusion) { | ||
return inclusion.test(name); | ||
}) && name; | ||
}; | ||
}); | ||
var includeMap = (function (mappings) { | ||
return function (name) { | ||
return mappings[name]; | ||
}; | ||
}); | ||
var capitalizeFirstLetter = function capitalizeFirstLetter(str) { | ||
return str[0].toUpperCase() + str.slice(1); | ||
}; | ||
}); | ||
var includeMap = (function (mappings) { | ||
return function (name) { | ||
return mappings[name]; | ||
}; | ||
}); | ||
var prefix = (function (prefix) { | ||
return function (name) { | ||
return prefix + capitalizeFirstLetter(name); | ||
}; | ||
}); | ||
var capitalizeFirstLetter = function capitalizeFirstLetter(str) { | ||
return str[0].toUpperCase() + str.slice(1); | ||
}; | ||
var band$1 = (function () { | ||
var prefix = (function (prefix) { | ||
return function (name) { | ||
return prefix + capitalizeFirstLetter(name); | ||
}; | ||
}); | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var orient = 'horizontal'; | ||
var fromValue = function fromValue(d) { | ||
return d.from; | ||
}; | ||
var toValue = function toValue(d) { | ||
return d.to; | ||
}; | ||
var decorate = function decorate() {}; | ||
var band$1 = (function () { | ||
var pathGenerator = shapeBar().horizontalAlign('right').verticalAlign('top'); | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var orient = 'horizontal'; | ||
var fromValue = function fromValue(d) { | ||
return d.from; | ||
}; | ||
var toValue = function toValue(d) { | ||
return d.to; | ||
}; | ||
var decorate = function decorate() {}; | ||
var instance = function instance(data) { | ||
var pathGenerator = shapeBar().horizontalAlign('right').verticalAlign('top'); | ||
if (orient !== 'horizontal' && orient !== 'vertical') { | ||
throw new Error('Invalid orientation'); | ||
} | ||
var instance = function instance(data) { | ||
var context = pathGenerator.context(); | ||
var horizontal = orient === 'horizontal'; | ||
// the value scale which the annotation 'value' relates to, the crossScale | ||
// is the other. Which is which depends on the orienation! | ||
var crossScale = horizontal ? xScale : yScale; | ||
var valueScale = horizontal ? yScale : xScale; | ||
var crossScaleRange = crossScale.range(); | ||
var crossScaleSize = crossScaleRange[1] - crossScaleRange[0]; | ||
var valueAxisStart = horizontal ? 'x' : 'y'; | ||
var crossAxisStart = horizontal ? 'y' : 'x'; | ||
var valueAxisDimension = horizontal ? 'height' : 'width'; | ||
var crossAxisDimension = horizontal ? 'width' : 'height'; | ||
if (orient !== 'horizontal' && orient !== 'vertical') { | ||
throw new Error('Invalid orientation'); | ||
} | ||
data.forEach(function (d, i) { | ||
context.save(); | ||
context.beginPath(); | ||
context.strokeStyle = 'transparent'; | ||
var context = pathGenerator.context(); | ||
var horizontal = orient === 'horizontal'; | ||
// the value scale which the annotation 'value' relates to, the crossScale | ||
// is the other. Which is which depends on the orienation! | ||
var crossScale = horizontal ? xScale : yScale; | ||
var valueScale = horizontal ? yScale : xScale; | ||
var crossScaleRange = crossScale.range(); | ||
var crossScaleSize = crossScaleRange[1] - crossScaleRange[0]; | ||
var valueAxisStart = horizontal ? 'x' : 'y'; | ||
var crossAxisStart = horizontal ? 'y' : 'x'; | ||
var valueAxisDimension = horizontal ? 'height' : 'width'; | ||
var crossAxisDimension = horizontal ? 'width' : 'height'; | ||
pathGenerator[crossAxisStart](valueScale(fromValue(d))); | ||
pathGenerator[valueAxisStart](crossScaleRange[0]); | ||
pathGenerator[crossAxisDimension](crossScaleSize); | ||
pathGenerator[valueAxisDimension](valueScale(toValue(d)) - valueScale(fromValue(d))); | ||
data.forEach(function (d, i) { | ||
context.save(); | ||
context.beginPath(); | ||
context.strokeStyle = 'transparent'; | ||
decorate(context, d, i); | ||
pathGenerator.context(context)([d], i); | ||
pathGenerator[crossAxisStart](valueScale(fromValue(d))); | ||
pathGenerator[valueAxisStart](crossScaleRange[0]); | ||
pathGenerator[crossAxisDimension](crossScaleSize); | ||
pathGenerator[valueAxisDimension](valueScale(toValue(d)) - valueScale(fromValue(d))); | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.restore(); | ||
}); | ||
}; | ||
decorate(context, d, i); | ||
pathGenerator.context(context)([d], i); | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.fromValue = function () { | ||
if (!arguments.length) { | ||
return fromValue; | ||
} | ||
fromValue = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.toValue = function () { | ||
if (!arguments.length) { | ||
return toValue; | ||
} | ||
toValue = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.restore(); | ||
}); | ||
}; | ||
rebind(instance, pathGenerator, 'context'); | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.fromValue = function () { | ||
if (!arguments.length) { | ||
return fromValue; | ||
} | ||
fromValue = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.toValue = function () { | ||
if (!arguments.length) { | ||
return toValue; | ||
} | ||
toValue = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
}); | ||
rebind(instance, pathGenerator, 'context'); | ||
var annotationLine = (function () { | ||
return instance; | ||
}); | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var value = function value(d) { | ||
return d; | ||
}; | ||
var label = value; | ||
var decorate = function decorate() {}; | ||
var orient = 'horizontal'; | ||
var annotationLine = (function () { | ||
var join = dataJoin('g', 'annotation-line'); | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var value = function value(d) { | ||
return d; | ||
}; | ||
var label = value; | ||
var decorate = function decorate() {}; | ||
var orient = 'horizontal'; | ||
var instance = function instance(selection) { | ||
var join = dataJoin('g', 'annotation-line'); | ||
if (selection.selection) { | ||
join.transition(selection); | ||
} | ||
var instance = function instance(selection$$1) { | ||
if (orient !== 'horizontal' && orient !== 'vertical') { | ||
throw new Error('Invalid orientation'); | ||
} | ||
var horizontal = orient === 'horizontal'; | ||
var translation = horizontal ? function (a, b) { | ||
return 'translate(' + a + ', ' + b + ')'; | ||
} : function (a, b) { | ||
return 'translate(' + b + ', ' + a + ')'; | ||
}; | ||
var lineProperty = horizontal ? 'x2' : 'y2'; | ||
// the value scale which the annotation 'value' relates to, the crossScale | ||
// is the other. Which is which depends on the orienation! | ||
var crossScale = horizontal ? xScale : yScale; | ||
var valueScale = horizontal ? yScale : xScale; | ||
var handleOne = horizontal ? 'left-handle' : 'bottom-handle'; | ||
var handleTwo = horizontal ? 'right-handle' : 'top-handle'; | ||
var textOffsetX = horizontal ? '9' : '0'; | ||
var textOffsetY = horizontal ? '0' : '9'; | ||
var textOffsetDeltaY = horizontal ? '0.32em' : '0.71em'; | ||
var textAnchor = horizontal ? 'start' : 'middle'; | ||
if (selection$$1.selection) { | ||
join.transition(selection$$1); | ||
} | ||
var scaleRange = crossScale.range(); | ||
// the transform that sets the 'origin' of the annotation | ||
var containerTransform = function containerTransform() { | ||
return translation(scaleRange[0], valueScale(value.apply(undefined, arguments))); | ||
}; | ||
var scaleWidth = scaleRange[1] - scaleRange[0]; | ||
if (orient !== 'horizontal' && orient !== 'vertical') { | ||
throw new Error('Invalid orientation'); | ||
} | ||
var horizontal = orient === 'horizontal'; | ||
var translation = horizontal ? function (a, b) { | ||
return 'translate(' + a + ', ' + b + ')'; | ||
} : function (a, b) { | ||
return 'translate(' + b + ', ' + a + ')'; | ||
}; | ||
var lineProperty = horizontal ? 'x2' : 'y2'; | ||
// the value scale which the annotation 'value' relates to, the crossScale | ||
// is the other. Which is which depends on the orienation! | ||
var crossScale = horizontal ? xScale : yScale; | ||
var valueScale = horizontal ? yScale : xScale; | ||
var handleOne = horizontal ? 'left-handle' : 'bottom-handle'; | ||
var handleTwo = horizontal ? 'right-handle' : 'top-handle'; | ||
var textOffsetX = horizontal ? '9' : '0'; | ||
var textOffsetY = horizontal ? '0' : '9'; | ||
var textOffsetDeltaY = horizontal ? '0.32em' : '0.71em'; | ||
var textAnchor = horizontal ? 'start' : 'middle'; | ||
selection.each(function (data, selectionIndex, nodes) { | ||
var scaleRange = crossScale.range(); | ||
// the transform that sets the 'origin' of the annotation | ||
var containerTransform = function containerTransform() { | ||
return translation(scaleRange[0], valueScale(value.apply(undefined, arguments))); | ||
}; | ||
var scaleWidth = scaleRange[1] - scaleRange[0]; | ||
var g = join(d3Selection.select(nodes[selectionIndex]), data); | ||
selection$$1.each(function (data, selectionIndex, nodes) { | ||
// create the outer container and line | ||
var enter = g.enter().attr('transform', containerTransform).style('stroke', '#bbb'); | ||
enter.append('line').attr(lineProperty, scaleWidth); | ||
var g = join(d3Selection.select(nodes[selectionIndex]), data); | ||
// create containers at each end of the annotation | ||
enter.append('g').classed(handleOne, true).style('stroke', 'none'); | ||
// create the outer container and line | ||
var enter = g.enter().attr('transform', containerTransform).style('stroke', '#bbb'); | ||
enter.append('line').attr(lineProperty, scaleWidth); | ||
enter.append('g').classed(handleTwo, true).style('stroke', 'none').attr('transform', translation(scaleWidth, 0)).append('text').attr('text-anchor', textAnchor).attr('x', textOffsetX).attr('y', textOffsetY).attr('dy', textOffsetDeltaY); | ||
// create containers at each end of the annotation | ||
enter.append('g').classed(handleOne, true).style('stroke', 'none'); | ||
// Update | ||
g.attr('class', 'annotation-line ' + orient); | ||
enter.append('g').classed(handleTwo, true).style('stroke', 'none').attr('transform', translation(scaleWidth, 0)).append('text').attr('text-anchor', textAnchor).attr('x', textOffsetX).attr('y', textOffsetY).attr('dy', textOffsetDeltaY); | ||
// translate the parent container to the left hand edge of the annotation | ||
g.attr('transform', containerTransform); | ||
// Update | ||
g.attr('class', 'annotation-line ' + orient); | ||
// update the elements that depend on scale width | ||
g.select('line').attr(lineProperty, scaleWidth); | ||
g.select('g.' + handleTwo).attr('transform', translation(scaleWidth, 0)); | ||
// translate the parent container to the left hand edge of the annotation | ||
g.attr('transform', containerTransform); | ||
// Update the text label | ||
g.select('text').text(label); | ||
// update the elements that depend on scale width | ||
g.select('line').attr(lineProperty, scaleWidth); | ||
g.select('g.' + handleTwo).attr('transform', translation(scaleWidth, 0)); | ||
decorate(g, data, selectionIndex); | ||
}); | ||
}; | ||
// Update the text label | ||
g.select('text').text(label); | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.value = function () { | ||
if (!arguments.length) { | ||
return value; | ||
} | ||
value = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.label = function () { | ||
if (!arguments.length) { | ||
return label; | ||
} | ||
label = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
decorate(g, data, selectionIndex); | ||
}); | ||
}; | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.value = function () { | ||
if (!arguments.length) { | ||
return value; | ||
} | ||
value = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.label = function () { | ||
if (!arguments.length) { | ||
return label; | ||
} | ||
label = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
}); | ||
return instance; | ||
}); | ||
var functor$1 = (function (d) { | ||
return typeof d === 'function' ? d : function () { | ||
return d; | ||
}; | ||
}); | ||
var functor$1 = (function (d) { | ||
return typeof d === 'function' ? d : function () { | ||
return d; | ||
}; | ||
}); | ||
// Checks that passes properties are 'defined', meaning that calling them with (d, i) returns non null values | ||
function defined() { | ||
var outerArguments = arguments; | ||
return function (d, i) { | ||
for (var c = 0, j = outerArguments.length; c < j; c++) { | ||
if (outerArguments[c](d, i) == null) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
} | ||
// Checks that passes properties are 'defined', meaning that calling them with (d, i) returns non null values | ||
function defined$1() { | ||
var outerArguments = arguments; | ||
return function (d, i) { | ||
for (var c = 0, j = outerArguments.length; c < j; c++) { | ||
if (outerArguments[c](d, i) == null) { | ||
return false; | ||
} | ||
// determines the offset required along the cross scale based | ||
// on the series alignment | ||
var alignOffset = (function (align, width) { | ||
switch (align) { | ||
case 'left': | ||
return width / 2; | ||
case 'right': | ||
return -width / 2; | ||
default: | ||
return 0; | ||
} | ||
return true; | ||
}; | ||
} | ||
}); | ||
// determines the offset required along the cross scale based | ||
// on the series alignment | ||
var alignOffset = (function (align, width) { | ||
switch (align) { | ||
case 'left': | ||
return width / 2; | ||
case 'right': | ||
return -width / 2; | ||
default: | ||
return 0; | ||
} | ||
}); | ||
var createBase = (function (initialValues) { | ||
var createBase = (function (initialValues) { | ||
var env = Object.assign({}, initialValues); | ||
var base = function base() {}; | ||
var env = Object.assign({}, initialValues); | ||
var base = function base() {}; | ||
Object.keys(env).forEach(function (key) { | ||
base[key] = function () { | ||
if (!arguments.length) { | ||
return env[key]; | ||
} | ||
env[key] = arguments.length <= 0 ? undefined : arguments[0]; | ||
return base; | ||
}; | ||
}); | ||
Object.keys(env).forEach(function (key) { | ||
base[key] = function () { | ||
if (!arguments.length) { | ||
return env[key]; | ||
} | ||
env[key] = arguments.length <= 0 ? undefined : arguments[0]; | ||
return base; | ||
}; | ||
return base; | ||
}); | ||
return base; | ||
}); | ||
var xyBase = (function () { | ||
var xyBase = (function () { | ||
var baseValue = function baseValue() { | ||
return 0; | ||
}; | ||
var crossValue = function crossValue(d) { | ||
return d.x; | ||
}; | ||
var mainValue = function mainValue(d) { | ||
return d.y; | ||
}; | ||
var align = 'center'; | ||
var bandwidth = function bandwidth() { | ||
return 5; | ||
}; | ||
var orient = 'vertical'; | ||
var baseValue = function baseValue() { | ||
return 0; | ||
}; | ||
var crossValue = function crossValue(d) { | ||
return d.x; | ||
}; | ||
var mainValue = function mainValue(d) { | ||
return d.y; | ||
}; | ||
var align = 'center'; | ||
var bandwidth = function bandwidth() { | ||
return 5; | ||
}; | ||
var orient = 'vertical'; | ||
var base = createBase({ | ||
decorate: function decorate() {}, | ||
defined: function defined$1(d, i) { | ||
return defined(baseValue, crossValue, mainValue)(d, i); | ||
}, | ||
xScale: d3Scale.scaleIdentity(), | ||
yScale: d3Scale.scaleIdentity() | ||
}); | ||
var base = createBase({ | ||
decorate: function decorate() {}, | ||
defined: function defined(d, i) { | ||
return defined$1(baseValue, crossValue, mainValue)(d, i); | ||
}, | ||
xScale: d3Scale.scaleIdentity(), | ||
yScale: d3Scale.scaleIdentity() | ||
}); | ||
base.values = function (d, i) { | ||
var width = bandwidth(d, i); | ||
var offset = alignOffset(align, width); | ||
var xScale = base.xScale(); | ||
var yScale = base.yScale(); | ||
base.values = function (d, i) { | ||
var width = bandwidth(d, i); | ||
var offset = alignOffset(align, width); | ||
var xScale = base.xScale(); | ||
var yScale = base.yScale(); | ||
if (orient === 'vertical') { | ||
var y = yScale(mainValue(d, i), i); | ||
var y0 = yScale(baseValue(d, i), i); | ||
var x = xScale(crossValue(d, i), i) + offset; | ||
return { | ||
d: d, | ||
x: x, | ||
y: y, | ||
y0: y0, | ||
width: width, | ||
height: y - y0, | ||
origin: [x, y], | ||
baseOrigin: [x, y0], | ||
transposedX: x, | ||
transposedY: y | ||
}; | ||
} else { | ||
var _y = xScale(mainValue(d, i), i); | ||
var _y2 = xScale(baseValue(d, i), i); | ||
var _x = yScale(crossValue(d, i), i) + offset; | ||
return { | ||
d: d, | ||
x: _x, | ||
y: _y, | ||
y0: _y2, | ||
width: width, | ||
height: _y - _y2, | ||
origin: [_y, _x], | ||
baseOrigin: [_y2, _x], | ||
transposedX: _y, | ||
transposedY: _x | ||
}; | ||
} | ||
}; | ||
if (orient === 'vertical') { | ||
var y = yScale(mainValue(d, i), i); | ||
var y0 = yScale(baseValue(d, i), i); | ||
var x = xScale(crossValue(d, i), i) + offset; | ||
return { | ||
d: d, | ||
x: x, | ||
y: y, | ||
y0: y0, | ||
width: width, | ||
height: y - y0, | ||
origin: [x, y], | ||
baseOrigin: [x, y0], | ||
transposedX: x, | ||
transposedY: y | ||
}; | ||
} else { | ||
var _y = xScale(mainValue(d, i), i); | ||
var _y2 = xScale(baseValue(d, i), i); | ||
var _x = yScale(crossValue(d, i), i) + offset; | ||
return { | ||
d: d, | ||
x: _x, | ||
y: _y, | ||
y0: _y2, | ||
width: width, | ||
height: _y - _y2, | ||
origin: [_y, _x], | ||
baseOrigin: [_y2, _x], | ||
transposedX: _y, | ||
transposedY: _x | ||
}; | ||
} | ||
}; | ||
base.baseValue = function () { | ||
if (!arguments.length) { | ||
return baseValue; | ||
} | ||
baseValue = functor$1(arguments.length <= 0 ? undefined : arguments[0]); | ||
return base; | ||
}; | ||
base.crossValue = function () { | ||
if (!arguments.length) { | ||
return crossValue; | ||
} | ||
crossValue = functor$1(arguments.length <= 0 ? undefined : arguments[0]); | ||
return base; | ||
}; | ||
base.mainValue = function () { | ||
if (!arguments.length) { | ||
return mainValue; | ||
} | ||
mainValue = functor$1(arguments.length <= 0 ? undefined : arguments[0]); | ||
return base; | ||
}; | ||
base.bandwidth = function () { | ||
if (!arguments.length) { | ||
return bandwidth; | ||
} | ||
bandwidth = functor$1(arguments.length <= 0 ? undefined : arguments[0]); | ||
return base; | ||
}; | ||
base.align = function () { | ||
if (!arguments.length) { | ||
return align; | ||
} | ||
align = arguments.length <= 0 ? undefined : arguments[0]; | ||
return base; | ||
}; | ||
base.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return base; | ||
}; | ||
base.baseValue = function () { | ||
if (!arguments.length) { | ||
return baseValue; | ||
} | ||
baseValue = functor$1(arguments.length <= 0 ? undefined : arguments[0]); | ||
return base; | ||
}; | ||
base.crossValue = function () { | ||
if (!arguments.length) { | ||
return crossValue; | ||
} | ||
crossValue = functor$1(arguments.length <= 0 ? undefined : arguments[0]); | ||
return base; | ||
}; | ||
base.mainValue = function () { | ||
if (!arguments.length) { | ||
return mainValue; | ||
} | ||
mainValue = functor$1(arguments.length <= 0 ? undefined : arguments[0]); | ||
return base; | ||
}; | ||
base.bandwidth = function () { | ||
if (!arguments.length) { | ||
return bandwidth; | ||
} | ||
bandwidth = functor$1(arguments.length <= 0 ? undefined : arguments[0]); | ||
return base; | ||
}; | ||
base.align = function () { | ||
if (!arguments.length) { | ||
return align; | ||
} | ||
align = arguments.length <= 0 ? undefined : arguments[0]; | ||
return base; | ||
}; | ||
base.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return base; | ||
}; | ||
}); | ||
return base; | ||
}); | ||
var red = '#c60'; | ||
var green = '#6c0'; | ||
var black = '#000'; | ||
var gray = '#ddd'; | ||
var darkGray = '#999'; | ||
var red = '#c60'; | ||
var green = '#6c0'; | ||
var black = '#000'; | ||
var gray = '#ddd'; | ||
var darkGray = '#999'; | ||
var colors = { | ||
red: red, | ||
green: green, | ||
black: black, | ||
gray: gray, | ||
darkGray: darkGray | ||
}; | ||
var colors = { | ||
red: red, | ||
green: green, | ||
black: black, | ||
gray: gray, | ||
darkGray: darkGray | ||
}; | ||
var seriesSvgPoint = (function () { | ||
var symbol = d3Shape.symbol(); | ||
var seriesSvgPoint = (function () { | ||
var symbol$$1 = d3Shape.symbol(); | ||
var base = xyBase(); | ||
var base = xyBase(); | ||
var join = dataJoin('g', 'point'); | ||
var join = dataJoin('g', 'point'); | ||
var containerTransform = function containerTransform(origin) { | ||
return 'translate(' + origin[0] + ', ' + origin[1] + ')'; | ||
}; | ||
var containerTransform = function containerTransform(origin) { | ||
return 'translate(' + origin[0] + ', ' + origin[1] + ')'; | ||
}; | ||
var point = function point(selection) { | ||
var point = function point(selection$$1) { | ||
if (selection.selection) { | ||
join.transition(selection); | ||
} | ||
if (selection$$1.selection) { | ||
join.transition(selection$$1); | ||
} | ||
selection.each(function (data, index, group) { | ||
selection$$1.each(function (data, index, group) { | ||
var filteredData = data.filter(base.defined()); | ||
var filteredData = data.filter(base.defined()); | ||
var g = join(d3Selection.select(group[index]), filteredData); | ||
g.enter().attr('transform', function (d, i) { | ||
return containerTransform(base.values(d, i).origin); | ||
}).attr('fill', colors.gray).attr('stroke', colors.black).append('path'); | ||
var g = join(d3Selection.select(group[index]), filteredData); | ||
g.enter().attr('transform', function (d, i) { | ||
return containerTransform(base.values(d, i).origin); | ||
}).attr('fill', colors.gray).attr('stroke', colors.black).append('path'); | ||
g.attr('transform', function (d, i) { | ||
return containerTransform(base.values(d, i).origin); | ||
}).select('path').attr('d', symbol); | ||
g.attr('transform', function (d, i) { | ||
return containerTransform(base.values(d, i).origin); | ||
}).select('path').attr('d', symbol$$1); | ||
base.decorate()(g, data, index); | ||
}); | ||
}; | ||
base.decorate()(g, data, index); | ||
}); | ||
}; | ||
rebindAll(point, base, exclude('baseValue', 'bandwidth', 'align')); | ||
rebind(point, join, 'key'); | ||
rebind(point, symbol, 'type', 'size'); | ||
rebindAll(point, base, exclude('baseValue', 'bandwidth', 'align')); | ||
rebind(point, join, 'key'); | ||
rebind(point, symbol$$1, 'type', 'size'); | ||
return point; | ||
}); | ||
return point; | ||
}); | ||
var seriesCanvasPoint = (function () { | ||
var seriesCanvasPoint = (function () { | ||
var symbol = d3Shape.symbol(); | ||
var symbol$$1 = d3Shape.symbol(); | ||
var base = xyBase(); | ||
var base = xyBase(); | ||
var point = function point(data) { | ||
var filteredData = data.filter(base.defined()); | ||
var context = symbol.context(); | ||
var point = function point(data) { | ||
var filteredData = data.filter(base.defined()); | ||
var context = symbol$$1.context(); | ||
filteredData.forEach(function (d, i) { | ||
context.save(); | ||
filteredData.forEach(function (d, i) { | ||
context.save(); | ||
var values = base.values(d, i); | ||
context.translate(values.origin[0], values.origin[1]); | ||
context.beginPath(); | ||
var values = base.values(d, i); | ||
context.translate(values.origin[0], values.origin[1]); | ||
context.beginPath(); | ||
symbol(d, i); | ||
symbol$$1(d, i); | ||
context.strokeStyle = colors.black; | ||
context.fillStyle = colors.gray; | ||
context.strokeStyle = colors.black; | ||
context.fillStyle = colors.gray; | ||
base.decorate()(context, d, i); | ||
base.decorate()(context, d, i); | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.restore(); | ||
}); | ||
}; | ||
context.restore(); | ||
}); | ||
}; | ||
rebindAll(point, base, exclude('baseValue', 'bandwidth', 'align')); | ||
rebind(point, symbol, 'size', 'type', 'context'); | ||
rebindAll(point, base, exclude('baseValue', 'bandwidth', 'align')); | ||
rebind(point, symbol$$1, 'size', 'type', 'context'); | ||
return point; | ||
}); | ||
return point; | ||
}); | ||
var multiBase = (function () { | ||
var multiBase = (function () { | ||
var series = []; | ||
var mapping = function mapping(d) { | ||
return d; | ||
}; | ||
var key = function key(_, i) { | ||
return i; | ||
}; | ||
var series = []; | ||
var mapping = function mapping(d) { | ||
return d; | ||
}; | ||
var key = function key(_, i) { | ||
return i; | ||
}; | ||
var multi = createBase({ | ||
decorate: function decorate() {}, | ||
xScale: d3Scale.scaleIdentity(), | ||
yScale: d3Scale.scaleIdentity() | ||
}); | ||
var multi = createBase({ | ||
decorate: function decorate() {}, | ||
xScale: d3Scale.scaleIdentity(), | ||
yScale: d3Scale.scaleIdentity() | ||
}); | ||
multi.mapping = function () { | ||
if (!arguments.length) { | ||
return mapping; | ||
} | ||
mapping = arguments.length <= 0 ? undefined : arguments[0]; | ||
return multi; | ||
}; | ||
multi.key = function () { | ||
if (!arguments.length) { | ||
return key; | ||
} | ||
key = arguments.length <= 0 ? undefined : arguments[0]; | ||
return multi; | ||
}; | ||
multi.series = function () { | ||
if (!arguments.length) { | ||
return series; | ||
} | ||
series = arguments.length <= 0 ? undefined : arguments[0]; | ||
return multi; | ||
}; | ||
multi.mapping = function () { | ||
if (!arguments.length) { | ||
return mapping; | ||
} | ||
mapping = arguments.length <= 0 ? undefined : arguments[0]; | ||
return multi; | ||
}; | ||
multi.key = function () { | ||
if (!arguments.length) { | ||
return key; | ||
} | ||
key = arguments.length <= 0 ? undefined : arguments[0]; | ||
return multi; | ||
}; | ||
multi.series = function () { | ||
if (!arguments.length) { | ||
return series; | ||
} | ||
series = arguments.length <= 0 ? undefined : arguments[0]; | ||
return multi; | ||
}; | ||
}); | ||
return multi; | ||
}); | ||
var seriesSvgMulti = (function () { | ||
var multiSeries = (function () { | ||
var base = multiBase(); | ||
var base = multiBase(); | ||
var innerJoin = dataJoin('g'); | ||
var innerJoin = dataJoin('g'); | ||
var join = dataJoin('g', 'multi'); | ||
var join = dataJoin('g', 'multi'); | ||
var multi = function multi(selection) { | ||
var multi = function multi(selection$$1) { | ||
if (selection.selection) { | ||
join.transition(selection); | ||
innerJoin.transition(selection); | ||
} | ||
if (selection$$1.selection) { | ||
join.transition(selection$$1); | ||
innerJoin.transition(selection$$1); | ||
} | ||
var mapping = base.mapping(); | ||
var series = base.series(); | ||
var xScale = base.xScale(); | ||
var yScale = base.yScale(); | ||
var mapping = base.mapping(); | ||
var series = base.series(); | ||
var xScale = base.xScale(); | ||
var yScale = base.yScale(); | ||
selection.each(function (data, index, group) { | ||
selection$$1.each(function (data, index, group) { | ||
var container = join(d3Selection.select(group[index]), series); | ||
var container = join(d3Selection.select(group[index]), series); | ||
// iterate over the containers, 'call'-ing the series for each | ||
container.each(function (dataSeries, seriesIndex, seriesGroup) { | ||
dataSeries.xScale(xScale).yScale(yScale); | ||
// iterate over the containers, 'call'-ing the series for each | ||
container.each(function (dataSeries, seriesIndex, seriesGroup) { | ||
dataSeries.xScale(xScale).yScale(yScale); | ||
var seriesData = mapping(data, seriesIndex, series); | ||
var innerContainer = innerJoin(d3Selection.select(seriesGroup[seriesIndex]), [seriesData]); | ||
var seriesData = mapping(data, seriesIndex, series); | ||
var innerContainer = innerJoin(d3Selection.select(seriesGroup[seriesIndex]), [seriesData]); | ||
innerContainer.call(dataSeries); | ||
}); | ||
innerContainer.call(dataSeries); | ||
var unwrappedSelection = container.selection ? container.selection() : container; | ||
unwrappedSelection.order(); | ||
base.decorate()(container, data, index); | ||
}); | ||
}; | ||
var unwrappedSelection = container.selection ? container.selection() : container; | ||
unwrappedSelection.order(); | ||
rebindAll(multi, base); | ||
rebind(multi, join, 'key'); | ||
base.decorate()(container, data, index); | ||
}); | ||
}; | ||
return multi; | ||
}); | ||
rebindAll(multi, base); | ||
rebind(multi, join, 'key'); | ||
var seriesCanvasMulti = (function () { | ||
return multi; | ||
}); | ||
var context = null; | ||
var base = multiBase(); | ||
var seriesCanvasMulti = (function () { | ||
var multi = function multi(data) { | ||
var mapping = base.mapping(); | ||
var series = base.series(); | ||
var xScale = base.xScale(); | ||
var yScale = base.yScale(); | ||
var context = null; | ||
var base = multiBase(); | ||
series.forEach(function (dataSeries, index) { | ||
var seriesData = mapping(data, index, series); | ||
dataSeries.context(context).xScale(xScale).yScale(yScale); | ||
var multi = function multi(data) { | ||
var mapping = base.mapping(); | ||
var series = base.series(); | ||
var xScale = base.xScale(); | ||
var yScale = base.yScale(); | ||
var adaptedDecorate = void 0; | ||
if (dataSeries.decorate) { | ||
adaptedDecorate = dataSeries.decorate(); | ||
dataSeries.decorate(function (c, d, i) { | ||
base.decorate()(c, data, index); | ||
adaptedDecorate(c, d, i); | ||
}); | ||
} else { | ||
base.decorate()(context, data, index); | ||
} | ||
series.forEach(function (dataSeries, index) { | ||
var seriesData = mapping(data, index, series); | ||
dataSeries.context(context).xScale(xScale).yScale(yScale); | ||
dataSeries(seriesData); | ||
var adaptedDecorate = void 0; | ||
if (dataSeries.decorate) { | ||
adaptedDecorate = dataSeries.decorate(); | ||
dataSeries.decorate(function (c, d, i) { | ||
base.decorate()(c, data, index); | ||
adaptedDecorate(c, d, i); | ||
}); | ||
} else { | ||
base.decorate()(context, data, index); | ||
if (adaptedDecorate) { | ||
dataSeries.decorate(adaptedDecorate); | ||
} | ||
}); | ||
}; | ||
multi.context = function () { | ||
if (!arguments.length) { | ||
return context; | ||
} | ||
context = arguments.length <= 0 ? undefined : arguments[0]; | ||
return multi; | ||
}; | ||
dataSeries(seriesData); | ||
rebindAll(multi, base); | ||
if (adaptedDecorate) { | ||
dataSeries.decorate(adaptedDecorate); | ||
} | ||
}); | ||
}; | ||
multi.context = function () { | ||
if (!arguments.length) { | ||
return context; | ||
} | ||
context = arguments.length <= 0 ? undefined : arguments[0]; | ||
return multi; | ||
}; | ||
}); | ||
rebindAll(multi, base); | ||
var toConsumableArray = function (arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return multi; | ||
}); | ||
return arr2; | ||
} else { | ||
return Array.from(arr); | ||
} | ||
}; | ||
var toConsumableArray = function (arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
function crosshair () { | ||
return arr2; | ||
} else { | ||
return Array.from(arr); | ||
} | ||
}; | ||
var x = function x(d) { | ||
return d.x; | ||
}; | ||
var y = function y(d) { | ||
return d.y; | ||
}; | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var decorate = function decorate() {}; | ||
var crosshair = function () { | ||
var join = dataJoin('g', 'annotation-crosshair'); | ||
var x = function x(d) { | ||
return d.x; | ||
}; | ||
var y = function y(d) { | ||
return d.y; | ||
}; | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var decorate = function decorate() {}; | ||
var point = seriesSvgPoint(); | ||
var join = dataJoin('g', 'annotation-crosshair'); | ||
var horizontalLine = annotationLine(); | ||
var point = seriesSvgPoint(); | ||
var verticalLine = annotationLine().orient('vertical'); | ||
var horizontalLine = annotationLine(); | ||
// The line annotations and point series used to render the crosshair are positioned using | ||
// screen coordinates. This function constructs an identity scale for these components. | ||
var xIdentity = d3Scale.scaleIdentity(); | ||
var yIdentity = d3Scale.scaleIdentity(); | ||
var verticalLine = annotationLine().orient('vertical'); | ||
var multi = seriesSvgMulti().series([horizontalLine, verticalLine, point]).xScale(xIdentity).yScale(yIdentity).mapping(function (data) { | ||
return [data]; | ||
}); | ||
// The line annotations and point series used to render the crosshair are positioned using | ||
// screen coordinates. This function constructs an identity scale for these components. | ||
var xIdentity = d3Scale.scaleIdentity(); | ||
var yIdentity = d3Scale.scaleIdentity(); | ||
var instance = function instance(selection) { | ||
var multi = multiSeries().series([horizontalLine, verticalLine, point]).xScale(xIdentity).yScale(yIdentity).mapping(function (data) { | ||
return [data]; | ||
}); | ||
if (selection.selection) { | ||
join.transition(selection); | ||
} | ||
var instance = function instance(selection$$1) { | ||
selection.each(function (data, index, nodes) { | ||
if (selection$$1.selection) { | ||
join.transition(selection$$1); | ||
} | ||
var g = join(d3Selection.select(nodes[index]), data); | ||
selection$$1.each(function (data, index, nodes) { | ||
// Prevent the crosshair triggering pointer events on itself | ||
g.enter().style('pointer-events', 'none'); | ||
var g = join(d3Selection.select(nodes[index]), data); | ||
// Assign the identity scales an accurate range to allow the line annotations to cover | ||
// the full width/height of the chart. | ||
xIdentity.range(xScale.range()); | ||
yIdentity.range(yScale.range()); | ||
// Prevent the crosshair triggering pointer events on itself | ||
g.enter().style('pointer-events', 'none'); | ||
point.crossValue(x).mainValue(y); | ||
// Assign the identity scales an accurate range to allow the line annotations to cover | ||
// the full width/height of the chart. | ||
xIdentity.range(xScale.range()); | ||
yIdentity.range(yScale.range()); | ||
horizontalLine.value(y); | ||
point.crossValue(x).mainValue(y); | ||
verticalLine.value(x); | ||
horizontalLine.value(y); | ||
g.call(multi); | ||
verticalLine.value(x); | ||
decorate(g, data, index); | ||
}); | ||
}; | ||
g.call(multi); | ||
// Don't use the xValue/yValue convention to indicate that these values are in screen | ||
// not domain co-ordinates and are therefore not scaled. | ||
instance.x = function () { | ||
if (!arguments.length) { | ||
return x; | ||
} | ||
x = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.y = function () { | ||
if (!arguments.length) { | ||
return y; | ||
} | ||
y = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
decorate(g, data, index); | ||
}); | ||
}; | ||
var lineIncludes = include('label'); | ||
rebindAll(instance, horizontalLine, lineIncludes, prefix('y')); | ||
rebindAll(instance, verticalLine, lineIncludes, prefix('x')); | ||
// Don't use the xValue/yValue convention to indicate that these values are in screen | ||
// not domain co-ordinates and are therefore not scaled. | ||
instance.x = function () { | ||
if (!arguments.length) { | ||
return x; | ||
} | ||
x = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.y = function () { | ||
if (!arguments.length) { | ||
return y; | ||
} | ||
y = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
} | ||
var lineIncludes = include('label'); | ||
rebindAll(instance, horizontalLine, lineIncludes, prefix('y')); | ||
rebindAll(instance, verticalLine, lineIncludes, prefix('x')); | ||
var annotationLine$1 = (function () { | ||
return instance; | ||
}; | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var value = function value(d) { | ||
return d; | ||
}; | ||
var label = value; | ||
var decorate = function decorate() {}; | ||
var orient = 'horizontal'; | ||
var annotationLine$1 = (function () { | ||
var lineData = d3Shape.line(); | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var value = function value(d) { | ||
return d; | ||
}; | ||
var label = value; | ||
var decorate = function decorate() {}; | ||
var orient = 'horizontal'; | ||
var instance = function instance(data) { | ||
if (orient !== 'horizontal' && orient !== 'vertical') { | ||
throw new Error('Invalid orientation'); | ||
} | ||
var horizontal = orient === 'horizontal'; | ||
var context = lineData.context(); | ||
// the value scale which the annotation 'value' relates to, the crossScale | ||
// is the other. Which is which depends on the orienation! | ||
var crossScale = horizontal ? xScale : yScale; | ||
var valueScale = horizontal ? yScale : xScale; | ||
var crossDomain = crossScale.domain(); | ||
var textOffsetX = horizontal ? 9 : 0; | ||
var textOffsetY = horizontal ? 0 : 9; | ||
var textAlign = horizontal ? 'left' : 'center'; | ||
var textBaseline = horizontal ? 'middle' : 'hanging'; | ||
var lineData = d3Shape.line(); | ||
data.forEach(function (d, i) { | ||
context.save(); | ||
context.beginPath(); | ||
context.strokeStyle = '#bbb'; | ||
context.fillStyle = '#000'; | ||
context.textAlign = textAlign; | ||
context.textBaseline = textBaseline; | ||
var instance = function instance(data) { | ||
if (orient !== 'horizontal' && orient !== 'vertical') { | ||
throw new Error('Invalid orientation'); | ||
} | ||
var horizontal = orient === 'horizontal'; | ||
var context = lineData.context(); | ||
// the value scale which the annotation 'value' relates to, the crossScale | ||
// is the other. Which is which depends on the orienation! | ||
var crossScale = horizontal ? xScale : yScale; | ||
var valueScale = horizontal ? yScale : xScale; | ||
var crossDomain = crossScale.domain(); | ||
var textOffsetX = horizontal ? 9 : 0; | ||
var textOffsetY = horizontal ? 0 : 9; | ||
var textAlign = horizontal ? 'left' : 'center'; | ||
var textBaseline = horizontal ? 'middle' : 'hanging'; | ||
decorate(context, d, i); | ||
data.forEach(function (d, i) { | ||
context.save(); | ||
context.beginPath(); | ||
context.strokeStyle = '#bbb'; | ||
context.fillStyle = '#000'; | ||
context.textAlign = textAlign; | ||
context.textBaseline = textBaseline; | ||
// Draw line | ||
lineData.context(context)(crossDomain.map(function (extent) { | ||
var point = [crossScale(extent), valueScale(value(d))]; | ||
return horizontal ? point : point.reverse(); | ||
})); | ||
decorate(context, d, i); | ||
// Draw label | ||
var x = horizontal ? crossScale(crossDomain[1]) : valueScale(value(d)); | ||
var y = horizontal ? valueScale(value(d)) : crossScale(crossDomain[1]); | ||
context.fillText(label(d), x + textOffsetX, y + textOffsetY); | ||
// Draw line | ||
lineData.context(context)(crossDomain.map(function (extent) { | ||
var point = [crossScale(extent), valueScale(value(d))]; | ||
return horizontal ? point : point.reverse(); | ||
})); | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.restore(); | ||
}); | ||
}; | ||
// Draw label | ||
var x = horizontal ? crossScale(crossDomain[1]) : valueScale(value(d)); | ||
var y = horizontal ? valueScale(value(d)) : crossScale(crossDomain[1]); | ||
context.fillText(label(d), x + textOffsetX, y + textOffsetY); | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.value = function () { | ||
if (!arguments.length) { | ||
return value; | ||
} | ||
value = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.label = function () { | ||
if (!arguments.length) { | ||
return label; | ||
} | ||
label = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.restore(); | ||
}); | ||
}; | ||
rebind(instance, lineData, 'context'); | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.value = function () { | ||
if (!arguments.length) { | ||
return value; | ||
} | ||
value = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.label = function () { | ||
if (!arguments.length) { | ||
return label; | ||
} | ||
label = constant(arguments.length <= 0 ? undefined : arguments[0]); | ||
return instance; | ||
}; | ||
instance.decorate = function () { | ||
if (!arguments.length) { | ||
return decorate; | ||
} | ||
decorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.orient = function () { | ||
if (!arguments.length) { | ||
return orient; | ||
} | ||
orient = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
}); | ||
rebind(instance, lineData, 'context'); | ||
var crosshair$1 = (function () { | ||
return instance; | ||
}); | ||
var x = function x(d) { | ||
return d.x; | ||
}; | ||
var y = function y(d) { | ||
return d.y; | ||
}; | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var crosshair$1 = (function () { | ||
var point = seriesCanvasPoint(); | ||
var x = function x(d) { | ||
return d.x; | ||
}; | ||
var y = function y(d) { | ||
return d.y; | ||
}; | ||
var xScale = d3Scale.scaleIdentity(); | ||
var yScale = d3Scale.scaleIdentity(); | ||
var horizontalLine = annotationLine$1(); | ||
var point = seriesCanvasPoint(); | ||
var verticalLine = annotationLine$1().orient('vertical'); | ||
var horizontalLine = annotationLine$1(); | ||
// The line annotations and point series used to render the crosshair are positioned using | ||
// screen coordinates. This function constructs an identity scale for these components. | ||
var xIdentity = d3Scale.scaleIdentity(); | ||
var yIdentity = d3Scale.scaleIdentity(); | ||
var verticalLine = annotationLine$1().orient('vertical'); | ||
var multi = seriesCanvasMulti().series([horizontalLine, verticalLine, point]).xScale(xIdentity).yScale(yIdentity).mapping(function (data) { | ||
return [data]; | ||
}); | ||
// The line annotations and point series used to render the crosshair are positioned using | ||
// screen coordinates. This function constructs an identity scale for these components. | ||
var xIdentity = d3Scale.scaleIdentity(); | ||
var yIdentity = d3Scale.scaleIdentity(); | ||
var instance = function instance(data) { | ||
var multi = seriesCanvasMulti().series([horizontalLine, verticalLine, point]).xScale(xIdentity).yScale(yIdentity).mapping(function (data) { | ||
return [data]; | ||
}); | ||
data.forEach(function (d) { | ||
// Assign the identity scales an accurate range to allow the line annotations to cover | ||
// the full width/height of the chart. | ||
xIdentity.range(xScale.range()); | ||
yIdentity.range(yScale.range()); | ||
var instance = function instance(data) { | ||
point.crossValue(x).mainValue(y); | ||
data.forEach(function (d) { | ||
// Assign the identity scales an accurate range to allow the line annotations to cover | ||
// the full width/height of the chart. | ||
xIdentity.range(xScale.range()); | ||
yIdentity.range(yScale.range()); | ||
horizontalLine.value(y); | ||
point.crossValue(x).mainValue(y); | ||
verticalLine.value(x); | ||
horizontalLine.value(y); | ||
multi(d); | ||
}); | ||
}; | ||
verticalLine.value(x); | ||
// Don't use the xValue/yValue convention to indicate that these values are in screen | ||
// not domain co-ordinates and are therefore not scaled. | ||
instance.x = function () { | ||
if (!arguments.length) { | ||
return x; | ||
} | ||
x = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.y = function () { | ||
if (!arguments.length) { | ||
return y; | ||
} | ||
y = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
multi(d); | ||
}); | ||
}; | ||
var lineIncludes = include('label', 'decorate'); | ||
rebindAll(instance, horizontalLine, lineIncludes, prefix('y')); | ||
rebindAll(instance, verticalLine, lineIncludes, prefix('x')); | ||
rebind(instance, point, 'decorate'); | ||
rebind(instance, multi, 'context'); | ||
// Don't use the xValue/yValue convention to indicate that these values are in screen | ||
// not domain co-ordinates and are therefore not scaled. | ||
instance.x = function () { | ||
if (!arguments.length) { | ||
return x; | ||
} | ||
x = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.y = function () { | ||
if (!arguments.length) { | ||
return y; | ||
} | ||
y = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.xScale = function () { | ||
if (!arguments.length) { | ||
return xScale; | ||
} | ||
xScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yScale = function () { | ||
if (!arguments.length) { | ||
return yScale; | ||
} | ||
yScale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
}); | ||
var lineIncludes = include('label', 'decorate'); | ||
rebindAll(instance, horizontalLine, lineIncludes, prefix('y')); | ||
rebindAll(instance, verticalLine, lineIncludes, prefix('x')); | ||
rebind(instance, point, 'decorate'); | ||
rebind(instance, multi, 'context'); | ||
var ticks = (function () { | ||
return instance; | ||
}); | ||
var scale = d3Scale.scaleIdentity(); | ||
var tickArguments = [10]; | ||
var tickValues = null; | ||
var ticks = (function () { | ||
var ticks = function ticks() { | ||
var _scale; | ||
var scale = d3Scale.scaleIdentity(); | ||
var tickArguments = [10]; | ||
var tickValues = null; | ||
return tickValues != null ? tickValues : scale.ticks ? (_scale = scale).ticks.apply(_scale, toConsumableArray(tickArguments)) : scale.domain(); | ||
}; | ||
var ticks = function ticks() { | ||
var _scale; | ||
ticks.scale = function () { | ||
if (!arguments.length) { | ||
return scale; | ||
} | ||
scale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return ticks; | ||
}; | ||
return tickValues != null ? tickValues : scale.ticks ? (_scale = scale).ticks.apply(_scale, toConsumableArray(tickArguments)) : scale.domain(); | ||
}; | ||
ticks.ticks = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
ticks.scale = function () { | ||
if (!arguments.length) { | ||
return scale; | ||
} | ||
scale = arguments.length <= 0 ? undefined : arguments[0]; | ||
return ticks; | ||
}; | ||
tickArguments = args; | ||
return ticks; | ||
}; | ||
ticks.ticks = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
ticks.tickArguments = function () { | ||
if (!arguments.length) { | ||
return tickArguments; | ||
} | ||
tickArguments = arguments.length <= 0 ? undefined : arguments[0]; | ||
return ticks; | ||
}; | ||
tickArguments = args; | ||
return ticks; | ||
}; | ||
ticks.tickValues = function () { | ||
if (!arguments.length) { | ||
return tickValues; | ||
} | ||
tickValues = arguments.length <= 0 ? undefined : arguments[0]; | ||
return ticks; | ||
}; | ||
ticks.tickArguments = function () { | ||
if (!arguments.length) { | ||
return tickArguments; | ||
} | ||
tickArguments = arguments.length <= 0 ? undefined : arguments[0]; | ||
return ticks; | ||
}; | ||
}); | ||
ticks.tickValues = function () { | ||
if (!arguments.length) { | ||
return tickValues; | ||
} | ||
tickValues = arguments.length <= 0 ? undefined : arguments[0]; | ||
return ticks; | ||
var identity = function identity(d) { | ||
return d; | ||
}; | ||
return ticks; | ||
}); | ||
var gridline = (function () { | ||
var identity = function identity(d) { | ||
return d; | ||
}; | ||
var xDecorate = function xDecorate() {}; | ||
var yDecorate = function yDecorate() {}; | ||
var gridline = (function () { | ||
var xTicks = ticks(); | ||
var yTicks = ticks(); | ||
var xJoin = dataJoin('line', 'gridline-y').key(identity); | ||
var yJoin = dataJoin('line', 'gridline-x').key(identity); | ||
var xDecorate = function xDecorate() {}; | ||
var yDecorate = function yDecorate() {}; | ||
var instance = function instance(selection) { | ||
var xTicks = ticks(); | ||
var yTicks = ticks(); | ||
var xJoin = dataJoin('line', 'gridline-y').key(identity); | ||
var yJoin = dataJoin('line', 'gridline-x').key(identity); | ||
if (selection.selection) { | ||
xJoin.transition(selection); | ||
yJoin.transition(selection); | ||
} | ||
var instance = function instance(selection$$1) { | ||
selection.each(function (data, index, nodes) { | ||
if (selection$$1.selection) { | ||
xJoin.transition(selection$$1); | ||
yJoin.transition(selection$$1); | ||
} | ||
var element = nodes[index]; | ||
var container = d3Selection.select(nodes[index]); | ||
selection$$1.each(function (data, index, nodes) { | ||
var xScale = xTicks.scale(); | ||
var yScale = yTicks.scale(); | ||
var element = nodes[index]; | ||
var container = d3Selection.select(nodes[index]); | ||
// Stash a snapshot of the scale, and retrieve the old snapshot. | ||
var xScaleOld = element.__x_scale__ || xScale; | ||
element.__x_scale__ = xScale.copy(); | ||
var xScale = xTicks.scale(); | ||
var yScale = yTicks.scale(); | ||
var xData = xTicks(); | ||
var xLines = xJoin(container, xData); | ||
// Stash a snapshot of the scale, and retrieve the old snapshot. | ||
var xScaleOld = element.__x_scale__ || xScale; | ||
element.__x_scale__ = xScale.copy(); | ||
xLines.enter().attr('x1', xScaleOld).attr('x2', xScaleOld).attr('y1', yScale.range()[0]).attr('y2', yScale.range()[1]); | ||
var xData = xTicks(); | ||
var xLines = xJoin(container, xData); | ||
xLines.attr('x1', xScale).attr('x2', xScale).attr('y1', yScale.range()[0]).attr('y2', yScale.range()[1]).attr('stroke', '#bbb'); | ||
xLines.enter().attr('x1', xScaleOld).attr('x2', xScaleOld).attr('y1', yScale.range()[0]).attr('y2', yScale.range()[1]); | ||
xLines.exit().attr('x1', xScale).attr('x2', xScale); | ||
xLines.attr('x1', xScale).attr('x2', xScale).attr('y1', yScale.range()[0]).attr('y2', yScale.range()[1]).attr('stroke', '#bbb'); | ||
xDecorate(xLines, xData, index); | ||
xLines.exit().attr('x1', xScale).attr('x2', xScale); | ||
// Stash a snapshot of the scale, and retrieve the old snapshot. | ||
var yScaleOld = element.__y_scale__ || yScale; | ||
element.__y_scale__ = yScale.copy(); | ||
xDecorate(xLines, xData, index); | ||
var yData = yTicks(); | ||
var yLines = yJoin(container, yData); | ||
// Stash a snapshot of the scale, and retrieve the old snapshot. | ||
var yScaleOld = element.__y_scale__ || yScale; | ||
element.__y_scale__ = yScale.copy(); | ||
yLines.enter().attr('y1', yScaleOld).attr('y2', yScaleOld).attr('x1', xScale.range()[0]).attr('x2', xScale.range()[1]); | ||
var yData = yTicks(); | ||
var yLines = yJoin(container, yData); | ||
yLines.attr('y1', yScale).attr('y2', yScale).attr('x1', xScale.range()[0]).attr('x2', xScale.range()[1]).attr('stroke', '#bbb'); | ||
yLines.enter().attr('y1', yScaleOld).attr('y2', yScaleOld).attr('x1', xScale.range()[0]).attr('x2', xScale.range()[1]); | ||
yLines.exit().attr('y1', yScale).attr('y2', yScale); | ||
yLines.attr('y1', yScale).attr('y2', yScale).attr('x1', xScale.range()[0]).attr('x2', xScale.range()[1]).attr('stroke', '#bbb'); | ||
yDecorate(yLines, yData, index); | ||
}); | ||
}; | ||
yLines.exit().attr('y1', yScale).attr('y2', yScale); | ||
instance.yDecorate = function () { | ||
if (!arguments.length) { | ||
return yDecorate; | ||
} | ||
yDecorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
yDecorate(yLines, yData, index); | ||
}); | ||
}; | ||
instance.xDecorate = function () { | ||
if (!arguments.length) { | ||
return xDecorate; | ||
} | ||
xDecorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
instance.yDecorate = function () { | ||
if (!arguments.length) { | ||
return yDecorate; | ||
} | ||
yDecorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
rebindAll(instance, xJoin, includeMap({ 'key': 'xKey' })); | ||
rebindAll(instance, yJoin, includeMap({ 'key': 'yKey' })); | ||
instance.xDecorate = function () { | ||
if (!arguments.length) { | ||
return xDecorate; | ||
} | ||
xDecorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
rebindAll(instance, xTicks, prefix('x')); | ||
rebindAll(instance, yTicks, prefix('y')); | ||
return instance; | ||
}; | ||
}); | ||
rebindAll(instance, xJoin, includeMap({ 'key': 'xKey' })); | ||
rebindAll(instance, yJoin, includeMap({ 'key': 'yKey' })); | ||
var gridline$1 = (function () { | ||
rebindAll(instance, xTicks, prefix('x')); | ||
rebindAll(instance, yTicks, prefix('y')); | ||
var xDecorate = function xDecorate() {}; | ||
var yDecorate = function yDecorate() {}; | ||
return instance; | ||
}); | ||
var xTicks = ticks(); | ||
var yTicks = ticks(); | ||
var gridline$1 = (function () { | ||
var lineData = d3Shape.line(); | ||
var xDecorate = function xDecorate() {}; | ||
var yDecorate = function yDecorate() {}; | ||
var instance = function instance() { | ||
var xTicks = ticks(); | ||
var yTicks = ticks(); | ||
var context = lineData.context(); | ||
var xScale = xTicks.scale(); | ||
var yScale = yTicks.scale(); | ||
var lineData = d3Shape.line(); | ||
xTicks().forEach(function (xTick, i) { | ||
context.save(); | ||
context.beginPath(); | ||
context.strokeStyle = '#bbb'; | ||
context.fillStyle = 'transparent'; | ||
var instance = function instance() { | ||
xDecorate(context, xTick, i); | ||
lineData.context(context)(yScale.domain().map(function (d) { | ||
return [xScale(xTick), yScale(d)]; | ||
})); | ||
var context = lineData.context(); | ||
var xScale = xTicks.scale(); | ||
var yScale = yTicks.scale(); | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.restore(); | ||
}); | ||
xTicks().forEach(function (xTick, i) { | ||
context.save(); | ||
context.beginPath(); | ||
context.strokeStyle = '#bbb'; | ||
context.fillStyle = 'transparent'; | ||
yTicks().forEach(function (yTick, i) { | ||
context.save(); | ||
context.beginPath(); | ||
context.strokeStyle = '#bbb'; | ||
context.fillStyle = 'transparent'; | ||
xDecorate(context, xTick, i); | ||
lineData.context(context)(yScale.domain().map(function (d) { | ||
return [xScale(xTick), yScale(d)]; | ||
})); | ||
yDecorate(context, yTick, i); | ||
lineData.context(context)(xScale.domain().map(function (d) { | ||
return [xScale(d), yScale(yTick)]; | ||
})); | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.restore(); | ||
}); | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.restore(); | ||
}); | ||
}; | ||
yTicks().forEach(function (yTick, i) { | ||
context.save(); | ||
context.beginPath(); | ||
context.strokeStyle = '#bbb'; | ||
context.fillStyle = 'transparent'; | ||
instance.yDecorate = function () { | ||
if (!arguments.length) { | ||
return yDecorate; | ||
} | ||
yDecorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
yDecorate(context, yTick, i); | ||
lineData.context(context)(xScale.domain().map(function (d) { | ||
return [xScale(d), yScale(yTick)]; | ||
})); | ||
instance.xDecorate = function () { | ||
if (!arguments.length) { | ||
return xDecorate; | ||
} | ||
xDecorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
context.restore(); | ||
}); | ||
}; | ||
rebindAll(instance, xTicks, prefix('x')); | ||
rebindAll(instance, yTicks, prefix('y')); | ||
rebind(instance, lineData, 'context'); | ||
instance.yDecorate = function () { | ||
if (!arguments.length) { | ||
return yDecorate; | ||
} | ||
yDecorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
}); | ||
instance.xDecorate = function () { | ||
if (!arguments.length) { | ||
return xDecorate; | ||
} | ||
xDecorate = arguments.length <= 0 ? undefined : arguments[0]; | ||
return instance; | ||
}; | ||
exports.annotationCanvasBand = band$1; | ||
exports.annotationCanvasCrosshair = crosshair$1; | ||
exports.annotationCanvasGridline = gridline$1; | ||
exports.annotationCanvasLine = annotationLine$1; | ||
exports.annotationSvgBand = band; | ||
exports.annotationSvgCrosshair = crosshair; | ||
exports.annotationSvgGridline = gridline; | ||
exports.annotationSvgLine = annotationLine; | ||
rebindAll(instance, xTicks, prefix('x')); | ||
rebindAll(instance, yTicks, prefix('y')); | ||
rebind(instance, lineData, 'context'); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
return instance; | ||
}); | ||
exports.annotationSvgBand = band; | ||
exports.annotationCanvasBand = band$1; | ||
exports.annotationSvgCrosshair = crosshair; | ||
exports.annotationCanvasCrosshair = crosshair$1; | ||
exports.annotationSvgLine = annotationLine; | ||
exports.annotationCanvasLine = annotationLine$1; | ||
exports.annotationSvgGridline = gridline; | ||
exports.annotationCanvasGridline = gridline$1; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
})); |
@@ -6,2 +6,10 @@ # Change Log | ||
<a name="2.4.2"></a> | ||
## [2.4.2](https://github.com/d3fc/d3fc/compare/@d3fc/d3fc-annotation@2.4.1...@d3fc/d3fc-annotation@2.4.2) (2019-08-12) | ||
**Note:** Version bump only for package @d3fc/d3fc-annotation | ||
<a name="2.4.1"></a> | ||
@@ -8,0 +16,0 @@ ## [2.4.1](https://github.com/d3fc/d3fc/compare/@d3fc/d3fc-annotation@2.4.0...@d3fc/d3fc-annotation@2.4.1) (2019-05-28) |
{ | ||
"extends": "defaults/configurations/eslint", | ||
"env": { | ||
@@ -4,0 +3,0 @@ "browser": true |
{ | ||
"name": "@d3fc/d3fc-annotation", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"description": "A collection of D3 components for rendering plot area annotations to SVG, including lines, crosshairs, gridlines and more", | ||
@@ -20,7 +20,8 @@ "license": "MIT", | ||
"scripts": { | ||
"bundle": "d3fc-scripts bundle", | ||
"test": "d3fc-scripts test" | ||
"bundle": "npx rollup -c ../../scripts/rollup.config.js", | ||
"test": " npx jasmine --config=../../scripts/jasmine.json", | ||
"lint": "npx eslint src/**/*.js", | ||
"screenshots": "node ../../scripts/screenshot.js" | ||
}, | ||
"devDependencies": { | ||
"@d3fc/d3fc-scripts": "^2.0.5", | ||
"babel-polyfill": "^6.16.0", | ||
@@ -32,6 +33,6 @@ "canvas": "2.3.1", | ||
"dependencies": { | ||
"@d3fc/d3fc-data-join": "^5.0.8", | ||
"@d3fc/d3fc-rebind": "^5.0.7", | ||
"@d3fc/d3fc-series": "^4.0.18", | ||
"@d3fc/d3fc-shape": "^5.0.8", | ||
"@d3fc/d3fc-data-join": "^5.0.9", | ||
"@d3fc/d3fc-rebind": "^5.0.8", | ||
"@d3fc/d3fc-series": "^4.0.19", | ||
"@d3fc/d3fc-shape": "^5.0.9", | ||
"d3-scale": "^1.0.1", | ||
@@ -38,0 +39,0 @@ "d3-selection": "^1.0.2" |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
4
0
0
155337
38
2592
Updated@d3fc/d3fc-data-join@^5.0.9
Updated@d3fc/d3fc-rebind@^5.0.8
Updated@d3fc/d3fc-series@^4.0.19
Updated@d3fc/d3fc-shape@^5.0.9