Joelius300 / ChartJSBlazor

This library is a modification of the awesome ChartJs.Blazor library by mariusmuntean. It's supposed to add more functionality to the LineChart and generally make the library more complete.
Other
40 stars 6 forks source link

Indexable options (but better) #67

Closed Joelius300 closed 5 years ago

Joelius300 commented 5 years ago

This is a replacement for https://github.com/Joelius300/ChartJSBlazor/pull/63 because I was not happy with it. I don't want to merge the two branches because I'd like to keep the other solution available. They're interface-compatible (only the implementation is different, they work pretty much the same) with the exception that the new solution doesn't expose a way to return the stored value. However, it is still not immutable (!!!) because you can change the stored value if it's a reference type even after creation.

I have also asked on code-review about my implementation because I've never actually fully implemented a struct with all its equality-comparisons etc. The question is here.
Most of the (current) feedback is already applied in this PR.

Below is the content of the original PR (https://github.com/Joelius300/ChartJSBlazor/pull/63)

Fixes https://github.com/Joelius300/ChartJSBlazor/issues/45

This contains the base implementation for IndexableOption. We will need to do the other properties this applies to as well. We should do those on the fly or if requested. It might also be a good idea to create a list of places where this has to be done (new issue).
Currently I've only changed those which were set to a List<T> and only exposed a getter. This really bothered me since you were not able to not index the values and it also made creating the classes (e.g. PieDataset) a lot uglier because of the missing setter.

Both of these concerns are now fixed as you can see in the updated samples.

Side note: I implemented the newtonsoft converter since we're still depending on it anyway. I will rework this with the other converters once we are able to move away from json.net. The solution for the System.Text.Json converter is here.