-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds CSS rules on SVG to help performances. (#78)
* Adds CSS rules on SVG to help performances. Before loading, rules to hide (cull) are added, then, after a zoom threshold is passed, the elements are shown. --------- Signed-off-by: BOUTIER Charly <charly.boutier@rte-france.com>
- Loading branch information
1 parent
3346428
commit 150536c
Showing
5 changed files
with
258 additions
and
17 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
85 changes: 85 additions & 0 deletions
85
src/components/network-area-diagram-viewer/dynamic-css-utils.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,85 @@ | ||
/** | ||
* Copyright (c) 2022-2024, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
export enum THRESHOLD_STATUS { | ||
BELOW = 'BELOW', | ||
ABOVE = 'ABOVE', | ||
} | ||
export type CSS_DECLARATION = Record<string, string>; | ||
export type CSS_RULE = { | ||
cssSelector: string; | ||
belowThresholdCssDeclaration: CSS_DECLARATION; | ||
aboveThresholdCssDeclaration: CSS_DECLARATION; | ||
threshold: number; | ||
thresholdStatus: THRESHOLD_STATUS; | ||
}; | ||
|
||
export const DEFAULT_DYNAMIC_CSS_RULES: CSS_RULE[] = [ | ||
{ | ||
cssSelector: '.nad-edge-infos', // data on edges (arrows and values) | ||
belowThresholdCssDeclaration: { display: 'block' }, | ||
aboveThresholdCssDeclaration: { display: 'none' }, | ||
threshold: 2200, | ||
thresholdStatus: THRESHOLD_STATUS.ABOVE, | ||
}, | ||
{ | ||
cssSelector: '.nad-label-box', // tooltips linked to nodes | ||
belowThresholdCssDeclaration: { display: 'block' }, | ||
aboveThresholdCssDeclaration: { display: 'none' }, | ||
threshold: 3000, | ||
thresholdStatus: THRESHOLD_STATUS.ABOVE, | ||
}, | ||
{ | ||
cssSelector: '.nad-text-edges', // visual link between nodes and their tooltip | ||
belowThresholdCssDeclaration: { display: 'block' }, | ||
aboveThresholdCssDeclaration: { display: 'none' }, | ||
threshold: 3000, | ||
thresholdStatus: THRESHOLD_STATUS.ABOVE, | ||
}, | ||
{ | ||
cssSelector: '[class^="nad-vl0to30"], [class*=" nad-vl0to30"]', | ||
belowThresholdCssDeclaration: { display: 'block' }, | ||
aboveThresholdCssDeclaration: { display: 'none' }, | ||
threshold: 4000, | ||
thresholdStatus: THRESHOLD_STATUS.BELOW, | ||
}, | ||
{ | ||
cssSelector: '[class^="nad-vl30to50"], [class*=" nad-vl30to50"]', | ||
belowThresholdCssDeclaration: { display: 'block' }, | ||
aboveThresholdCssDeclaration: { display: 'none' }, | ||
threshold: 4000, | ||
thresholdStatus: THRESHOLD_STATUS.BELOW, | ||
}, | ||
{ | ||
cssSelector: '[class^="nad-vl50to70"], [class*=" nad-vl50to70"]', | ||
belowThresholdCssDeclaration: { display: 'block' }, | ||
aboveThresholdCssDeclaration: { display: 'none' }, | ||
threshold: 9000, | ||
thresholdStatus: THRESHOLD_STATUS.BELOW, | ||
}, | ||
{ | ||
cssSelector: '[class^="nad-vl70to120"], [class*=" nad-vl70to120"]', | ||
belowThresholdCssDeclaration: { display: 'block' }, | ||
aboveThresholdCssDeclaration: { display: 'none' }, | ||
threshold: 9000, | ||
thresholdStatus: THRESHOLD_STATUS.BELOW, | ||
}, | ||
{ | ||
cssSelector: '[class^="nad-vl120to180"], [class*=" nad-vl120to180"]', | ||
belowThresholdCssDeclaration: { display: 'block' }, | ||
aboveThresholdCssDeclaration: { display: 'none' }, | ||
threshold: 12000, | ||
thresholdStatus: THRESHOLD_STATUS.BELOW, | ||
}, | ||
{ | ||
cssSelector: '[class^="nad-vl180to300"], [class*=" nad-vl180to300"]', | ||
belowThresholdCssDeclaration: { display: 'block' }, | ||
aboveThresholdCssDeclaration: { display: 'none' }, | ||
threshold: 20000, | ||
thresholdStatus: THRESHOLD_STATUS.BELOW, | ||
}, | ||
]; |
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