MCPcopy
hub / github.com/chartjs/Chart.js / generateLabels

Function generateLabels

src/plugins/plugin.legend.js:675–703  ·  view source on GitHub ↗
(chart)

Source from the content-addressed store, hash-verified

673 // lineJoin :
674 // lineWidth :
675 generateLabels(chart) {
676 const datasets = chart.data.datasets;
677 const {labels: {usePointStyle, pointStyle, textAlign, color, useBorderRadius, borderRadius}} = chart.legend.options;
678
679 return chart._getSortedDatasetMetas().map((meta) => {
680 const style = meta.controller.getStyle(usePointStyle ? 0 : undefined);
681 const borderWidth = toPadding(style.borderWidth);
682
683 return {
684 text: datasets[meta.index].label,
685 fillStyle: style.backgroundColor,
686 fontColor: color,
687 hidden: !meta.visible,
688 lineCap: style.borderCapStyle,
689 lineDash: style.borderDash,
690 lineDashOffset: style.borderDashOffset,
691 lineJoin: style.borderJoinStyle,
692 lineWidth: (borderWidth.width + borderWidth.height) / 4,
693 strokeStyle: style.borderColor,
694 pointStyle: pointStyle || style.pointStyle,
695 rotation: style.rotation,
696 textAlign: textAlign || style.textAlign,
697 borderRadius: useBorderRadius && (borderRadius || style.borderRadius),
698
699 // Below is extra data used for toggling the datasets
700 datasetIndex: meta.index
701 };
702 }, this);
703 }
704 },
705
706 title: {

Callers

nothing calls this directly

Calls 3

toPaddingFunction · 0.85
getStyleMethod · 0.80

Tested by

no test coverage detected