feat: Enable cross fitlers in WorldMap and Graph charts (#22886)

This commit is contained in:
Kamil Gabryjelski
2023-02-22 11:42:56 +01:00
committed by GitHub
parent a0ca0c04ff
commit 871cab8cbe
9 changed files with 247 additions and 67 deletions

View File

@@ -162,8 +162,16 @@ function getCategoryName(columnName: string, name?: DataRecordValue) {
export default function transformProps(
chartProps: EchartsGraphChartProps,
): GraphChartTransformedProps {
const { width, height, formData, queriesData, hooks, inContextMenu } =
chartProps;
const {
width,
height,
formData,
queriesData,
hooks,
inContextMenu,
filterState,
emitCrossFilters,
} = chartProps;
const data: DataRecord[] = queriesData[0].data || [];
const {
@@ -204,12 +212,13 @@ export default function transformProps(
* Get the node id of an existing node,
* or create a new node if it doesn't exist.
*/
function getOrCreateNode(name: string, category?: string) {
function getOrCreateNode(name: string, col: string, category?: string) {
if (!(name in nodes)) {
nodes[name] = echartNodes.length;
echartNodes.push({
id: String(nodes[name]),
name,
col,
value: 0,
category,
select: DEFAULT_GRAPH_SERIES_OPTION.select,
@@ -244,8 +253,8 @@ export default function transformProps(
const targetCategoryName = targetCategory
? getCategoryName(targetCategory, link[targetCategory])
: undefined;
const sourceNode = getOrCreateNode(sourceName, sourceCategoryName);
const targetNode = getOrCreateNode(targetName, targetCategoryName);
const sourceNode = getOrCreateNode(sourceName, source, sourceCategoryName);
const targetNode = getOrCreateNode(targetName, target, targetCategoryName);
sourceNode.value += value;
targetNode.value += value;
@@ -321,7 +330,7 @@ export default function transformProps(
series,
};
const { onContextMenu } = hooks;
const { onContextMenu, setDataMask } = hooks;
return {
width,
@@ -329,6 +338,9 @@ export default function transformProps(
formData,
echartOptions,
onContextMenu,
setDataMask,
filterState,
refs,
emitCrossFilters,
};
}