Skip to content

Commit

Permalink
refactor(runtime): plot
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed Mar 28, 2022
1 parent fc6591d commit fb21d9d
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/runtime/plot.ts
Expand Up @@ -140,25 +140,10 @@ async function plotArea(options: G2Area, context: G2Context): Promise<void> {
options,
);

// Sorted marks and components by zIndex.
const displays: G2Display[] = [
...components.map(
(component): G2Display => ({
type: 'component',
zIndex: component.zIndex || -1,
display: component,
}),
),
...Array.from(markProps.keys()).map(
(mark): G2Display => ({
type: 'mark',
zIndex: mark.zIndex || 0,
display: mark,
}),
),
].sort((a, b) => a.zIndex - b.zIndex);
// Sort marks and components by zIndex.
const displays = normalizeDisplays(marks, components);
displays.sort((a, b) => a.zIndex - b.zIndex);

// @todo Refactor into renderComponents and renderMarks.
for (const { type, display } of displays) {
if (type === 'component') {
// Render components with corresponding bbox and scale(if required).
Expand Down Expand Up @@ -202,6 +187,28 @@ function inferTheme(theme: G2ThemeOptions = { type: 'light' }): G2ThemeOptions {
return { ...theme, type };
}

function normalizeDisplays(
marks: G2Mark[],
components: G2GuideComponentOptions[],
): G2Display[] {
return [
...components.map(
(component): G2Display => ({
type: 'component',
zIndex: component.zIndex || -1,
display: component,
}),
),
...marks.map(
(mark): G2Display => ({
type: 'mark',
zIndex: mark.zIndex || 0,
display: mark,
}),
),
];
}

function applyAnimation(
I: number[],
shapes: DisplayObject[],
Expand Down

0 comments on commit fb21d9d

Please sign in to comment.