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

Method generateLabels

src/controllers/controller.doughnut.js:92–119  ·  view source on GitHub ↗
(chart)

Source from the content-addressed store, hash-verified

90 legend: {
91 labels: {
92 generateLabels(chart) {
93 const data = chart.data;
94 const {labels: {pointStyle, textAlign, color, useBorderRadius, borderRadius}} = chart.legend.options;
95 if (data.labels.length && data.datasets.length) {
96 return data.labels.map((label, i) => {
97 const meta = chart.getDatasetMeta(0);
98 const style = meta.controller.getStyle(i);
99
100 return {
101 text: label,
102 fillStyle: style.backgroundColor,
103 fontColor: color,
104 hidden: !chart.getDataVisibility(i),
105 lineDash: style.borderDash,
106 lineDashOffset: style.borderDashOffset,
107 lineJoin: style.borderJoinStyle,
108 lineWidth: style.borderWidth,
109 strokeStyle: style.borderColor,
110 textAlign: textAlign,
111 pointStyle: pointStyle,
112 borderRadius: useBorderRadius && (borderRadius || style.borderRadius),
113 // Extra data used for toggling the correct item
114 index: i
115 };
116 });
117 }
118 return [];
119 }
120 },
121
122 onClick(e, legendItem, legend) {

Callers 1

Calls 3

getDatasetMetaMethod · 0.80
getStyleMethod · 0.80
getDataVisibilityMethod · 0.80

Tested by

no test coverage detected