brownplt / code.pyret.org

Website for serving Pyret to folks.
Other
24 stars 45 forks source link

Reverted files and updated geochart chart window code #418

Open schornb opened 2 years ago

jpolitz commented 2 years ago

Thanks for cleaning up this PR! It made it much easier to understand what was going on for me, I really appreciate it.

When I run this example:

include chart

an-example-geochart-series = from-list.geochart(
[list: "US", "India","Pakistan", "Philippines", "Nigeria"],
[list: 251388301, 125344736, 110041604, 89800800, 79000000])
render-chart(an-example-geochart-series)

I get an apparent “infinite loop”, though what's really happening is one of two errors inside the chart library, either:

jsapi_compiled_geochart_module.js:81 Uncaught (in promise) Error: Must draw chart before calling getImageURI.
    at gvjs_E_.gvjs_.ah (www.gstatic.com/charts/51/js/jsapi_compiled_geochart_module.js:81:133)
    at Object.defaultImageReturn [as onExit] (js/cpo-main.jarr:243063:30)
    at onExitRetry (js/cpo-main.jarr:243025:14)
    at Object.onExit (js/cpo-main.jarr:243117:27)
    at HTMLDivElement.beforeClose (js/cpo-main.jarr:221985:18)
    at t.<computed>.<computed>._trigger (jquery-ui.min.js:6:10036)
    at t.<computed>.<computed>.close (jquery-ui.min.js:7:5830)
    at t.<computed>.<computed>.close (jquery-ui.min.js:6:5029)
    at HTMLDivElement.<anonymous> (jquery-ui.min.js:6:5995)
    at Function.each (jquery.min.js:4:5347)
    at init.each (jquery.min.js:4:1999)
    at init.t.fn.<computed> [as dialog] (jquery-ui.min.js:6:5901)
    at js/cpo-main.jarr:222071:24
    at js/cpo-main.jarr:243115:41

Or:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'Uj')
    at gvjs_rB.gvjs_.Li (www.gstatic.com/charts/51/js/jsapi_compiled_ui_module.js:182:54)
    at gvjs_rB.gvjs_.Bl (www.gstatic.com/charts/51/js/jsapi_compiled_ui_module.js:185:305)
    at gvjs_rB.gvjs_.yb (www.gstatic.com/charts/51/js/jsapi_compiled_ui_module.js:141:203)
    at gvjs_TZ (www.gstatic.com/charts/51/js/jsapi_compiled_geochart_module.js:32:406)
    at gvjs_SZ (www.gstatic.com/charts/51/js/jsapi_compiled_geochart_module.js:24:93)
    at gvjs_E_.gvjs_.ah (www.gstatic.com/charts/51/js/jsapi_compiled_geochart_module.js:81:350)
    at Object.defaultImageReturn [as onExit] (js/cpo-main.jarr:243063:30)
    at onExitRetry (js/cpo-main.jarr:243025:14)
    at Object.onExit (js/cpo-main.jarr:243117:27)
    at HTMLDivElement.beforeClose (js/cpo-main.jarr:221985:18)
    at t.<computed>.<computed>._trigger (jquery-ui.min.js:6:10036)
    at t.<computed>.<computed>.close (jquery-ui.min.js:7:5830)
    at t.<computed>.<computed>.close (jquery-ui.min.js:6:5029)
    at HTMLDivElement.<anonymous> (jquery-ui.min.js:6:5995)
    at Function.each (jquery.min.js:4:5347)
    at init.each (jquery.min.js:4:1999)
    at init.t.fn.<computed> [as dialog] (jquery-ui.min.js:6:5901)
    at js/cpo-main.jarr:222071:24
    at js/cpo-main.jarr:243115:41

Relatedly, when I run the example using .display() (as in the docs https://github.com/brownplt/pyret-docs/pull/64/files), when I close the window, it pops back up; I have to close it again, then the image renders in the REPL. This is unlike the other chart types.

@blerner and I think there may be some kind of race condition between rendering the chart and getting its image data.

Have you run into this as well/any ideas? @sorawee any insights from your experience?

jpolitz commented 2 years ago

Also, when I do get the image, it doesn't use the red color in the docs (https://github.com/brownplt/pyret-docs/pull/64/files), I get:

image

Have you seen any inconsistencies in how the images render in different browsers, etc?