LayTec-AG / Plotly.Blazor

This library packages the well-known charting library plotly.js into a razor component that can be used in a Blazor project.
MIT License
340 stars 48 forks source link

Issue updating to 4.2.0 #415

Closed jewicht closed 2 months ago

jewicht commented 5 months ago

Hello,

I'm trying to update from 4.1.0 and 4.2.0. The only modifications was to bump Plotly.Blazor in the solution and remove the javascripts in _Layout.cshtml.

I get the following exception:

blazor.server.js:1 [2024-03-20T14:59:50.541Z] Error: Microsoft.JSInterop.JSException: Could not find 'newPlot' ('newPlot' was undefined).
Error: Could not find 'newPlot' ('newPlot' was undefined).
    at http://localhost:5123/_framework/blazor.server.js:1:734
    at Array.forEach (<anonymous>)
    at l.findFunction (http://localhost:5123/_framework/blazor.server.js:1:702)
    at _ (http://localhost:5123/_framework/blazor.server.js:1:5445)
    at http://localhost:5123/_framework/blazor.server.js:1:3238
    at new Promise (<anonymous>)
    at y.beginInvokeJSFromDotNet (http://localhost:5123/_framework/blazor.server.js:1:3201)
    at Xt._invokeClientMethod (http://localhost:5123/_framework/blazor.server.js:1:61001)
    at Xt._processIncomingData (http://localhost:5123/_framework/blazor.server.js:1:58476)
    at Xt.connection.onreceive (http://localhost:5123/_framework/blazor.server.js:1:52117)
   at Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeVoidAsync(IJSObjectReference jsObjectReference, String identifier, CancellationToken cancellationToken, Object[] args)
   at Plotly.Blazor.PlotlyJsInterop.NewPlot(CancellationToken cancellationToken)
   at Plotly.Blazor.PlotlyChart.NewPlot(CancellationToken cancellationToken)
   at Plotly.Blazor.PlotlyChart.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Any idea why this newPlot function is not found?

sean-mcl commented 5 months ago

Yeah, its the browser cache. The examples are using the previous version and overwrite the newest version everytime. Will update the examples sooner or later. You may want to use the examples using a different browser or a private window.

Use the browser dev tools (Network > Disable Cache)

jewicht commented 5 months ago

Thanks, that indeed fixes the issue.

jewicht commented 2 months ago

I'm still having the problem with 4.3.0. Clearing the browser cache does the trick but I don't want to inform all the users of my app to clear their cache. so we're still on 4.1.0. How to properly fix it?

sean-mcl commented 2 months ago

I'm still having the problem with 4.3.0. Clearing the browser cache does the trick but I don't want to inform all the users of my app to clear their cache. so we're still on 4.1.0. How to properly fix it?

Will check it out next week. I thought about a solution by appending the version number of plotly and the interop scripts to the file names, so it automatically reloads the JS without disabling the cache.

sean-mcl commented 2 months ago

Should be fixed by https://github.com/LayTec-AG/Plotly.Blazor/pull/432

jewicht commented 2 months ago

Indeed, it's fixed, thanks