From a15eda841d47556ab1345ea5d9f743c635a032fd Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Wed, 1 May 2024 07:25:52 -0400 Subject: [PATCH 1/5] remove path log --- avenger-vega-renderer/src/marks/path.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/avenger-vega-renderer/src/marks/path.rs b/avenger-vega-renderer/src/marks/path.rs index 7b1baa9..3796ef6 100644 --- a/avenger-vega-renderer/src/marks/path.rs +++ b/avenger-vega-renderer/src/marks/path.rs @@ -18,7 +18,6 @@ pub struct PathMark { impl PathMark { pub fn build(self) -> RsPathMark { - log(&format!("{:#?}", self.inner)); self.inner } } From 9e7f5d422a2a4273fa38853d86a251a53aa34c40 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Wed, 1 May 2024 07:34:29 -0400 Subject: [PATCH 2/5] Add verbose option to avenger-vega-renderer --- avenger-vega-renderer/js/index.js | 15 ++++++++++++--- avenger-vega-renderer/test/test_server/index.js | 2 +- .../test/test_server/package-lock.json | 2 +- examples/vega-renderer/index.js | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/avenger-vega-renderer/js/index.js b/avenger-vega-renderer/js/index.js index 4b87bf3..edb573f 100644 --- a/avenger-vega-renderer/js/index.js +++ b/avenger-vega-renderer/js/index.js @@ -6,6 +6,8 @@ import { importScenegraph } from "./marks/scenegraph.js" // Load wasm instantiate(); +const AVENGER_OPTIONS = {} + function devicePixelRatio() { return typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1; } @@ -102,7 +104,7 @@ inherits(AvengerRenderer, Renderer, { }, _render(scene) { - console.log("scene graph construction time: " + (performance.now() - this._lastRenderFinishTime)); + this.log("scene graph construction time: " + (performance.now() - this._lastRenderFinishTime)) this._avengerCanvasPromise.then((avengerCanvas) => { var start = performance.now(); importScenegraph( @@ -113,11 +115,17 @@ inherits(AvengerRenderer, Renderer, { this._loader, ).then((sceneGraph) => { avengerCanvas.set_scene(sceneGraph); - console.log("_render time: " + (performance.now() - start)); + this.log("_render time: " + (performance.now() - start)); }); }); this._lastRenderFinishTime = performance.now(); return this; + }, + + log(msg) { + if (AVENGER_OPTIONS["verbose"]) { + console.log(msg); + } } }) @@ -132,7 +140,8 @@ inherits(AvengerHandler, CanvasHandler, { } }); -export function registerVegaRenderer(renderModule) { +export function registerVegaRenderer(renderModule, verbose) { + AVENGER_OPTIONS['verbose'] = verbose ?? false; // Call with renderModule function from 'vega-scenegraph' renderModule('avenger', { handler: AvengerHandler, diff --git a/avenger-vega-renderer/test/test_server/index.js b/avenger-vega-renderer/test/test_server/index.js index 43ba08c..f929237 100644 --- a/avenger-vega-renderer/test/test_server/index.js +++ b/avenger-vega-renderer/test/test_server/index.js @@ -14,7 +14,7 @@ const spec = { }; // Make the "avenger" renderer available -registerVegaRenderer(renderModule); +registerVegaRenderer(renderModule, true); // Make vega embed available globally so that we can call it using playwright window.vegaEmbed = vegaEmbed; diff --git a/avenger-vega-renderer/test/test_server/package-lock.json b/avenger-vega-renderer/test/test_server/package-lock.json index 918faeb..ef51177 100644 --- a/avenger-vega-renderer/test/test_server/package-lock.json +++ b/avenger-vega-renderer/test/test_server/package-lock.json @@ -46,7 +46,7 @@ }, "../../dist": { "name": "avenger-vega-renderer", - "version": "0.1.0", + "version": "0.0.4", "license": "ISC", "devDependencies": { "typescript": "^5" diff --git a/examples/vega-renderer/index.js b/examples/vega-renderer/index.js index f8c773b..2561712 100644 --- a/examples/vega-renderer/index.js +++ b/examples/vega-renderer/index.js @@ -326,7 +326,7 @@ var spec = { // ] // }; -registerVegaRenderer(renderModule); +registerVegaRenderer(renderModule, true); vegaEmbed('#plot-container', spec, { // renderer: "canvas", From adea992576eef4bee8bf3a990e15abfb14376c09 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Wed, 1 May 2024 07:40:56 -0400 Subject: [PATCH 3/5] Add verbose option to avenger-html renderer --- avenger-python/avenger/altair_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avenger-python/avenger/altair_utils.py b/avenger-python/avenger/altair_utils.py index d22686b..220435c 100644 --- a/avenger-python/avenger/altair_utils.py +++ b/avenger-python/avenger/altair_utils.py @@ -29,7 +29,7 @@ def avenger_png_renderer(spec: dict, **kwargs) -> dict: return {"image/png": sg.to_png(scale=kwargs.get("scale", None))} -def avenger_html_renderer(spec: dict, **kwargs) -> dict: +def avenger_html_renderer(spec: dict, verbose=False, **kwargs) -> dict: """ Altair renderer plugin that uses Avenger to render interactive charts @@ -68,7 +68,7 @@ def avenger_html_renderer(spec: dict, **kwargs) -> dict: