MCPcopy Create free account
hub / github.com/chartjs/Chart.js / generateLabels

Method generateLabels

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 3

getDatasetMetaMethod · 0.80
getStyleMethod · 0.80
getDataVisibilityMethod · 0.80

Tested by

no test coverage detected