Skip to content

Commit

Permalink
fix: ci and bench (#5880)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored Dec 5, 2023
1 parent c78da52 commit 046ea5f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
41 changes: 22 additions & 19 deletions scripts/bench/chart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@antv/g2v5';
import { render, stdlib } from '@antv/g2v5';
import { html } from 'htl';
import * as _cases from './tests/chart';

Expand Down Expand Up @@ -162,14 +162,14 @@ async function launch(container: HTMLDivElement) {
end: (node: any) => {
const result = performance.measure(key, key);
results.push(result);
renderPrefResultEach(container, node, key, result, false);
renderPrefResultEach(container, node, key, result, true);
resolve();
},
});
});
}

renderPreResultAll(container, results);
// renderPreResultAll(container, results);

renderReportUpload(container, results);

Expand Down Expand Up @@ -212,26 +212,29 @@ function renderPreResultAll(
const dashboard = document.createElement('div');
dashboard.id = id;
container.appendChild(dashboard);
const node = render({
type: 'interval',
width: 1000,
data: results,
encode: { x: 'name', y: 'duration' },
style: { fill: 'black' },
transform: [{ type: 'sortX', by: 'y', reverse: true }],
scale: {
y: { nice: true },
const node = render(
{
type: 'interval',
width: 1000,
data: results,
encode: { x: 'name', y: 'duration' },
style: { fill: 'black' },
transform: [{ type: 'sortX', by: 'y', reverse: true }],
scale: {
y: { nice: true },
},
axis: {
x: { labelAutoRotate: false, title: 'library + env' },
y: { title: 'duration(ms)' },
},
labels: [{ text: 'duration', position: 'inside', formatter: '.1f' }],
},
axis: {
x: { labelAutoRotate: false, title: 'library + env' },
y: { title: 'duration(ms)' },
},
labels: [{ text: 'duration', position: 'inside', formatter: '.1f' }],
});
{ library: stdlib() },
);
dashboard.appendChild(node);
}

function clearNodes(className: string = 'chart') {
function clearNodes(className = 'chart') {
const charts = document.getElementsByClassName(className);
Array.from(charts).forEach((d) => d.remove());
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/bench/tests/chart/point-temperatures/g2-v4-canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const g2V4Canvas: ChartType = (data, { start, end }) => {

chart.point().position('date*value').style({ stroke: 'black' });

chart.animate(false);

chart.render();

end(node);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { render } from '@antv/g2v5';
import { render, stdlib } from '@antv/g2v5';
import type { Chart } from '../types';

export const g2V5CanvasSpec: Chart = (data, { start, end }) => {
let node: HTMLElement;
start();
node = render(
const node = render(
{
type: 'point',
data,
Expand All @@ -18,7 +17,7 @@ export const g2V5CanvasSpec: Chart = (data, { start, end }) => {
},
animate: false,
},
undefined,
{ library: stdlib() },
() => end(node),
);
};
9 changes: 3 additions & 6 deletions src/runtime/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function useLibrary<
>(
namespace: G2ComponentNamespaces,
publicLibrary: G2Library,
): [(options: O, context?: G2Context) => V, (type: O['type']) => C] {
): [(options: O, context?) => V, (type: O['type']) => C] {
const library = { ...builtinlib(), ...publicLibrary };

const create = (type: O['type']) => {
Expand All @@ -24,12 +24,9 @@ export function useLibrary<
return library[key] || error(`Unknown Component: ${key}`);
};

const use = (options: O, context?: G2Context) => {
const use = (options: O, context?) => {
const { type, ...rest } = options;
if (!type) {
error(`Plot type is required!`);
}

if (!type) error(`Plot type is required!`);
const currentLibrary = create(type);
return currentLibrary?.(rest, context);
};
Expand Down

0 comments on commit 046ea5f

Please sign in to comment.