ant-design-blazor / ant-design-charts-blazor

A Blazor chart library, based on G2Plot
https://ant-design-blazor.github.io/ant-design-charts-blazor/
Apache License 2.0
178 stars 40 forks source link

Donut Chart - Statistic Broken #104

Open patrykgz opened 3 years ago

patrykgz commented 3 years ago

Describe the bug

The DonutConfig Statistic variable is broken due to OneOf.

Steps to reproduce (please include code)

Go to https://antblazor.com/en-US/charts/pie Scroll down to Donut Click Example 2 or 3

Exceptions (if any)

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Cannot return as T1 as result is T0 System.InvalidOperationException: Cannot return as T1 as result is T0 at OneOf.OneOf2[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AntDesign.Charts.DonutStatisticContent, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_AsT1() at System.Text.Json.JsonPropertyInfo1[[AntDesign.Charts.DonutStatisticContent, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1[[OneOf.OneOf2[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AntDesign.Charts.DonutStatisticContent, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], OneOf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnTryWrite(Utf8JsonWriter writer, OneOf2 value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter1[[OneOf.OneOf2[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AntDesign.Charts.DonutStatisticContent, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], OneOf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].TryWrite(Utf8JsonWriter writer, OneOf2& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.JsonPropertyInfo1[[OneOf.OneOf2[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AntDesign.Charts.DonutStatisticContent, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], OneOf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1[[AntDesign.Charts.DonutViewConfigStatistic, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnTryWrite(Utf8JsonWriter writer, DonutViewConfigStatistic value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter1[[AntDesign.Charts.DonutViewConfigStatistic, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].TryWrite(Utf8JsonWriter writer, DonutViewConfigStatistic& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.JsonPropertyInfo1[[AntDesign.Charts.DonutViewConfigStatistic, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1[[AntDesign.Charts.DonutConfig, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnTryWrite(Utf8JsonWriter writer, DonutConfig value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter1[[AntDesign.Charts.DonutConfig, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].TryWrite(Utf8JsonWriter writer, DonutConfig& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter1[[AntDesign.Charts.DonutConfig, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].TryWriteAsObject(Utf8JsonWriter writer, Object value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter1[[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryWrite(Utf8JsonWriter writer, Object& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.Converters.ArrayConverter2[[System.Object[], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnWriteResume(Utf8JsonWriter writer, Object[] value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.Converters.IEnumerableDefaultConverter2[[System.Object[], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnTryWrite(Utf8JsonWriter writer, Object[] value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter1[[System.Object[], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryWrite(Utf8JsonWriter writer, Object[]& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter1[[System.Object[], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].WriteCore(Utf8JsonWriter writer, Object[]& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.JsonSerializer.WriteCore[Object[]](JsonConverter jsonConverter, Utf8JsonWriter writer, Object[]& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.JsonSerializer.WriteCore[Object[]](Utf8JsonWriter writer, Object[]& value, Type inputType, JsonSerializerOptions options) at System.Text.Json.JsonSerializer.Serialize[Object[]](Object[]& value, Type inputType, JsonSerializerOptions options) at System.Text.Json.JsonSerializer.Serialize[Object[]](Object[] value, JsonSerializerOptions options) at Microsoft.JSInterop.JSRuntime.InvokeAsync[Object](Int64 targetInstanceId, String identifier, CancellationToken cancellationToken, Object[] args) at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__151[[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args) at AntDesign.Charts.ChartComponentBase2.<Create>d__46[[System.Collections.Generic.IEnumerable1[[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AntDesign.Charts.DonutConfig, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at AntDesign.Charts.ChartComponentBase2.<OnAfterRenderAsync>d__43[[System.Collections.Generic.IEnumerable1[[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AntDesign.Charts.DonutConfig, AntDesign.Charts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()

Further technical details

patrykgz commented 3 years ago

Is it possible JsonSeralizer doesn't understand One of?

patrykgz commented 3 years ago

Any updates on this issue? Modifying G2Plot.js is not an ideal solution