diff --git a/src/elements/decorators/show-anchors.js b/src/elements/decorators/show-anchors.js index e68795a8c..e74a20ad6 100644 --- a/src/elements/decorators/show-anchors.js +++ b/src/elements/decorators/show-anchors.js @@ -12,7 +12,7 @@ export function elementDecoratorShowAnchors({container, guide, xScale, yScale}) var dots = container .selectAll('circle') - .data(({data: frame}) => frame.data); + .data((fiber) => fiber); dots.exit() .remove(); dots.call(anchorUpdate); diff --git a/src/elements/decorators/show-text.js b/src/elements/decorators/show-text.js index 4d32b9a12..27664e0ff 100644 --- a/src/elements/decorators/show-text.js +++ b/src/elements/decorators/show-text.js @@ -57,7 +57,7 @@ export function elementDecoratorShowText({container, guide, xScale, yScale, text var text = container .selectAll('.caption') - .data(({data: frame}) => frame.data.filter((d) => d[textScale.dim])); + .data((fiber) => fiber.filter((d) => d[textScale.dim])); text.exit() .remove(); text.call(captionUpdate); diff --git a/src/elements/element.line.js b/src/elements/element.line.js index cad941205..e43b84482 100644 --- a/src/elements/element.line.js +++ b/src/elements/element.line.js @@ -6,7 +6,6 @@ import {elementDecoratorShowAnchors} from './decorators/show-anchors'; import {getLineClassesByWidth, getLineClassesByCount} from '../utils/css-class-map'; import {default as _} from 'underscore'; import {default as d3} from 'd3'; -import {utils} from '../utils/utils'; export class Line extends Element { @@ -164,7 +163,7 @@ export class Line extends Element { var path = this .selectAll('path') - .data(({data: frame}) => [frame.data]); + .data((fiber) => [fiber]); path.exit() .remove(); path.attr('d', d3Line) @@ -205,15 +204,15 @@ export class Line extends Element { var updatePoints = function () { var attr = { - r: ({data:d}) => model.size(d), - cx: ({data:d}) => model.x(d), - cy: ({data:d}) => model.y(d), - class: ({data:d}) => (`${pointPref} ${model.color(d)}`) + r: (d) => model.size(d), + cx: (d) => model.x(d), + cy: (d) => model.y(d), + class: (d) => (`${pointPref} ${model.color(d)}`) }; var dots = this .selectAll('circle') - .data(frame => frame.data.data.map(item => ({data: item}))); + .data((fiber) => fiber); dots.exit() .remove(); dots.attr(attr); @@ -221,15 +220,15 @@ export class Line extends Element { .append('circle') .attr(attr); - self.subscribe(dots, ({data:d}) => d); + self.subscribe(dots, (d) => d); }; var updateGroups = (x, isLine) => { return function () { - this.attr('class', ({data: f}) => - `${linePref} ${model.color(f.data[0])} ${x} frame-${f.hash}`) + this.attr('class', (fiber) => + `${linePref} ${model.color(fiber[0])} ${x}`) .call(function () { if (isLine) { @@ -249,17 +248,12 @@ export class Line extends Element { }; var groups = _.groupBy(fullData, model.group); - var fibers = Object.keys(groups).reduce( - (memo, k) => { - return memo.concat({ - data: { - hash: utils.generateHash(k), - data: groups[k] - }, - uid: options.uid - }); - }, - []); + var fibers = Object + .keys(groups) + .reduce((memo, k) => { + memo.push(groups[k]); + return memo; + }, []); var drawFrame = (tag, id, filter) => { @@ -268,7 +262,7 @@ export class Line extends Element { var frameGroups = options .container .selectAll(`.frame-${id}`) - .data(fibers.filter(filter), ({data: f}) => f.hash); + .data(fibers.filter(filter)); frameGroups .exit() .remove(); @@ -280,8 +274,8 @@ export class Line extends Element { .call(updateGroups((`frame-${id}`), isDrawLine)); }; - drawFrame('line', 'line-' + options.uid, ({data: f}) => f.data.length > 1); - drawFrame('anch', 'anch-' + options.uid, ({data: f}) => f.data.length < 2); + drawFrame('line', 'line-' + options.uid, (fiber) => fiber.length > 1); + drawFrame('anch', 'anch-' + options.uid, (fiber) => fiber.length < 2); } highlight(filter) { @@ -291,15 +285,15 @@ export class Line extends Element { container .selectAll('.line') .classed({ - 'graphical-report__highlighted': (({data: d}) => filter(d.data[0]) === true), - 'graphical-report__dimmed': (({data: d}) => filter(d.data[0]) === false) + 'graphical-report__highlighted': ((fiber) => filter(fiber[0]) === true), + 'graphical-report__dimmed': ((fiber) => filter(fiber[0]) === false) }); container .selectAll('.dot-line') .classed({ - 'graphical-report__highlighted': (({data: d}) => filter(d) === true), - 'graphical-report__dimmed': (({data: d}) => filter(d) === false) + 'graphical-report__highlighted': ((d) => filter(d) === true), + 'graphical-report__dimmed': ((d) => filter(d) === false) }); } diff --git a/src/elements/element.path.js b/src/elements/element.path.js index 593d4caf6..9490f98ff 100644 --- a/src/elements/element.path.js +++ b/src/elements/element.path.js @@ -6,7 +6,6 @@ import {elementDecoratorShowText} from './decorators/show-text'; import {elementDecoratorShowAnchors} from './decorators/show-anchors'; import {getLineClassesByCount} from '../utils/css-class-map'; import {default as d3} from 'd3'; -import {utils} from '../utils/utils'; export class Path extends Element { @@ -158,7 +157,7 @@ export class Path extends Element { var path = this .selectAll('polygon') - .data(({data: frame}) => [self.packFrameData(frame.data)]); + .data((fiber) => [self.packFrameData(fiber)]); path.exit() .remove(); path.attr('points', polygonPointsMapper); @@ -198,8 +197,8 @@ export class Path extends Element { return function () { - this.attr('class', ({data: f}) => - `${areaPref} ${model.color(f.data[0])} ${x} frame-${f.hash}`) + this.attr('class', (fiber) => + `${areaPref} ${model.color(fiber[0])} ${x}`) .call(function () { if (guide.color.fill && !model.scaleColor.dim) { @@ -215,23 +214,18 @@ export class Path extends Element { }; var groups = _.groupBy(fullData, model.group); - var fibers = Object.keys(groups).reduce( - (memo, k) => { - return memo.concat({ - data: { - hash: utils.generateHash(k), - data: groups[k] - }, - uid: options.uid - }); - }, - []); + var fibers = Object + .keys(groups) + .reduce((memo, k) => { + memo.push(groups[k]); + return memo; + }, []); var drawFrame = (id) => { var frameGroups = options.container .selectAll(`.frame-${id}`) - .data(fibers, ({data: f}) => f.hash); + .data(fibers); frameGroups .exit() .remove(); @@ -253,8 +247,8 @@ export class Path extends Element { .container .selectAll('.area') .classed({ - 'graphical-report__highlighted': (({data: f}) => filter(f.data[0]) === true), - 'graphical-report__dimmed': (({data: f}) => filter(f.data[0]) === false) + 'graphical-report__highlighted': ((fiber) => filter(fiber[0]) === true), + 'graphical-report__dimmed': ((fiber) => filter(fiber[0]) === false) }); }