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): add legend and highlighters (opensearch-project#616)
This commit adds the legend and highlighters to partition charts. Two new options are added to the <Settings/> components: `flatLegend` will flat the legend for pie/tree hierarchical legend and `legendMaxDepth` will limit the legend hierarchy to a maximum depth value: 1 is the root level (can be combined with the `flatLegend`). close opensearch-project#486, close opensearch-project#532
- Loading branch information
Showing
80 changed files
with
1,890 additions
and
832 deletions.
There are no files selected for viewing
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
Binary file modified
BIN
+14.9 KB
(130%)
...ll-stories-interactions-sunburst-slice-clicks-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
+113 KB
...-visual-tests-for-all-stories-legend-piechart-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
+43.3 KB
...ests-for-all-stories-sunburst-single-sunburst-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
+16.7 KB
(120%)
...l-stories-sunburst-sunburst-with-three-layers-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
+3.92 KB
(100%)
...-tests-for-all-stories-treemap-mid-two-layers-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
-16.4 KB
(89%)
...or-all-stories-treemap-two-layers-stress-test-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
+16 KB
(130%)
.../interactions-test-ts-tooltips-rotation-90-shows-tooltip-on-sunburst-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
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
57 changes: 57 additions & 0 deletions
57
packages/osd-charts/src/chart_types/partition_chart/layout/viewmodel/hierarchy_of_arrays.ts
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,57 @@ | ||
/* | ||
* 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 { HierarchyOfArrays } from '../utils/group_by_rollup'; | ||
import { Relation } from '../types/types'; | ||
import { ValueAccessor } from '../../../../utils/commons'; | ||
import { IndexedAccessorFn } from '../../../../utils/accessor'; | ||
import { | ||
aggregateComparator, | ||
aggregators, | ||
childOrders, | ||
groupByRollup, | ||
mapEntryValue, | ||
mapsToArrays, | ||
} from '../utils/group_by_rollup'; | ||
|
||
export function getHierarchyOfArrays( | ||
rawFacts: Relation, | ||
valueAccessor: ValueAccessor, | ||
groupByRollupAccessors: IndexedAccessorFn[], | ||
): HierarchyOfArrays { | ||
const aggregator = aggregators.sum; | ||
|
||
const facts = rawFacts.filter((n) => { | ||
const value = valueAccessor(n); | ||
return Number.isFinite(value) && value >= 0; | ||
}); | ||
|
||
// don't render anything if the total, the width or height is not positive | ||
if (facts.reduce((p: number, n) => aggregator.reducer(p, valueAccessor(n)), aggregator.identity()) <= 0) { | ||
return []; | ||
} | ||
|
||
// We can precompute things invariant of how the rectangle is divvied up. | ||
// By introducing `scale`, we no longer need to deal with the dichotomy of | ||
// size as data value vs size as number of pixels in the rectangle | ||
|
||
return mapsToArrays( | ||
groupByRollup(groupByRollupAccessors, valueAccessor, aggregator, facts), | ||
aggregateComparator(mapEntryValue, childOrders.descending), | ||
); | ||
} |
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
Oops, something went wrong.