Skip to content

Commit e563e9d

Browse files
Sunburst Child's color (#212)
* Sunburst Child's color * Updated release notes and changelog * Merge * Fixed merge conflict Co-authored-by: Niels de Jong <[email protected]>
1 parent 6cf44e2 commit e563e9d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

docs/modules/ROOT/pages/user-guide/reports/sunburst.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ an arc needed to display a label (if labels are enabled).
5555
|Slice Corner Radius |number |3 |The rounding angle of each of the arcs
5656
in the visualization.
5757

58+
|Inherit color from parent |on/off |on |If enabled, starting from level 2, each
59+
level will inherit the same color of his parent. If disabled, color will be randomly
60+
assigned based on the color scheme.
61+
5862
|Auto-run query |on/off |on |When activated, automatically runs the
5963
query when the report is displayed. When set to `off', the query is
6064
displayed and will need to be executed manually.

src/chart/sunburst/SunburstChart.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const NeoSunburstChart = (props: ChartProps) => {
1414
}
1515
const records = props.records;
1616
const selection = props.selection;
17-
const [data, setData] = useState(undefined);
1817
useEffect(() => {
1918
setData(commonProperties.data);
2019
}, [props.selection]);
@@ -32,10 +31,15 @@ const NeoSunburstChart = (props: ChartProps) => {
3231
// Where a user give us just the tree starting one hop away from the root.
3332
// as Nivo needs a common root, so in that case, we create it for them.
3433
const commonProperties = { data: dataPre.length == 1 ? dataPre[0] : { name: "Total", children: dataPre } };
34+
35+
const [data, setData] = useState(commonProperties.data);
36+
3537
if(data == undefined){
3638
setData(commonProperties.data);
3739
}
3840

41+
42+
const [back, setBack] = useState(false);
3943
const settings = (props.settings) ? props.settings : {};
4044
const legendHeight = 20;
4145
const marginRight = (settings["marginRight"]) ? settings["marginRight"] : 24;
@@ -45,10 +49,11 @@ const NeoSunburstChart = (props: ChartProps) => {
4549
const enableArcLabels = (settings["enableArcLabels"] !== undefined) ? settings["enableArcLabels"] : true;
4650
const interactive = (settings["interactive"]) ? settings["interactive"] : true;
4751
const borderWidth = (settings["borderWidth"]) ? settings["borderWidth"] : 0;
48-
const legend = (settings["legend"]) ? settings["legend"] : false;
52+
const legend = (settings["legend"] !== undefined) ? settings["legend"] : false;
4953
const arcLabelsSkipAngle = (settings["arcLabelsSkipAngle"]) ? settings["arcLabelsSkipAngle"] : 10;
5054
const cornerRadius = (settings["cornerRadius"]) ? settings["cornerRadius"] : 3;
5155
const colorScheme = (settings["colors"]) ? settings["colors"] : 'nivo';
56+
const inheritColorFromParent = (settings["inheritColorFromParent"] !== undefined) ? settings["inheritColorFromParent"] : true;
5257

5358
if(!data || !data.children || data.children.length == 0){
5459
return <NoDrawableDataErrorMessage />;
@@ -80,6 +85,7 @@ const NeoSunburstChart = (props: ChartProps) => {
8085
enableArcLabels={enableArcLabels}
8186
borderWidth={borderWidth}
8287
cornerRadius={cornerRadius}
88+
inheritColorFromParent = {inheritColorFromParent}
8389
margin={{
8490
top: marginTop,
8591
right: marginRight,

src/config/ReportConfig.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,12 @@ export const REPORT_TYPES = {
951951
type: SELECTION_TYPES.NUMBER,
952952
default: 3
953953
},
954+
"inheritColorFromParent": {
955+
label: "Inherit color from parent",
956+
type: SELECTION_TYPES.LIST,
957+
values: [true, false],
958+
default: true
959+
},
954960
"autorun": {
955961
label: "Auto-run query",
956962
type: SELECTION_TYPES.LIST,

0 commit comments

Comments
 (0)