ydb-embedded-ui 20.4.0 → 21.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/components/AutoRefreshControl/i18n/index.d.ts +1 -1
- package/dist/components/FullNodeViewer/i18n/index.d.ts +1 -1
- package/dist/components/Graph/BlockComponents/ConnectionBlockComponent.d.ts +7 -0
- package/dist/components/Graph/BlockComponents/ConnectionBlockComponent.js +30 -0
- package/dist/components/Graph/BlockComponents/ConnectionBlockComponent.js.map +1 -0
- package/dist/components/Graph/BlockComponents/QueryBlockComponent.d.ts +5 -0
- package/dist/components/Graph/BlockComponents/QueryBlockComponent.js +5 -0
- package/dist/components/Graph/BlockComponents/QueryBlockComponent.js.map +1 -0
- package/dist/components/Graph/BlockComponents/ResultBlockComponent.d.ts +7 -0
- package/dist/components/Graph/BlockComponents/ResultBlockComponent.js +5 -0
- package/dist/components/Graph/BlockComponents/ResultBlockComponent.js.map +1 -0
- package/dist/components/Graph/BlockComponents/StageBlockComponent.d.ts +7 -0
- package/dist/components/Graph/BlockComponents/StageBlockComponent.js +17 -0
- package/dist/components/Graph/BlockComponents/StageBlockComponent.js.map +1 -0
- package/dist/components/Graph/FullViewportBackground.d.ts +2 -0
- package/dist/components/Graph/FullViewportBackground.js +67 -0
- package/dist/components/Graph/FullViewportBackground.js.map +1 -0
- package/dist/components/Graph/GraphControls.d.ts +6 -0
- package/dist/components/Graph/GraphControls.js +24 -0
- package/dist/components/Graph/GraphControls.js.map +1 -0
- package/dist/components/Graph/GravityGraph.d.ts +9 -0
- package/dist/components/Graph/GravityGraph.js +122 -0
- package/dist/components/Graph/GravityGraph.js.map +1 -0
- package/dist/components/Graph/GravityGraph.scss +131 -0
- package/dist/components/Graph/NonSelectableConnection.d.ts +9 -0
- package/dist/components/Graph/NonSelectableConnection.js +16 -0
- package/dist/components/Graph/NonSelectableConnection.js.map +1 -0
- package/dist/components/Graph/TooltipComponent.d.ts +8 -0
- package/dist/components/Graph/TooltipComponent.js +63 -0
- package/dist/components/Graph/TooltipComponent.js.map +1 -0
- package/dist/components/Graph/colorsConfig.d.ts +19 -0
- package/dist/components/Graph/colorsConfig.js +20 -0
- package/dist/components/Graph/colorsConfig.js.map +1 -0
- package/dist/components/Graph/i18n/en.json +5 -0
- package/dist/components/Graph/i18n/index.d.ts +2 -0
- package/dist/components/Graph/i18n/index.js +5 -0
- package/dist/components/Graph/i18n/index.js.map +1 -0
- package/dist/components/Graph/runTreeLayout.d.ts +12 -0
- package/dist/components/Graph/runTreeLayout.js +75 -0
- package/dist/components/Graph/runTreeLayout.js.map +1 -0
- package/dist/components/Graph/treeLayout.d.ts +2 -0
- package/dist/components/Graph/treeLayout.js +284 -0
- package/dist/components/Graph/treeLayout.js.map +1 -0
- package/dist/components/Graph/types.d.ts +52 -0
- package/dist/components/Graph/types.js +2 -0
- package/dist/components/Graph/types.js.map +1 -0
- package/dist/components/Graph/utils.d.ts +6 -0
- package/dist/components/Graph/utils.js +88 -0
- package/dist/components/Graph/utils.js.map +1 -0
- package/dist/components/InfoViewer/formatters/pqGroup.d.ts +5 -1
- package/dist/components/InfoViewer/formatters/pqGroup.js +24 -2
- package/dist/components/InfoViewer/formatters/pqGroup.js.map +1 -1
- package/dist/components/InfoViewer/i18n/en.json +8 -1
- package/dist/components/InfoViewer/i18n/index.d.ts +1 -1
- package/dist/components/PDiskInfo/i18n/index.d.ts +1 -1
- package/dist/components/VDiskInfo/i18n/index.d.ts +1 -1
- package/dist/containers/App/Content.js +9 -2
- package/dist/containers/App/Content.js.map +1 -1
- package/dist/containers/App/clusterRouteGuard.d.ts +5 -0
- package/dist/containers/App/clusterRouteGuard.js +13 -0
- package/dist/containers/App/clusterRouteGuard.js.map +1 -0
- package/dist/containers/Clusters/constants.d.ts +1 -1
- package/dist/containers/Nodes/i18n/index.d.ts +1 -1
- package/dist/containers/Operations/constants.d.ts +1 -1
- package/dist/containers/Tenant/Diagnostics/Overview/TableInfo/i18n/index.d.ts +1 -1
- package/dist/containers/Tenant/Diagnostics/Overview/TransferInfo/Credentials.d.ts +1 -1
- package/dist/containers/Tenant/Diagnostics/Overview/utils/prepareTopicSchemaInfo.js +17 -3
- package/dist/containers/Tenant/Diagnostics/Overview/utils/prepareTopicSchemaInfo.js.map +1 -1
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/useTenantStorageNewData.d.ts +2 -2
- package/dist/containers/Tenant/Query/QueryResult/components/Graph/Graph.js +9 -4
- package/dist/containers/Tenant/Query/QueryResult/components/Graph/Graph.js.map +1 -1
- package/dist/containers/Tenant/Query/QueryResult/components/Graph/Graph.scss +2 -0
- package/dist/containers/Tenant/TenantNavigation/useTenantNavigation.d.ts +1 -1
- package/dist/graphLayout.worker.d.ts +1 -0
- package/dist/graphLayout.worker.js +17 -0
- package/dist/graphLayout.worker.js.map +1 -0
- package/dist/lib.d.ts +1 -1
- package/dist/lib.js.map +1 -1
- package/dist/store/reducers/query/parsers/preparePlanData.js.map +1 -1
- package/dist/store/reducers/query/types.d.ts +38 -1
- package/dist/store/reducers/settings/utils.d.ts +2 -2
- package/dist/types/api/schema/persQueueGroup.d.ts +16 -0
- package/dist/types/api/schema/persQueueGroup.js +7 -0
- package/dist/types/api/schema/persQueueGroup.js.map +1 -1
- package/dist/uiFactory/types.d.ts +3 -0
- package/dist/utils/disks/helpers.d.ts +2 -2
- package/dist/utils/hooks/useChangedQuerySettings.d.ts +2 -2
- package/dist/utils/hooks/useLastQueryExecutionSettings.d.ts +2 -2
- package/dist/utils/hooks/useQueryExecutionSettings.d.ts +2 -2
- package/dist/utils/prepareQueryExplain.d.ts +1 -2
- package/dist/utils/prepareQueryExplain.js +10 -2
- package/dist/utils/prepareQueryExplain.js.map +1 -1
- package/dist/utils/query.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/Graph/BlockComponents/ConnectionBlockComponent.tsx +49 -0
- package/src/components/Graph/BlockComponents/QueryBlockComponent.tsx +7 -0
- package/src/components/Graph/BlockComponents/ResultBlockComponent.tsx +10 -0
- package/src/components/Graph/BlockComponents/StageBlockComponent.tsx +35 -0
- package/src/components/Graph/FullViewportBackground.ts +122 -0
- package/src/components/Graph/GraphControls.tsx +49 -0
- package/src/components/Graph/GravityGraph.scss +131 -0
- package/src/components/Graph/GravityGraph.tsx +174 -0
- package/src/components/Graph/NonSelectableConnection.tsx +14 -0
- package/src/components/Graph/TooltipComponent.tsx +114 -0
- package/src/components/Graph/colorsConfig.ts +21 -0
- package/src/components/Graph/i18n/en.json +5 -0
- package/src/components/Graph/i18n/index.ts +7 -0
- package/src/components/Graph/runTreeLayout.ts +105 -0
- package/src/components/Graph/treeLayout.ts +378 -0
- package/src/components/Graph/types.ts +56 -0
- package/src/components/Graph/utils.ts +112 -0
- package/src/components/InfoViewer/formatters/pqGroup.ts +30 -2
- package/src/components/InfoViewer/i18n/en.json +8 -1
- package/src/containers/App/Content.tsx +9 -1
- package/src/containers/App/clusterRouteGuard.ts +24 -0
- package/src/containers/Tenant/Diagnostics/Overview/utils/prepareTopicSchemaInfo.ts +23 -2
- package/src/containers/Tenant/Query/QueryResult/components/Graph/Graph.scss +2 -0
- package/src/containers/Tenant/Query/QueryResult/components/Graph/Graph.tsx +13 -7
- package/src/graphLayout.worker.ts +21 -0
- package/src/lib.ts +1 -0
- package/src/store/reducers/query/parsers/preparePlanData.ts +1 -3
- package/src/store/reducers/query/types.ts +42 -2
- package/src/types/api/schema/persQueueGroup.ts +19 -0
- package/src/uiFactory/types.ts +4 -0
- package/src/utils/prepareQueryExplain.ts +13 -5
- package/dist/components/Graph/Graph.d.ts +0 -12
- package/dist/components/Graph/Graph.js +0 -44
- package/dist/components/Graph/Graph.js.map +0 -1
- package/dist/components/Graph/colors.d.ts +0 -10
- package/dist/components/Graph/colors.js +0 -53
- package/dist/components/Graph/colors.js.map +0 -1
- package/src/components/Graph/Graph.tsx +0 -70
- package/src/components/Graph/colors.ts +0 -75
|
@@ -3,14 +3,17 @@ import {formatObject} from '../../../../../components/InfoViewer';
|
|
|
3
3
|
import {
|
|
4
4
|
formatPQGroupItem,
|
|
5
5
|
formatPQPartitionConfig,
|
|
6
|
+
formatPQPartitionStrategy,
|
|
6
7
|
formatPQTabletConfig,
|
|
7
8
|
} from '../../../../../components/InfoViewer/formatters';
|
|
8
9
|
import type {
|
|
9
10
|
TEvDescribeSchemeResult,
|
|
10
11
|
TPQPartitionConfig,
|
|
12
|
+
TPQPartitionStrategy,
|
|
11
13
|
TPQTabletConfig,
|
|
12
14
|
TPersQueueGroupDescription,
|
|
13
15
|
} from '../../../../../types/api/schema';
|
|
16
|
+
import {EPQPartitionStrategyType} from '../../../../../types/api/schema';
|
|
14
17
|
|
|
15
18
|
export const prepareTopicSchemaInfo = (data?: TEvDescribeSchemeResult): Array<InfoViewerItem> => {
|
|
16
19
|
const pqGroupData = data?.PathDescription?.PersQueueGroup;
|
|
@@ -21,7 +24,7 @@ export const prepareTopicSchemaInfo = (data?: TEvDescribeSchemeResult): Array<In
|
|
|
21
24
|
|
|
22
25
|
const {Partitions = [], PQTabletConfig = {PartitionConfig: {LifetimeSeconds: 0}}} = pqGroupData;
|
|
23
26
|
|
|
24
|
-
const {Codecs, MeteringMode} = PQTabletConfig;
|
|
27
|
+
const {Codecs, MeteringMode, PartitionStrategy} = PQTabletConfig;
|
|
25
28
|
const {WriteSpeedInBytesPerSecond, StorageLimitBytes} = PQTabletConfig.PartitionConfig;
|
|
26
29
|
|
|
27
30
|
//@ts-expect-error
|
|
@@ -40,5 +43,23 @@ export const prepareTopicSchemaInfo = (data?: TEvDescribeSchemeResult): Array<In
|
|
|
40
43
|
MeteringMode,
|
|
41
44
|
});
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
let pqAutopartitioningInfo: InfoViewerItem[] = [];
|
|
47
|
+
const strategyType = PartitionStrategy?.PartitionStrategyType;
|
|
48
|
+
if (PartitionStrategy && strategyType) {
|
|
49
|
+
// For a disabled strategy only the state itself is meaningful; otherwise show the bounds.
|
|
50
|
+
const strategyFields: TPQPartitionStrategy =
|
|
51
|
+
strategyType === EPQPartitionStrategyType.DISABLED
|
|
52
|
+
? {PartitionStrategyType: strategyType}
|
|
53
|
+
: {
|
|
54
|
+
PartitionStrategyType: strategyType,
|
|
55
|
+
MinPartitionCount: PartitionStrategy.MinPartitionCount,
|
|
56
|
+
MaxPartitionCount: PartitionStrategy.MaxPartitionCount,
|
|
57
|
+
};
|
|
58
|
+
pqAutopartitioningInfo = formatObject<TPQPartitionStrategy>(
|
|
59
|
+
formatPQPartitionStrategy,
|
|
60
|
+
strategyFields,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return [...pqGeneralInfo, ...pqPartitionInfo, ...pqTabletInfo, ...pqAutopartitioningInfo];
|
|
44
65
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import {YDBGraph} from '../../../../../../components/Graph/Graph';
|
|
3
|
+
import {GravityGraph} from '../../../../../../components/Graph/GravityGraph';
|
|
6
4
|
import type {PreparedPlan} from '../../../../../../store/reducers/query/types';
|
|
7
5
|
import {cn} from '../../../../../../utils/cn';
|
|
8
6
|
import i18n from '../../i18n';
|
|
@@ -17,22 +15,30 @@ interface GraphProps {
|
|
|
17
15
|
theme?: string;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
function isValidGraphData(data: Partial<
|
|
18
|
+
function isValidGraphData(data: Partial<PreparedPlan>) {
|
|
21
19
|
return Boolean(data.links && data.nodes && data.nodes.length);
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
export function Graph({explain = {}, theme}: GraphProps) {
|
|
25
23
|
const {links, nodes} = explain;
|
|
26
24
|
|
|
27
|
-
const data = React.useMemo(() => ({links, nodes}), [links, nodes]);
|
|
25
|
+
const data = React.useMemo(() => ({links: links || [], nodes: nodes || []}), [links, nodes]);
|
|
26
|
+
const [failedData, setFailedData] = React.useState<typeof data>();
|
|
27
|
+
const handleLayoutError = React.useCallback(
|
|
28
|
+
(error: Error) => {
|
|
29
|
+
console.error(error);
|
|
30
|
+
setFailedData(data);
|
|
31
|
+
},
|
|
32
|
+
[data],
|
|
33
|
+
);
|
|
28
34
|
|
|
29
|
-
if (!isValidGraphData(data)) {
|
|
35
|
+
if (!isValidGraphData(data) || failedData === data) {
|
|
30
36
|
return <StubMessage message={i18n('description.graph-is-not-supported')} />;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
return (
|
|
34
40
|
<div className={b('canvas-container')}>
|
|
35
|
-
<
|
|
41
|
+
<GravityGraph data={data} onError={handleLayoutError} theme={theme} />
|
|
36
42
|
</div>
|
|
37
43
|
);
|
|
38
44
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {prepareTreeLayout} from './components/Graph/treeLayout';
|
|
2
|
+
import type {TreeLayoutRequest, TreeLayoutWorkerResponse} from './components/Graph/types';
|
|
3
|
+
|
|
4
|
+
const workerScope = globalThis as unknown as {
|
|
5
|
+
onmessage: ((event: MessageEvent<TreeLayoutRequest>) => void) | null;
|
|
6
|
+
postMessage: (response: TreeLayoutWorkerResponse) => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
workerScope.onmessage = ({data}) => {
|
|
10
|
+
try {
|
|
11
|
+
workerScope.postMessage({
|
|
12
|
+
type: 'success',
|
|
13
|
+
result: prepareTreeLayout(data),
|
|
14
|
+
});
|
|
15
|
+
} catch (error) {
|
|
16
|
+
workerScope.postMessage({
|
|
17
|
+
type: 'error',
|
|
18
|
+
error: error instanceof Error ? error.message : String(error),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
package/src/lib.ts
CHANGED
|
@@ -40,6 +40,7 @@ export type {ExternalQueryToOpen} from './containers/Tenant/Query/hooks/useOpenE
|
|
|
40
40
|
export type {DrawerContextType} from './components/Drawer';
|
|
41
41
|
export type {GetMonitoringLink, GetMonitoringClusterLink} from './utils/monitoring';
|
|
42
42
|
export type {
|
|
43
|
+
CreateGraphLayoutWorker,
|
|
43
44
|
GetAdditionalDatabaseInfoItems,
|
|
44
45
|
GetReportProblemUrl,
|
|
45
46
|
IllustrationComponent,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type {ExplainPlanNodeData, GraphNode, Link} from '@gravity-ui/paranoid';
|
|
2
|
-
|
|
3
1
|
import type {QueryPlan, ScriptPlan, TKqpStatsQuery} from '../../../../types/api/query';
|
|
4
2
|
import {preparePlan, prepareSimplifiedPlan} from '../../../../utils/prepareQueryExplain';
|
|
5
3
|
import {parseQueryExplainPlan} from '../../../../utils/query';
|
|
6
|
-
import type {PreparedQueryData} from '../types';
|
|
4
|
+
import type {ExplainPlanNodeData, GraphNode, Link, PreparedQueryData} from '../types';
|
|
7
5
|
|
|
8
6
|
const explainVersions = {
|
|
9
7
|
v2: '0.2',
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type {ExplainPlanNodeData, GraphNode, Link} from '@gravity-ui/paranoid';
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
PlanTable,
|
|
5
3
|
QueryPlan,
|
|
@@ -27,6 +25,48 @@ export interface QueryInHistory extends RawQueryInHistory {
|
|
|
27
25
|
status?: QueryExecutionStatusType;
|
|
28
26
|
}
|
|
29
27
|
|
|
28
|
+
export interface Link {
|
|
29
|
+
from: string;
|
|
30
|
+
to: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Metric {
|
|
34
|
+
name: string;
|
|
35
|
+
value: string;
|
|
36
|
+
theme?: 'warning' | 'danger';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface GraphNode<TData = any> {
|
|
40
|
+
name: string;
|
|
41
|
+
status?: string;
|
|
42
|
+
meta?: string;
|
|
43
|
+
group?: string;
|
|
44
|
+
data?: TData;
|
|
45
|
+
metrics?: Metric[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ExplainPlanNodeData {
|
|
49
|
+
id?: number;
|
|
50
|
+
type: 'query' | 'result' | 'stage' | 'connection' | 'materialize';
|
|
51
|
+
name?: string;
|
|
52
|
+
operators?: string[];
|
|
53
|
+
tables?: string[];
|
|
54
|
+
cte?: string;
|
|
55
|
+
stats?: TopologyNodeDataStats[];
|
|
56
|
+
}
|
|
57
|
+
export interface TopologyNodeDataStatsItem {
|
|
58
|
+
name: string;
|
|
59
|
+
value: string | number;
|
|
60
|
+
}
|
|
61
|
+
export interface TopologyNodeDataStatsSection {
|
|
62
|
+
name: string;
|
|
63
|
+
items: TopologyNodeDataStatsItem[];
|
|
64
|
+
}
|
|
65
|
+
export interface TopologyNodeDataStats {
|
|
66
|
+
group: string;
|
|
67
|
+
stats: TopologyNodeDataStatsSection[] | TopologyNodeDataStatsItem[];
|
|
68
|
+
}
|
|
69
|
+
|
|
30
70
|
export interface PreparedPlan {
|
|
31
71
|
links?: Link[];
|
|
32
72
|
nodes?: GraphNode<ExplainPlanNodeData>[];
|
|
@@ -67,6 +67,25 @@ export interface TPQTabletConfig {
|
|
|
67
67
|
Partitions?: TPartition[];
|
|
68
68
|
|
|
69
69
|
MeteringMode?: EMeteringMode;
|
|
70
|
+
|
|
71
|
+
PartitionStrategy?: TPQPartitionStrategy;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export enum EPQPartitionStrategyType {
|
|
75
|
+
DISABLED = 'DISABLED',
|
|
76
|
+
CAN_SPLIT = 'CAN_SPLIT',
|
|
77
|
+
CAN_SPLIT_AND_MERGE = 'CAN_SPLIT_AND_MERGE',
|
|
78
|
+
PAUSED = 'PAUSED',
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Strategy for automatically changing the number of topic partitions depending on the load */
|
|
82
|
+
export interface TPQPartitionStrategy {
|
|
83
|
+
MinPartitionCount?: number;
|
|
84
|
+
MaxPartitionCount?: number;
|
|
85
|
+
ScaleThresholdSeconds?: number;
|
|
86
|
+
ScaleUpPartitionWriteSpeedThresholdPercent?: number;
|
|
87
|
+
ScaleDownPartitionWriteSpeedThresholdPercent?: number;
|
|
88
|
+
PartitionStrategyType?: EPQPartitionStrategyType;
|
|
70
89
|
}
|
|
71
90
|
|
|
72
91
|
export interface TPQPartitionConfig {
|
package/src/uiFactory/types.ts
CHANGED
|
@@ -19,6 +19,7 @@ import type {GetLogsLink} from '../utils/logs';
|
|
|
19
19
|
import type {GetMonitoringClusterLink, GetMonitoringLink} from '../utils/monitoring';
|
|
20
20
|
|
|
21
21
|
export type IllustrationComponent = React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
22
|
+
export type CreateGraphLayoutWorker = () => Worker;
|
|
22
23
|
|
|
23
24
|
export type IllustrationName =
|
|
24
25
|
| 'InternalError'
|
|
@@ -54,6 +55,9 @@ export interface UIFactory<H extends string = CommonIssueCategory, T extends str
|
|
|
54
55
|
|
|
55
56
|
enableMultiTabQueryEditor?: boolean;
|
|
56
57
|
|
|
58
|
+
/** Creates a fresh computation-graph layout worker for each layout run. */
|
|
59
|
+
createGraphLayoutWorker?: CreateGraphLayoutWorker;
|
|
60
|
+
|
|
57
61
|
healthcheck: {
|
|
58
62
|
issueCategories: ReadonlyArray<H>;
|
|
59
63
|
isIssueTypeOfCategory: (type: string, category: H) => boolean;
|
|
@@ -2,12 +2,11 @@ import type {
|
|
|
2
2
|
ExplainPlanNodeData,
|
|
3
3
|
GraphNode,
|
|
4
4
|
Link,
|
|
5
|
+
SimplifiedPlanItem,
|
|
5
6
|
TopologyNodeDataStats,
|
|
6
7
|
TopologyNodeDataStatsItem,
|
|
7
8
|
TopologyNodeDataStatsSection,
|
|
8
|
-
} from '
|
|
9
|
-
|
|
10
|
-
import type {SimplifiedPlanItem} from '../store/reducers/query/types';
|
|
9
|
+
} from '../store/reducers/query/types';
|
|
11
10
|
import type {PlanNode, SimplifiedNode} from '../types/api/query';
|
|
12
11
|
|
|
13
12
|
const CONNECTION_NODE_META_FIELDS = new Set(['PlanNodeId', 'PlanNodeType', 'Node Type', 'Plans']);
|
|
@@ -96,11 +95,19 @@ function getNodeType(plan: PlanNode) {
|
|
|
96
95
|
export function preparePlan(plan: PlanNode) {
|
|
97
96
|
const nodes: GraphNode<ExplainPlanNodeData>[] = [];
|
|
98
97
|
const links: Link[] = [];
|
|
98
|
+
let generatedNodeId = 0;
|
|
99
|
+
|
|
100
|
+
const getGraphNodeId = (node: PlanNode) => {
|
|
101
|
+
return node.PlanNodeId === undefined
|
|
102
|
+
? `generated-plan-node:${generatedNodeId++}`
|
|
103
|
+
: String(node.PlanNodeId);
|
|
104
|
+
};
|
|
99
105
|
|
|
100
106
|
function parsePlans(plans: PlanNode[] = [], from: string) {
|
|
101
107
|
plans.forEach((p) => {
|
|
108
|
+
const nodeId = getGraphNodeId(p);
|
|
102
109
|
const node: GraphNode<ExplainPlanNodeData> = {
|
|
103
|
-
name:
|
|
110
|
+
name: nodeId,
|
|
104
111
|
data: {
|
|
105
112
|
id: p.PlanNodeId,
|
|
106
113
|
type: getNodeType(p),
|
|
@@ -117,8 +124,9 @@ export function preparePlan(plan: PlanNode) {
|
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
const rootPlan = plan;
|
|
127
|
+
const rootNodeId = getGraphNodeId(rootPlan);
|
|
120
128
|
const rootNode: GraphNode<ExplainPlanNodeData> = {
|
|
121
|
-
name:
|
|
129
|
+
name: rootNodeId,
|
|
122
130
|
data: {
|
|
123
131
|
id: rootPlan.PlanNodeId,
|
|
124
132
|
type: getNodeType(rootPlan),
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Data, Options, Shapes } from '@gravity-ui/paranoid';
|
|
2
|
-
interface GraphProps<T> {
|
|
3
|
-
data: Data<T>;
|
|
4
|
-
opts?: Options;
|
|
5
|
-
shapes?: Shapes;
|
|
6
|
-
}
|
|
7
|
-
export declare function Graph<T>(props: GraphProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
interface YDBGraphProps<T> {
|
|
9
|
-
data: Data<T>;
|
|
10
|
-
}
|
|
11
|
-
export declare function YDBGraph<T>(props: YDBGraphProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { getTopology, getYdbPlanNodeShape } from '@gravity-ui/paranoid';
|
|
4
|
-
import { getGraphColorsFromElement, prepareGraphOptions } from './colors';
|
|
5
|
-
export function Graph(props) {
|
|
6
|
-
const containerRef = React.useRef(null);
|
|
7
|
-
const containerId = React.useId();
|
|
8
|
-
const { data, opts, shapes } = props;
|
|
9
|
-
React.useEffect(() => {
|
|
10
|
-
const graphRoot = containerRef.current;
|
|
11
|
-
if (!graphRoot) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
graphRoot.innerHTML = '';
|
|
15
|
-
// set width and height to screen size to make a canvas bigger then the container
|
|
16
|
-
graphRoot.style.setProperty('width', '100vw');
|
|
17
|
-
graphRoot.style.setProperty('height', '100vh');
|
|
18
|
-
const graphColors = getGraphColorsFromElement(graphRoot);
|
|
19
|
-
const topology = getTopology(graphRoot.id, data, prepareGraphOptions(opts, graphColors), shapes);
|
|
20
|
-
topology.render();
|
|
21
|
-
graphRoot.style.setProperty('width', '100%');
|
|
22
|
-
graphRoot.style.setProperty('height', '100%');
|
|
23
|
-
return () => {
|
|
24
|
-
topology.destroy();
|
|
25
|
-
};
|
|
26
|
-
}, [data, opts, shapes]);
|
|
27
|
-
return _jsx("div", { id: containerId, ref: containerRef, style: { overflow: 'auto' } });
|
|
28
|
-
}
|
|
29
|
-
const renderExplainNode = (node) => {
|
|
30
|
-
const parts = node.name.split('|');
|
|
31
|
-
return parts.length > 1 ? parts[1] : node.name;
|
|
32
|
-
};
|
|
33
|
-
const schemaOptions = {
|
|
34
|
-
renderNodeTitle: renderExplainNode,
|
|
35
|
-
textOverflow: 'normal',
|
|
36
|
-
initialZoomFitsCanvas: true,
|
|
37
|
-
};
|
|
38
|
-
const schemaShapes = {
|
|
39
|
-
node: getYdbPlanNodeShape,
|
|
40
|
-
};
|
|
41
|
-
export function YDBGraph(props) {
|
|
42
|
-
return _jsx(Graph, { ...props, opts: schemaOptions, shapes: schemaShapes });
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=Graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../../src/components/Graph/Graph.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAGtE,OAAO,EAAC,yBAAyB,EAAE,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAQxE,MAAM,UAAU,KAAK,CAAI,KAAoB;IACzC,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAiB,IAAI,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAElC,MAAM,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,GAAG,KAAK,CAAC;IAEnC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;QACvC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC;QACzB,iFAAiF;QACjF,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9C,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAE/C,MAAM,WAAW,GAAG,yBAAyB,CAAC,SAAS,CAAC,CAAC;QACzD,MAAM,QAAQ,GAAG,WAAW,CACxB,SAAS,CAAC,EAAE,EACZ,IAAI,EACJ,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAC,EACtC,MAAM,CACT,CAAC;QACF,QAAQ,CAAC,MAAM,EAAE,CAAC;QAClB,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7C,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE;YACR,QAAQ,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAEzB,OAAO,cAAK,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,GAAI,CAAC;AAClF,CAAC;AAED,MAAM,iBAAiB,GAAG,CAAC,IAAe,EAAU,EAAE;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,aAAa,GAAY;IAC3B,eAAe,EAAE,iBAAiB;IAClC,YAAY,EAAE,QAAiB;IAC/B,qBAAqB,EAAE,IAAI;CAC9B,CAAC;AAEF,MAAM,YAAY,GAAG;IACjB,IAAI,EAAE,mBAAmB;CAC5B,CAAC;AAMF,MAAM,UAAU,QAAQ,CAAI,KAAuB;IAC/C,OAAO,KAAC,KAAK,OAAQ,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAI,CAAC;AAC9E,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Colors, Options } from '@gravity-ui/paranoid';
|
|
2
|
-
type CssVariableReader = (name: string) => string;
|
|
3
|
-
export interface GraphColors extends Colors {
|
|
4
|
-
getCommonColor(name: string): string;
|
|
5
|
-
}
|
|
6
|
-
export declare function normalizeCssColor(color: string): string;
|
|
7
|
-
export declare function getGraphColors(readCssVariable?: CssVariableReader): GraphColors;
|
|
8
|
-
export declare function getGraphColorsFromElement(element: Element): GraphColors;
|
|
9
|
-
export declare function prepareGraphOptions(options?: Options, graphColors?: GraphColors): Options;
|
|
10
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { colord } from 'colord';
|
|
2
|
-
const GRAPH_COLOR_VARIABLES = {
|
|
3
|
-
success: '--g-color-text-positive',
|
|
4
|
-
error: '--g-color-text-danger',
|
|
5
|
-
warning: '--g-color-text-warning',
|
|
6
|
-
errorBackground: '--g-color-base-danger-light',
|
|
7
|
-
warningBackground: '--g-color-base-warning-light',
|
|
8
|
-
mute: '--g-color-line-generic',
|
|
9
|
-
stroke: '--g-color-text-hint',
|
|
10
|
-
fill: '--g-color-base-generic-ultralight',
|
|
11
|
-
nodeFill: '--g-color-base-float',
|
|
12
|
-
nodeShadow: '--g-color-sfx-shadow',
|
|
13
|
-
titleColor: '--g-color-text-primary',
|
|
14
|
-
textColor: '--g-color-text-complementary',
|
|
15
|
-
buttonBorderColor: '--g-color-line-generic',
|
|
16
|
-
groupBorderColor: '--g-color-base-info-light-hover',
|
|
17
|
-
groupFill: '--g-color-base-info-light',
|
|
18
|
-
titleHoverColor: '--g-color-text-link-hover',
|
|
19
|
-
nodeHover: '--g-color-base-float-hover',
|
|
20
|
-
specialHover: '--g-color-line-brand',
|
|
21
|
-
};
|
|
22
|
-
export function normalizeCssColor(color) {
|
|
23
|
-
const value = color.trim();
|
|
24
|
-
const normalizedColor = colord(value);
|
|
25
|
-
return normalizedColor.isValid() ? normalizedColor.toRgbString() : value;
|
|
26
|
-
}
|
|
27
|
-
function getDefaultCssVariableReader() {
|
|
28
|
-
const styles = getComputedStyle(document.body);
|
|
29
|
-
return (name) => styles.getPropertyValue(name);
|
|
30
|
-
}
|
|
31
|
-
export function getGraphColors(readCssVariable = getDefaultCssVariableReader()) {
|
|
32
|
-
const colors = Object.fromEntries(Object.entries(GRAPH_COLOR_VARIABLES)
|
|
33
|
-
.map(([key, variable]) => [key, normalizeCssColor(readCssVariable(variable))])
|
|
34
|
-
.filter(([, value]) => value));
|
|
35
|
-
return {
|
|
36
|
-
...colors,
|
|
37
|
-
getCommonColor: (name) => normalizeCssColor(readCssVariable(`--g-color-${name}`)),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export function getGraphColorsFromElement(element) {
|
|
41
|
-
const styles = getComputedStyle(element);
|
|
42
|
-
return getGraphColors((name) => styles.getPropertyValue(name));
|
|
43
|
-
}
|
|
44
|
-
export function prepareGraphOptions(options, graphColors = getGraphColors()) {
|
|
45
|
-
return {
|
|
46
|
-
...options,
|
|
47
|
-
colors: {
|
|
48
|
-
...graphColors,
|
|
49
|
-
...options === null || options === void 0 ? void 0 : options.colors,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=colors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/components/Graph/colors.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAQ9B,MAAM,qBAAqB,GAAG;IAC1B,OAAO,EAAE,yBAAyB;IAClC,KAAK,EAAE,uBAAuB;IAC9B,OAAO,EAAE,wBAAwB;IACjC,eAAe,EAAE,6BAA6B;IAC9C,iBAAiB,EAAE,8BAA8B;IACjD,IAAI,EAAE,wBAAwB;IAC9B,MAAM,EAAE,qBAAqB;IAC7B,IAAI,EAAE,mCAAmC;IACzC,QAAQ,EAAE,sBAAsB;IAChC,UAAU,EAAE,sBAAsB;IAClC,UAAU,EAAE,wBAAwB;IACpC,SAAS,EAAE,8BAA8B;IACzC,iBAAiB,EAAE,wBAAwB;IAC3C,gBAAgB,EAAE,iCAAiC;IACnD,SAAS,EAAE,2BAA2B;IACtC,eAAe,EAAE,2BAA2B;IAC5C,SAAS,EAAE,4BAA4B;IACvC,YAAY,EAAE,sBAAsB;CACA,CAAC;AAEzC,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3B,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAEtC,OAAO,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7E,CAAC;AAED,SAAS,2BAA2B;IAChC,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,cAAc,CAC1B,kBAAqC,2BAA2B,EAAE;IAElE,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAC7B,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC;SAChC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,iBAAiB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC7E,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAC1B,CAAC;IAEZ,OAAO;QACH,GAAG,MAAM;QACT,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;KACpF,CAAC;AACN,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACtD,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,OAAO,cAAc,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAC/B,OAAiB,EACjB,cAA2B,cAAc,EAAE;IAE3C,OAAO;QACH,GAAG,OAAO;QACV,MAAM,EAAE;YACJ,GAAG,WAAW;YACd,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM;SACrB;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {getTopology, getYdbPlanNodeShape} from '@gravity-ui/paranoid';
|
|
4
|
-
import type {Data, GraphNode, Options, Shapes} from '@gravity-ui/paranoid';
|
|
5
|
-
|
|
6
|
-
import {getGraphColorsFromElement, prepareGraphOptions} from './colors';
|
|
7
|
-
|
|
8
|
-
interface GraphProps<T> {
|
|
9
|
-
data: Data<T>;
|
|
10
|
-
opts?: Options;
|
|
11
|
-
shapes?: Shapes;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function Graph<T>(props: GraphProps<T>) {
|
|
15
|
-
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
16
|
-
const containerId = React.useId();
|
|
17
|
-
|
|
18
|
-
const {data, opts, shapes} = props;
|
|
19
|
-
|
|
20
|
-
React.useEffect(() => {
|
|
21
|
-
const graphRoot = containerRef.current;
|
|
22
|
-
if (!graphRoot) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
graphRoot.innerHTML = '';
|
|
27
|
-
// set width and height to screen size to make a canvas bigger then the container
|
|
28
|
-
graphRoot.style.setProperty('width', '100vw');
|
|
29
|
-
graphRoot.style.setProperty('height', '100vh');
|
|
30
|
-
|
|
31
|
-
const graphColors = getGraphColorsFromElement(graphRoot);
|
|
32
|
-
const topology = getTopology(
|
|
33
|
-
graphRoot.id,
|
|
34
|
-
data,
|
|
35
|
-
prepareGraphOptions(opts, graphColors),
|
|
36
|
-
shapes,
|
|
37
|
-
);
|
|
38
|
-
topology.render();
|
|
39
|
-
graphRoot.style.setProperty('width', '100%');
|
|
40
|
-
graphRoot.style.setProperty('height', '100%');
|
|
41
|
-
return () => {
|
|
42
|
-
topology.destroy();
|
|
43
|
-
};
|
|
44
|
-
}, [data, opts, shapes]);
|
|
45
|
-
|
|
46
|
-
return <div id={containerId} ref={containerRef} style={{overflow: 'auto'}} />;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const renderExplainNode = (node: GraphNode): string => {
|
|
50
|
-
const parts = node.name.split('|');
|
|
51
|
-
return parts.length > 1 ? parts[1] : node.name;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const schemaOptions: Options = {
|
|
55
|
-
renderNodeTitle: renderExplainNode,
|
|
56
|
-
textOverflow: 'normal' as const,
|
|
57
|
-
initialZoomFitsCanvas: true,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const schemaShapes = {
|
|
61
|
-
node: getYdbPlanNodeShape,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
interface YDBGraphProps<T> {
|
|
65
|
-
data: Data<T>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function YDBGraph<T>(props: YDBGraphProps<T>) {
|
|
69
|
-
return <Graph<T> {...props} opts={schemaOptions} shapes={schemaShapes} />;
|
|
70
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type {Colors, Options} from '@gravity-ui/paranoid';
|
|
2
|
-
import {colord} from 'colord';
|
|
3
|
-
|
|
4
|
-
type CssVariableReader = (name: string) => string;
|
|
5
|
-
|
|
6
|
-
export interface GraphColors extends Colors {
|
|
7
|
-
getCommonColor(name: string): string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const GRAPH_COLOR_VARIABLES = {
|
|
11
|
-
success: '--g-color-text-positive',
|
|
12
|
-
error: '--g-color-text-danger',
|
|
13
|
-
warning: '--g-color-text-warning',
|
|
14
|
-
errorBackground: '--g-color-base-danger-light',
|
|
15
|
-
warningBackground: '--g-color-base-warning-light',
|
|
16
|
-
mute: '--g-color-line-generic',
|
|
17
|
-
stroke: '--g-color-text-hint',
|
|
18
|
-
fill: '--g-color-base-generic-ultralight',
|
|
19
|
-
nodeFill: '--g-color-base-float',
|
|
20
|
-
nodeShadow: '--g-color-sfx-shadow',
|
|
21
|
-
titleColor: '--g-color-text-primary',
|
|
22
|
-
textColor: '--g-color-text-complementary',
|
|
23
|
-
buttonBorderColor: '--g-color-line-generic',
|
|
24
|
-
groupBorderColor: '--g-color-base-info-light-hover',
|
|
25
|
-
groupFill: '--g-color-base-info-light',
|
|
26
|
-
titleHoverColor: '--g-color-text-link-hover',
|
|
27
|
-
nodeHover: '--g-color-base-float-hover',
|
|
28
|
-
specialHover: '--g-color-line-brand',
|
|
29
|
-
} satisfies Record<keyof Colors, string>;
|
|
30
|
-
|
|
31
|
-
export function normalizeCssColor(color: string) {
|
|
32
|
-
const value = color.trim();
|
|
33
|
-
const normalizedColor = colord(value);
|
|
34
|
-
|
|
35
|
-
return normalizedColor.isValid() ? normalizedColor.toRgbString() : value;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getDefaultCssVariableReader(): CssVariableReader {
|
|
39
|
-
const styles = getComputedStyle(document.body);
|
|
40
|
-
|
|
41
|
-
return (name) => styles.getPropertyValue(name);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getGraphColors(
|
|
45
|
-
readCssVariable: CssVariableReader = getDefaultCssVariableReader(),
|
|
46
|
-
): GraphColors {
|
|
47
|
-
const colors = Object.fromEntries(
|
|
48
|
-
Object.entries(GRAPH_COLOR_VARIABLES)
|
|
49
|
-
.map(([key, variable]) => [key, normalizeCssColor(readCssVariable(variable))])
|
|
50
|
-
.filter(([, value]) => value),
|
|
51
|
-
) as Colors;
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
...colors,
|
|
55
|
-
getCommonColor: (name) => normalizeCssColor(readCssVariable(`--g-color-${name}`)),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function getGraphColorsFromElement(element: Element): GraphColors {
|
|
60
|
-
const styles = getComputedStyle(element);
|
|
61
|
-
return getGraphColors((name) => styles.getPropertyValue(name));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function prepareGraphOptions(
|
|
65
|
-
options?: Options,
|
|
66
|
-
graphColors: GraphColors = getGraphColors(),
|
|
67
|
-
): Options {
|
|
68
|
-
return {
|
|
69
|
-
...options,
|
|
70
|
-
colors: {
|
|
71
|
-
...graphColors,
|
|
72
|
-
...options?.colors,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|