forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(partition): general sunburst via slice show control (opensearch-…
…project#592) * feat(partition): control which slices/sectors are shown, for example, for general sunburst charts * chore(partition): ignore incompliant data
- Loading branch information
Showing
9 changed files
with
177 additions
and
8 deletions.
There are no files selected for viewing
Binary file added
BIN
+68.3 KB
...-tests-for-all-stories-sunburst-heterogeneous-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+45 KB
(2500%)
...isual-tests-for-all-stories-sunburst-negative-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.9 KB
...l-tests-for-all-stories-sunburst-not-a-number-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
packages/osd-charts/stories/sunburst/27_heterogeneous_depth.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. */ | ||
|
||
import { Chart, Datum, Partition, PartitionLayout } from '../../src'; | ||
import { mocks } from '../../src/mocks/hierarchical/index'; | ||
import { config } from '../../src/chart_types/partition_chart/layout/config/config'; | ||
import React from 'react'; | ||
import { ShapeTreeNode } from '../../src/chart_types/partition_chart/layout/types/viewmodel_types'; | ||
import { | ||
categoricalFillColor, | ||
colorBrewerCategoricalStark9, | ||
countryLookup, | ||
productLookup, | ||
regionLookup, | ||
} from '../utils/utils'; | ||
import { PrimitiveValue } from '../../src/chart_types/partition_chart/layout/utils/group_by_rollup'; | ||
|
||
export const example = () => ( | ||
<Chart className="story-chart" /*size={{ width: 1200, height: 800 }}*/> | ||
<Partition | ||
id="spec_1" | ||
data={mocks.miniSunburst} | ||
valueAccessor={(d: Datum) => d.exportVal as number} | ||
valueFormatter={(d: number) => `$${config.fillLabel.valueFormatter(Math.round(d / 1000000000))}\xa0Bn`} | ||
layers={[ | ||
{ | ||
groupByRollup: (d: Datum) => d.sitc1, | ||
nodeLabel: (d: PrimitiveValue) => d !== null && productLookup[d].name, | ||
shape: { | ||
fillColor: (d: ShapeTreeNode) => { | ||
return categoricalFillColor(colorBrewerCategoricalStark9, 0.7)(d.sortIndex); | ||
}, | ||
}, | ||
}, | ||
{ | ||
groupByRollup: (d: Datum) => countryLookup[d.dest].continentCountry.substr(0, 2), | ||
nodeLabel: (d: PrimitiveValue) => d !== null && regionLookup[d].regionName, | ||
shape: { | ||
fillColor: (d: ShapeTreeNode) => { | ||
return categoricalFillColor(colorBrewerCategoricalStark9, 0.5)(d.parent.sortIndex); | ||
}, | ||
}, | ||
}, | ||
{ | ||
groupByRollup: (d: Datum) => d.dest, | ||
nodeLabel: (d: PrimitiveValue) => d !== null && countryLookup[d].name, | ||
showAccessor: (d: PrimitiveValue) => (['chn', 'hkg', 'jpn', 'kor'] as PrimitiveValue[]).indexOf(d) === -1, | ||
shape: { | ||
fillColor: (d: ShapeTreeNode) => { | ||
return categoricalFillColor(colorBrewerCategoricalStark9, 0.3)(d.parent.parent.sortIndex); | ||
}, | ||
}, | ||
}, | ||
]} | ||
config={{ | ||
partitionLayout: PartitionLayout.sunburst, | ||
linkLabel: { | ||
maxCount: 0, | ||
fontSize: 14, | ||
}, | ||
fontFamily: 'Arial', | ||
fillLabel: { | ||
valueFormatter: (d: number) => `$${config.fillLabel.valueFormatter(Math.round(d / 1000000000))}\xa0Bn`, | ||
fontStyle: 'italic', | ||
textInvertible: true, | ||
fontWeight: 900, | ||
valueFont: { | ||
fontFamily: 'Menlo', | ||
fontStyle: 'normal', | ||
fontWeight: 100, | ||
}, | ||
}, | ||
margin: { top: 0, bottom: 0, left: 0, right: 0 }, | ||
minFontSize: 1, | ||
idealFontSizeJump: 1.1, | ||
outerSizeRatio: 1, | ||
emptySizeRatio: 0, | ||
circlePadding: 4, | ||
backgroundColor: 'rgba(229,229,229,1)', | ||
}} | ||
/> | ||
</Chart> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. */ | ||
|
||
import { Chart, Datum, Partition, PartitionLayout } from '../../src'; | ||
import { mocks } from '../../src/mocks/hierarchical/index'; | ||
import { config } from '../../src/chart_types/partition_chart/layout/config/config'; | ||
import React from 'react'; | ||
import { indexInterpolatedFillColor, interpolatorCET2s, productLookup } from '../utils/utils'; | ||
|
||
export const example = () => ( | ||
<Chart className="story-chart"> | ||
<Partition | ||
id="spec_1" | ||
data={mocks.pie | ||
.slice(0, 2) | ||
.concat(mocks.pie.slice(2, 3).map((s) => ({ ...s, exportVal: (undefined as unknown) as number }))) | ||
.concat(mocks.pie.slice(3))} | ||
valueAccessor={(d: Datum) => d.exportVal as number} | ||
valueFormatter={(d: number) => `$${config.fillLabel.valueFormatter(Math.round(d / 1000000000))}\xa0Bn`} | ||
layers={[ | ||
{ | ||
groupByRollup: (d: Datum) => d.sitc1, | ||
nodeLabel: (d: Datum) => productLookup[d].name, | ||
fillLabel: { textInvertible: true }, | ||
shape: { | ||
fillColor: indexInterpolatedFillColor(interpolatorCET2s), | ||
}, | ||
}, | ||
]} | ||
config={{ partitionLayout: PartitionLayout.sunburst }} | ||
/> | ||
</Chart> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters