mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
feat: Adds the ECharts Sunburst chart (#22833)
This commit is contained in:
committed by
GitHub
parent
cd6fc35f60
commit
30abefb519
@@ -16,17 +16,21 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { DataRecord } from '@superset-ui/core';
|
||||
import { DataRecord, DataRecordValue } from '@superset-ui/core';
|
||||
import _ from 'lodash';
|
||||
|
||||
export type TreeNode = {
|
||||
name: string;
|
||||
name: DataRecordValue;
|
||||
value: number;
|
||||
secondaryValue: number;
|
||||
groupBy: string;
|
||||
children?: TreeNode[];
|
||||
};
|
||||
|
||||
function getMetricValue(datum: DataRecord, metric: string) {
|
||||
return _.isNumber(datum[metric]) ? (datum[metric] as number) : 0;
|
||||
}
|
||||
|
||||
export function treeBuilder(
|
||||
data: DataRecord[],
|
||||
groupBy: string[],
|
||||
@@ -37,7 +41,8 @@ export function treeBuilder(
|
||||
const curData = _.groupBy(data, curGroupBy);
|
||||
return _.transform(
|
||||
curData,
|
||||
(result, value, name) => {
|
||||
(result, value, key) => {
|
||||
const name = curData[key][0][curGroupBy]!;
|
||||
if (!restGroupby.length) {
|
||||
(value ?? []).forEach(datum => {
|
||||
const metricValue = getMetricValue(datum, metric);
|
||||
@@ -81,7 +86,3 @@ export function treeBuilder(
|
||||
[] as TreeNode[],
|
||||
);
|
||||
}
|
||||
|
||||
function getMetricValue(datum: DataRecord, metric: string) {
|
||||
return _.isNumber(datum[metric]) ? (datum[metric] as number) : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user