Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat: basic sunburst chart * chore: add commnet and small tweak * chore: use `BaseConfiguration` for sunburst
- Loading branch information
Showing
6 changed files
with
156 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package charts | ||
|
||
import ( | ||
"github.com/go-echarts/go-echarts/v2/opts" | ||
"github.com/go-echarts/go-echarts/v2/render" | ||
"github.com/go-echarts/go-echarts/v2/types" | ||
) | ||
|
||
// Sunburst represents a sunburst chart. | ||
type Sunburst struct { | ||
BaseConfiguration | ||
} | ||
|
||
// Type returns the chart type. | ||
func (Sunburst) Type() string { return types.ChartSunburst } | ||
|
||
// NewSunburst creates a new sunburst chart instance. | ||
func NewSunburst() *Sunburst { | ||
c := &Sunburst{} | ||
c.initBaseConfiguration() | ||
c.Renderer = render.NewChartRender(c, c.Validate) | ||
return c | ||
} | ||
|
||
// AddSeries adds new data sets. | ||
func (c *Sunburst) AddSeries(name string, data []opts.SunBurstData, options ...SeriesOpts) *Sunburst { | ||
series := SingleSeries{Name: name, Type: types.ChartSunburst, Data: data} | ||
series.configureSeriesOpts(options...) | ||
c.MultiSeries = append(c.MultiSeries, series) | ||
return c | ||
} | ||
|
||
// SetGlobalOptions sets options for the Pie instance. | ||
func (c *Sunburst) SetGlobalOptions(options ...GlobalOpts) *Sunburst { | ||
c.BaseConfiguration.setBaseGlobalOptions(options...) | ||
return c | ||
} | ||
|
||
// Validate validates the given configuration. | ||
func (c *Sunburst) Validate() { | ||
c.Assets.Validate(c.AssetsHost) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters