Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.26k stars 526 forks source link

Update docs for Chart extension #116

Closed mihaimyh closed 5 years ago

mihaimyh commented 5 years ago

Using Blazorise.Charts Version="0.7.7" with netcore3-preview6 and a blazor-server side project, I am unable to use the example found in the documentation here https://github.com/stsrki/Blazorise/blob/master/docs/_docs/extensions/chart.md due to the following exceptions:

warn: Microsoft.AspNetCore.Components.Browser.Rendering.RemoteRenderer[100]
      Unhandled exception rendering component: Object of type 'Blazorise.Charts.LineChart`1[[System.Double, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' does not have a property matching the name 'ref'.
System.InvalidOperationException: Object of type 'Blazorise.Charts.LineChart`1[[System.Double, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' does not have a property matching the name 'ref'.
   at Microsoft.AspNetCore.Components.ParameterCollectionExtensions.ThrowForUnknownIncomingParameterName(Type targetType, String parameterName)
   at Microsoft.AspNetCore.Components.ParameterCollectionExtensions.SetParameterProperties(ParameterCollection& parameterCollection, Object target)
   at Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(ParameterCollection parameters)
   at Blazorise.Base.BaseComponent.SetParametersAsync(ParameterCollection parameters)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterCollection parameters)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.ProcessRenderQueue()
warn: Microsoft.AspNetCore.Components.Server.ComponentHub[0]
      Unhandled Server-Side exception
System.InvalidOperationException: Object of type 'Blazorise.Charts.LineChart`1[[System.Double, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' does not have a property matching the name 'ref'.
   at Microsoft.AspNetCore.Components.ParameterCollectionExtensions.ThrowForUnknownIncomingParameterName(Type targetType, String parameterName)
   at Microsoft.AspNetCore.Components.ParameterCollectionExtensions.SetParameterProperties(ParameterCollection& parameterCollection, Object target)
   at Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(ParameterCollection parameters)
   at Blazorise.Base.BaseComponent.SetParametersAsync(ParameterCollection parameters)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterCollection parameters)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.ProcessRenderQueue()

What I am doing wrong?

stsrki commented 5 years ago

Did you included css and js files in your wwwroot folder for the server-side project? See the description in the readme

Basically server-side projects still not support static files in the nuget packages so they must be copied manually.

MoriLuca commented 5 years ago

Hi guys, i had the same issue, I can not figure out what im doing wrong.

I downloaded the zip archive, extract everything in the www. ( I'm missing actually the file blazorise.sidebar.js, as it is not included int the zip).

All the resources are getting loaded from the browser, but I still get the same error as @mihaimyh .

stsrki commented 5 years ago

It seems I have not updated docs according to the latest Blazor preview6. I think the solution is to rename a ref to @ref on the Chart component. eg.

<LineChart @ref="lineChart" TItem="double" />

As for the blazorise.sidebar.js file, you can safely remove it from your source because it is not used at all.

MoriLuca commented 5 years ago

Thanks @stsrki That fixed it.

stsrki commented 5 years ago

Fixed with #143