Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For ease of adoption, it's important that chart options are obvious and functional. Having extra fields in the struct which only work under certain chart types or conditions can make it difficult to adopt our library.
Series
is a notable exception of this design pattern as it contains:In order to make the Series struct able to be flexible to match exactly the chart type, this change creates a
XxxSeries
struct for each chart type. This has the added benefit of removing theType
field, since the type is defined through the Series struct itself.Negatives:
series.go
, with many small but often mostly duplicate implementations to just handle the different typesChartOptions
is slightly worse - Since this struct is generic for all chart types the formerSeries
struct was a nice fit. We introducedGeneralSeries
which maintains the flexibility the old struct had. It needs to be constructed throughNewSeriesListGeneral
or through the former methods and then invoking.ToGeneralSeries()
in order to convert the chart specific series to the general one.Alternatives considered:
These chart configuration options could be moved from the
Series
struct into the specific Chart Option struct. This provides an easy way to discover these options (vs being multiple structs deep). It also allows us to create MarkLines and other features that don't have to be correlated to a specific series (e.g. our Global feature for MarkLine and MarkPoint's).The challenge with this is that in most cases these fields need to be correlated to a specific series. Which introduces:
If we did adopt this we could easily add an
SeriesIndex
field in subsequent structs (e.g.SeriesMarkLine
), but this would require this additional field to be manually set.We could alternatively use a map with the key being the series index, this would force a clear choice but will require the Options struct map's to be initialized.
Overall I want to consider this for v0.5 because I believe it produces an external API that is easier to understand and adopt for new users, with the primary burden being internal complexity. However I am opening this as second PR so I can get some specific review and consideration around this very significant API change.