Skip to content

Commit af02e06

Browse files
committed
feat(demo): Generate random colors for Pie Chart.
1 parent 22a81fb commit af02e06

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

demo/app/examples/NSChart.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,21 @@ exports.onPieChartLoaded = function(args)
107107
return {label: i + "", value: Math.random() * 100};
108108
});
109109

110+
// Generate pie colors
111+
const colors = [];
112+
while (colors.length < data.length)
113+
{
114+
const c = getRandomColor();
115+
if (!colors.includes(c))
116+
{
117+
colors.push(c);
118+
}
119+
}
120+
110121
console.log('setData', data.length, data[0]);
111122
const sets = [];
112123
const set = new pds.PieDataSet(data, 'value', 'value');
113-
set.setColors([getRandomColor(), getRandomColor()]);
124+
set.setColors(colors);
114125
set.setDrawValues(true);
115126
sets.push(set);
116127

0 commit comments

Comments
 (0)