blazorbootstrap icon indicating copy to clipboard operation
blazorbootstrap copied to clipboard

ChartDataset.Data generics

Open mhspelt opened this issue 1 year ago • 2 comments

In the latest version, the base ChartDataset.Data field was changed to object, then derived classes declared it as new List<double?>?. I understand this change was made to support the ScatterChart, but it was giving me problems with inheritance, so I changed it to use generics and avoid the shadowing.

mhspelt avatar Aug 07 '24 15:08 mhspelt

@mhspelt Thank you for the PR. Can you share at least one scenario for an inheritance issue, just for my understanding?

gvreddy04 avatar Aug 10 '24 10:08 gvreddy04

@mhspelt Thank you for the PR. Can you share at least one scenario for an inheritance issue, just for my understanding?

Hi @gvreddy04, here's a very simple example of a code snippet that shows two problems: https://dotnetfiddle.net/1tO4pg

  • Hiding requires casting the ChartDataset to access the data at all
  • Casting the ChartDataset edits the wrong field

Both of these behaviors are, to me as a client of the library, unexpected and are IMHO elegantly fixed by this PR.

[edit]I wrote "dumps 0" in the example, should have been "dumps null"[/edit]

mhspelt avatar Aug 13 '24 06:08 mhspelt