| 1 |
package charts |
| 2 |
|
| 3 |
import ( |
| 4 |
"github.com/go-echarts/go-echarts/v2/datasets" |
| 5 |
"github.com/go-echarts/go-echarts/v2/opts" |
| 6 |
"github.com/go-echarts/go-echarts/v2/render" |
| 7 |
"github.com/go-echarts/go-echarts/v2/types" |
| 8 |
) |
| 9 |
|
| 10 |
|
| 11 |
type Map struct { |
| 12 |
BaseConfiguration |
| 13 |
|
| 14 |
mapType string |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
func (*Map) Type() string { return types.ChartMap } |
| 19 |
|
| 20 |
|
| 21 |
func NewMap() *Map { |
| 22 |
c := &Map{} |
| 23 |
c.initBaseConfiguration() |
| 24 |
c.Renderer = render.NewChartRender(c, c.Validate) |
| 25 |
return c |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
func (c *Map) RegisterMapType(mapType string) { |
| 30 |
c.mapType = mapType |
| 31 |
mapFile, preset := datasets.PresetMapFileNames[mapType] |
| 32 |
if preset { |
| 33 |
c.JSAssets.Add("maps/" + mapFile + ".js") |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
func (c *Map) AddSeries(name string, data []opts.MapData, options ...SeriesOpts) *Map { |
| 39 |
series := SingleSeries{Name: name, Type: types.ChartMap, MapType: c.mapType, Data: data} |
| 40 |
series.ConfigureSeriesOpts(options...) |
| 41 |
c.MultiSeries = append(c.MultiSeries, series) |
| 42 |
return c |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
func (c *Map) SetGlobalOptions(options ...GlobalOpts) *Map { |
| 47 |
c.BaseConfiguration.setBaseGlobalOptions(options...) |
| 48 |
return c |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
func (c *Map) Validate() { |
| 53 |
c.Assets.Validate(c.AssetsHost) |
| 54 |
} |