MCPcopy
hub / github.com/dc-js/dc.js / _drawLabels

Method _drawLabels

src/charts/line-chart.js:431–457  ·  view source on GitHub ↗
(layers)

Source from the content-addressed store, hash-verified

429 }
430
431 _drawLabels (layers) {
432 const chart = this;
433 layers.each(function (data, layerIndex) {
434 const layer = select(this);
435 const labels = layer.selectAll('text.lineLabel')
436 .data(data.values, pluck('x'));
437
438 const labelsEnterModify = labels
439 .enter()
440 .append('text')
441 .attr('class', 'lineLabel')
442 .attr('text-anchor', 'middle')
443 .merge(labels);
444
445 transition(labelsEnterModify, chart.transitionDuration())
446 .attr('x', d => utils.safeNumber(chart.x()(d.x)))
447 .attr('y', d => {
448 const y = chart.y()(d.y + d.y0) - LABEL_PADDING;
449 return utils.safeNumber(y);
450 })
451 .text(d => chart.label()(d));
452
453 transition(labels.exit(), chart.transitionDuration())
454 .attr('height', 0)
455 .remove();
456 });
457 }
458
459 _createRefLines (g) {
460 const yRefLine = g.select(`path.${Y_AXIS_REF_LINE_CLASS}`).empty() ?

Callers 1

plotDataMethod · 0.95

Calls 8

pluckFunction · 0.90
transitionFunction · 0.90
dataMethod · 0.80
selectAllMethod · 0.80
transitionDurationMethod · 0.80
labelMethod · 0.80
xMethod · 0.45
yMethod · 0.45

Tested by

no test coverage detected