mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
Feature: Pie charts
This commit is contained in:
parent
06621cd7b8
commit
5bdc399226
2 changed files with 18 additions and 7 deletions
|
|
@ -68,12 +68,22 @@ export const Chart = function Chart({
|
|||
|
||||
if(!Array.isArray(rawData)) { rawData = []; }
|
||||
|
||||
const newData = [{
|
||||
type: chartType || 'line',
|
||||
x: rawData.map((item) => item["x"]),
|
||||
y: rawData.map((item) => item["y"]),
|
||||
marker: { color: markerColor }
|
||||
}];
|
||||
let newData = [];
|
||||
|
||||
if(chartType === 'pie') {
|
||||
newData = [{
|
||||
type: chartType,
|
||||
values: rawData.map((item) => item["value"]),
|
||||
labels: rawData.map((item) => item["label"]),
|
||||
}];
|
||||
} else {
|
||||
newData = [{
|
||||
type: chartType || 'line',
|
||||
x: rawData.map((item) => item["x"]),
|
||||
y: rawData.map((item) => item["y"]),
|
||||
marker: { color: markerColor }
|
||||
}];
|
||||
}
|
||||
|
||||
setChartData(newData);
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,8 @@ export const componentTypes = [
|
|||
showGridLines: { type: 'toggle', displayName: 'Show grid lines'},
|
||||
type: { type: 'select', displayName: 'Chart type', options: [
|
||||
{ name: 'Line', value: 'line' },
|
||||
{ name: 'Bar', value: 'bar' }
|
||||
{ name: 'Bar', value: 'bar' },
|
||||
{ name: 'Pie', value: 'pie' }
|
||||
] },
|
||||
},
|
||||
events: {},
|
||||
|
|
|
|||
Loading…
Reference in a new issue