Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/tree: add tree chart type (#159)
* feat/tree: add tree chart type * fix/struct: fix json tags * feat/tree-leaves: add leaves option * feat/label-position: add option to specify label distance from screen border * feat/tree-collapsed-chield: add option to collapse a chield * Update charts.go * update(type): update Tree name. * update: refactor char type. * update: change to BaseConfiguration. Co-authored-by: Koy <koy@ko8e24.top>
- Loading branch information
1 parent
012bf0e
commit 7a2a78b
Showing
5 changed files
with
139 additions
and
0 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,35 @@ | ||
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" | ||
) | ||
|
||
// Tree represents a Tree chart. | ||
type Tree struct { | ||
BaseConfiguration | ||
} | ||
|
||
// Type returns the chart type. | ||
func (Tree) Type() string { return types.ChartTree } | ||
|
||
// NewTree creates a new Tree chart instance. | ||
func NewTree() *Tree { | ||
c := &Tree{} | ||
c.initBaseConfiguration() | ||
c.Renderer = render.NewChartRender(c, c.Validate) | ||
return c | ||
} | ||
|
||
func (c *Tree) AddSeries(name string, data []opts.TreeData, options ...SeriesOpts) *Tree { | ||
series := SingleSeries{Name: name, Type: types.ChartTree, Data: data} | ||
series.configureSeriesOpts(options...) | ||
c.MultiSeries = append(c.MultiSeries, series) | ||
return c | ||
} | ||
|
||
// Validate validates the given configuration. | ||
func (c *Tree) 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