charts

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2021 License: MIT Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChartType = struct {
	Bar, Bar3D, BoxPlot,
	Cartesian3D,
	EffectScatter,
	Funnel,
	Gauge, Geo, Graph,
	HeatMap,
	Kline,
	Line, Line3D, Liquid,
	Map,
	Parallel, Pie,
	Radar,
	Sankey, Scatter, Scatter3D, Surface3D,
	ThemeRiver,
	WordCloud string
}{
	Bar:           "bar",
	Bar3D:         "bar3D",
	BoxPlot:       "boxplot",
	Cartesian3D:   "cartesian3D",
	EffectScatter: "effectScatter",
	Funnel:        "funnel",
	Gauge:         "gauge",
	Geo:           "geo",
	Graph:         "graph",
	HeatMap:       "heatmap",
	Kline:         "candlestick",
	Line:          "line",
	Line3D:        "line3D",
	Liquid:        "liquidFill",
	Map:           "map",
	Parallel:      "parallel",
	Pie:           "pie",
	Radar:         "radar",
	Sankey:        "sankey",
	Scatter:       "scatter",
	Scatter3D:     "scatter3D",
	Surface3D:     "surface",
	ThemeRiver:    "themeRiver",
	WordCloud:     "wordCloud",
}

ChartType contains string representations of chart types. TODO: should use enum.

View Source
var ThemeType = struct {
	Chalk,
	Essos,
	Infographic,
	Macarons,
	PurplePassion, Roma,
	Romantic,
	Shine,
	Vintage,
	Walden, Westeros, Wonderland string
}{
	Chalk:         "chalk",
	Essos:         "essos",
	Infographic:   "infographic",
	Macarons:      "macarons",
	PurplePassion: "purple-passion",
	Roma:          "roma",
	Romantic:      "romantic",
	Shine:         "shine",
	Vintage:       "vintage",
	Walden:        "walden",
	Westeros:      "westeros",
	Wonderland:    "wonderland",
}

ThemeType contains string representations of them types. TODO: should use enum.

Functions

func FuncOpts

func FuncOpts(fn string) string

FuncOpts is the option set for handling function type.

Types

type AreaStyleOpts

type AreaStyleOpts struct {
	// 填充区域的颜色
	Color string `json:"color,omitempty"`
	// 填充区域的透明度。支持从 0 到 1 的数字,为 0 时不填充区域
	Opacity float32 `json:"opacity,omitempty"`
}

AreaStyleOpts is the option set for an area style component.

type AssetsOpts

type AssetsOpts struct {
	JSAssets, CSSAssets datatypes.OrderedSet
}

AssetsOpts contains options for static assets.

type Bar

type Bar struct {
	RectChart
	BarOpts
	// contains filtered or unexported fields
}

Bar represents a bar chart.

func NewBar

func NewBar(routers ...RouterOpts) *Bar

NewBar creates a new bar chart.

func (*Bar) AddXAxis

func (c *Bar) AddXAxis(xAxis interface{}) *Bar

AddXAxis adds the X axis.

func (*Bar) AddYAxis

func (c *Bar) AddYAxis(name string, yAxis interface{}, options ...seriesOptser) *Bar

AddYAxis adds the Y axis.

func (*Bar) Render

func (c *Bar) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Bar) XYReversal

func (c *Bar) XYReversal() *Bar

XYReversal checks if X axis and Y axis are reversed.

type Bar3D

type Bar3D struct {
	Chart3D
}

Bar3D represents a 3D bar chart.

func NewBar3D

func NewBar3D(routers ...RouterOpts) *Bar3D

NewBar3D creates a new 3D bar chart.

func (*Bar3D) AddXYAxis

func (c *Bar3D) AddXYAxis(xAxis, yAxis interface{}) *Bar3D

AddXYAxis adds both the X axis and the Y axis.

func (*Bar3D) AddZAxis

func (c *Bar3D) AddZAxis(name string, zAxis interface{}, options ...seriesOptser) *Bar3D

AddZAxis adds the Z axis.

type Bar3DOpts

type Bar3DOpts struct {
	Shading string
}

Bar3DOpts is the option set for a 3D bar chart.

type BarOpts

type BarOpts struct {
	// 数据堆叠,同个类目轴上系列配置相同的 stack 值可以堆叠放置
	Stack string
	// 不同系列的柱间距离,为百分比(如 "30%",表示柱子宽度的 30%)。
	// 如果想要两个系列的柱子重叠,可以设置 barGap 为 "-100%"。这在用柱子做背景的时候有用。
	// 在同一坐标系上,此属性会被多个 "bar" 系列共享。
	// 此属性应设置于此坐标系中最后一个 "bar" 系列上才会生效,并且是对此坐标系中所有 "bar" 系列生效
	// 默认 "30%"
	BarGap string
	// 同一系列的柱间距离,默认为类目间距的 20%,可设固定值
	// 在同一坐标系上,此属性会被多个 "bar" 系列共享。
	// 此属性应设置于此坐标系中最后一个 "bar" 系列上才会生效,并且是对此坐标系中所有 "bar" 系列生效
	BarCategoryGap string
	// 使用的 x 轴的 index,在单个图表实例中存在多个 x 轴的时候有用
	XAxisIndex int
	// 使用的 y 轴的 index,在单个图表实例中存在多个 y 轴的时候有用
	YAxisIndex int
}

BarOpts is the option set for a bar chart.

type BaseOpts

type BaseOpts struct {
	InitOpts   // 图形初始化配置项
	LegendOpts // 图例组件配置项

	TooltipOpts          // 提示框组件配置项
	ToolboxOpts          // 工具箱组件配置项
	TitleOpts            // 标题组件配置项
	AssetsOpts           // 静态资源配置项
	Colors      []string // 全局颜色列表

	Routers               // 路由列表
	DataZoomOptsList      // 区域缩放组件配置项列表
	VisualMapOptsList     // 视觉映射组件配置项列表
	RadarComponentOpts    // 雷达图组件配置项
	ParallelComponentOpts // 平行坐标系组件配置项
	ParallelAxisOpts      // 平行坐标系中的坐标轴组件配置项
	JSFunctions           // JS 函数列表
	SingleAxisOpts        // 单轴组件

	HasXYAxis     bool // 图形是否拥有 XY 轴
	Has3DAxis     bool // 图形是否拥有 3D XYZ 轴
	HasGeo        bool // 图形是否拥有 Geo 组件
	HasRadar      bool // 图形是否拥有 Radar 组件
	HasParallel   bool // 图形是否拥有 Parallel 组件
	HasSingleAxis bool // 图形是否拥有 singleAxis 组件
	// contains filtered or unexported fields
}

BaseOpts represents a option set needed by all chart types.

type BoxPlot

type BoxPlot struct {
	RectChart
}

BoxPlot represents a boxplot chart.

func NewBoxPlot

func NewBoxPlot(routers ...RouterOpts) *BoxPlot

NewBoxPlot creates a new boxplot chart.

func (*BoxPlot) AddXAxis

func (c *BoxPlot) AddXAxis(xAxis interface{}) *BoxPlot

AddXAxis adds the X axis.

func (*BoxPlot) AddYAxis

func (c *BoxPlot) AddYAxis(name string, yAxis interface{}, options ...seriesOptser) *BoxPlot

AddYAxis adds the Y axis.

type Chart3D

type Chart3D struct {
	BaseOpts
	Series

	XAxis3D XAxis3DOpts
	YAxis3D YAxis3DOpts
	ZAxis3D ZAxis3DOpts
	Grid3D  Grid3DOpts
	// contains filtered or unexported fields
}

Chart3D is a chart in 3D coordinate.

func (*Chart3D) Render

func (c *Chart3D) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Chart3D) SetGlobalOptions

func (c *Chart3D) SetGlobalOptions(options ...globalOptser) *Chart3D

SetGlobalOptions sets options for the Chart3D instance.

type ColorOpts

type ColorOpts []string

ColorOpts contains options for color schemes.

type DataZoomOpts

type DataZoomOpts struct {
	// 缩放类型,可选 "inside", "slider"
	Type string `json:"type" default:"inside"`
	// 数据窗口范围的起始百分比。范围是:0 ~ 100。表示 0% ~ 100%。
	// 默认: 0
	Start float32 `json:"start,omitempty"`
	// 数据窗口范围的结束百分比。范围是:0 ~ 100。
	// 默认: 100
	End float32 `json:"end,omitempty"`
	// 触发视图刷新的频率。单位为毫秒(ms)。
	// 默认: 100
	Throttle float32 `json:"throttle,omitempty"`
	// 设置 dataZoom 组件控制的 X 轴
	// 不指定时,当 dataZoom-inside.orient 为 'horizontal'时,默认控制和 dataZoom 平行的第一个 xAxis。
	// 但是不建议使用默认值,建议显式指定。
	// 如果是 number 表示控制一个轴,如果是 Array 表示控制多个轴。
	XAxisIndex interface{} `json:"xAxisIndex,omitempty"`
	// 设置 dataZoom 组件控制的 Y 轴
	// 不指定时,当 dataZoom-slider.orient 为 'vertical'时,默认控制和 dataZoom 平行的第一个 yAxis。
	// 但是不建议使用默认值,建议显式指定。
	// 如果是 number 表示控制一个轴,如果是 Array 表示控制多个轴。
	YAxisIndex interface{} `json:"yAxisIndex,omitempty"`
}

DataZoomOpts is the option set for a zoom component.

type DataZoomOptsList

type DataZoomOptsList []DataZoomOpts

DataZoomOptsList is a list of DataZoomOpts.

func (DataZoomOptsList) Len

func (dz DataZoomOptsList) Len() int

Len returns count of DataZoomOpts in array.

type EffectScatter

type EffectScatter struct {
	RectChart
}

EffectScatter represents an effect scatter chart.

func NewEffectScatter

func NewEffectScatter(routers ...RouterOpts) *EffectScatter

NewEffectScatter creates a new effect scatter chart.

func (*EffectScatter) AddXAxis

func (c *EffectScatter) AddXAxis(xAxis interface{}) *EffectScatter

AddXAxis adds the X axis.

func (*EffectScatter) AddYAxis

func (c *EffectScatter) AddYAxis(name string, yAxis interface{}, options ...seriesOptser) *EffectScatter

AddYAxis adds the Y axis.

type EffectScatterChartOpts

type EffectScatterChartOpts struct {
	XAxisIndex int
	YAxisIndex int
}

EffectScatterChartOpts is the option set for an effect scatter chart.

type EmphasisOpts

type EmphasisOpts struct {
	// 高亮的标签样式
	Label LabelTextOpts `json:"label,omitempty"`
	// 高亮的图形样式
	ItemStyle ItemStyleOpts `json:"itemStyle,omitempty"`
}

EmphasisOpts contains options for an emphasis.

type Funnel

type Funnel struct {
	BaseOpts
	Series
}

Funnel represents a funnel chart.

func NewFunnel

func NewFunnel(routers ...RouterOpts) *Funnel

NewFunnel creates a new funnel chart.

func (*Funnel) Add

func (c *Funnel) Add(name string, data map[string]interface{}, options ...seriesOptser) *Funnel

Add adds new data sets.

func (*Funnel) Render

func (c *Funnel) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Funnel) SetGlobalOptions

func (c *Funnel) SetGlobalOptions(options ...globalOptser) *Funnel

SetGlobalOptions sets options for the Funnel instance.

type Gauge

type Gauge struct {
	BaseOpts
	Series
}

Gauge represents a gauge chart.

func NewGauge

func NewGauge(routers ...RouterOpts) *Gauge

NewGauge creates a new gauge chart.

func (*Gauge) Add

func (c *Gauge) Add(name string, data map[string]interface{}, options ...seriesOptser) *Gauge

Add adds new data sets.

func (*Gauge) Render

func (c *Gauge) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Gauge) SetGlobalOptions

func (c *Gauge) SetGlobalOptions(options ...globalOptser) *Gauge

SetGlobalOptions sets options for the Gauge instance.

type Geo

type Geo struct {
	BaseOpts
	Series
	GeoComponentOpts
}

Geo represents a geo chart.

func NewGeo

func NewGeo(mapType string, routers ...RouterOpts) *Geo

NewGeo creates a new geo chart.

func (*Geo) Add

func (c *Geo) Add(name, geoType string, data map[string]float32, options ...seriesOptser) *Geo

Add adds new data sets. geoType 是 Geo 图形的种类,有以下三种类型可选 common.ChartType.Scatter common.ChartType.EffectScatter common.ChartType.HeatMap

func (*Geo) Render

func (c *Geo) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Geo) SetGlobalOptions

func (c *Geo) SetGlobalOptions(options ...globalOptser) *Geo

SetGlobalOptions sets options for the Geo instance.

type GeoComponentOpts

type GeoComponentOpts struct {
	Map string `json:"map,omitempty"`
}

GeoComponentOpts is the option set for geo component.

type Graph

type Graph struct {
	BaseOpts
	Series
}

Graph represents a graph chart.

func NewGraph

func NewGraph(routers ...RouterOpts) *Graph

NewGraph creates a new graph chart.

func (*Graph) Add

func (c *Graph) Add(name string, nodes []GraphNode, links []GraphLink, options ...seriesOptser) *Graph

Add adds new data sets.

func (*Graph) Render

func (c *Graph) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Graph) SetGlobalOptions

func (c *Graph) SetGlobalOptions(options ...globalOptser) *Graph

SetGlobalOptions sets options for the Graph instance.

type GraphCategory

type GraphCategory struct {
	// 类目名称,用于和 legend 对应以及格式化 tooltip 的内容
	Name string `json:"name"`
	// 该类目节点标签的样式
	Label LabelTextOpts `json:"label"`
}

GraphCategory represents a category for data nodes.

type GraphForce

type GraphForce struct {
	// 进行力引导布局前的初始化布局,初始化布局会影响到力引导的效果
	//InitLayout string `json:"initLayout,omitempty"`
	// 节点之间的斥力因子。
	// 支持设置成数组表达斥力的范围,此时不同大小的值会线性映射到不同的斥力。
	// 值越大则斥力越大。默认为 50
	Repulsion float32 `json:"repulsion,omitempty"`
	// 节点受到的向中心的引力因子。该值越大节点越往中心点靠拢
	// 默认为 0.1
	Gravity float32 `json:"gravity,omitempty"`
	// 边的两个节点之间的距离,这个距离也会受 Repulsion 影响。
	// 支持设置成数组表达边长的范围,此时不同大小的值会线性映射到不同的长度。值越小则长度越长。
	// 如下示例:值最大的边长度会趋向于 10,值最小的边长度会趋向于 50
	// edgeLength: [10, 50]
	EdgeLength float32 `json:"edgeLength,omitempty"`
}

GraphForce is the option set for graph force layout.

type GraphLink struct {
	// 边的源节点名称的字符串,也支持使用数字表示源节点的索引
	Source interface{} `json:"source,omitempty"`
	// 边的目标节点名称的字符串,也支持使用数字表示源节点的索引
	Target interface{} `json:"target,omitempty"`
	// 边的数值,可以在力引导布局中用于映射到边的长度
	Value float32 `json:"value,omitempty"`
}

GraphLink represents relationship between two data nodes.

type GraphNode

type GraphNode struct {
	// 数据项名称
	Name string `json:"name,omitempty"`
	// 节点的初始 x 值。在布局为 "none" 时生效
	X float32 `json:"x,omitempty"`
	// 节点的初始 y 值。在布局为 "none" 时生效
	Y float32 `json:"y,omitempty"`
	// 数据项值
	Value float32 `json:"value,omitempty"`
	// 节点在力引导布局中是否固定
	Fixed bool `json:"fixed,omitempty"`
	// 数据项所在类目的 index
	Category int `json:"category,omitempty"`
	// 该类目节点标记的图形,可选
	// 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none'
	Symbol string `json:"symbol,omitempty"`
	// 该类目节点标记的大小,可以设置成诸如 10 这样单一的数字,
	// 也可以用数组分开表示宽和高,例如 [20, 10] 表示标记宽为20,高为10
	SymbolSize interface{} `json:"symbolSize,omitempty"`
	// 该节点的样式
	ItemStyle ItemStyleOpts `json:"itemStyle,omitempty"`
}

GraphNode represents a data node in graph chart.

type GraphOpts

type GraphOpts struct {
	//图的布局。可选:
	// "none" 不采用任何布局,使用节点中提供的 x, y 作为节点的位置。
	// "circular" 采用环形布局
	// "force" 采用力引导布局
	Layout string
	// "force", "circular" 布局详细配置项
	Force GraphForce
	// 是否开启鼠标缩放和平移漫游。默认不开启。
	Roam bool
	// 是否在鼠标移到节点上的时候突出显示节点以及节点的边和邻接节点
	FocusNodeAdjacency bool
	//
	Categories []GraphCategory
}

GraphOpts is the option set for graph chart.

type Grid3DOpts

type Grid3DOpts struct {
	// 是否显示三维笛卡尔坐标系
	Show bool `json:"show,omitempty"`
	// 三维笛卡尔坐标系组件在三维场景中的宽度
	// 默认 100
	BoxWidth float32 `json:"boxWidth,omitempty"`
	// 三维笛卡尔坐标系组件在三维场景中的高度
	// 默认 100
	BoxHeight float32 `json:"boxHeight,omitempty"`
	// 三维笛卡尔坐标系组件在三维场景中的深度
	// 默认 100
	BoxDepth float32 `json:"boxDepth,omitempty"`
	// 用于鼠标的旋转,缩放等视角控制
	ViewControl ViewControlOpts `json:"viewControl,omitempty"`
}

Grid3DOpts contains options for the 3D coordinate.

type HeatMap

type HeatMap struct {
	RectChart
}

HeatMap represents a heatmap chart.

func NewHeatMap

func NewHeatMap(routers ...RouterOpts) *HeatMap

NewHeatMap creates a new heatmap chart.

func (*HeatMap) AddXAxis

func (c *HeatMap) AddXAxis(xAxis interface{}) *HeatMap

AddXAxis adds the X axis.

func (*HeatMap) AddYAxis

func (c *HeatMap) AddYAxis(name string, yAxis interface{}, options ...seriesOptser) *HeatMap

AddYAxis adds the Y axis.

type HeatMapOpts

type HeatMapOpts struct {
	//使用的 x 轴的 index,在单个图表实例中存在多个 x 轴的时候有用
	XAxisIndex int
	//使用的 y 轴的 index,在单个图表实例中存在多个 y 轴的时候有用
	YAxisIndex int
}

HeatMapOpts is the option set for a heatmap chart.

type IndicatorOpts

type IndicatorOpts struct {
	// 指示器名称
	Name string `json:"name,omitempty"`
	// 指示器的最大值,可选,建议设置
	Max float32 `json:"max,omitempty"`
	// 指示器的最小值,可选,默认为 0
	Min float32 `json:"min,omitempty"`
	// 标签特定的颜色
	Color string `json:"color,omitempty"`
}

IndicatorOpts is the option set for a radar chart.

type InitOpts

type InitOpts struct {
	// 生成的 HTML 页面标题
	PageTitle string `default:"MLModelScope charts"`
	// 画布宽度
	Width string `default:"900px"`
	// 画布高度
	Height string `default:"500px"`
	// 画布背景颜色
	BackgroundColor string `json:"backgroundColor,omitempty"`
	// 图表 ID,是图表唯一标识
	ChartID string
	// 静态资源 host 地址
	AssetsHost string `default:"http://chenjiandongx.com/go-echarts-assets/assets/"`
	// 图表主题
	Theme string `default:"white"`
}

InitOpts contains options for the canvas.

type ItemStyleOpts

type ItemStyleOpts struct {
	// 图形的颜色
	// Kline 图中为 阳线图形颜色
	Color string `json:"color,omitempty"`
	// Kline 图中为 阴线图形颜色
	Color0 string `json:"color0,omitempty"`
	// 图形的描边颜色
	// Kline 途中为 阳线图形的描边颜色
	BorderColor string `json:"borderColor,omitempty"`
	// Kline 途中为 阴线图形的描边颜色
	BorderColor0 string `json:"borderColor0,omitempty"`
	// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形
	Opacity float32 `json:"opacity,omitempty"`
}

ItemStyleOpts contains styling options for a MarkLine.

type JSFunctions

type JSFunctions struct {
	Fns []string
}

JSFunctions contains a set of JS functions.

func (*JSFunctions) AddJSFuncs

func (f *JSFunctions) AddJSFuncs(fn ...string)

AddJSFuncs adds a new JS function.

type Kline

type Kline struct {
	RectChart
}

Kline represents a kline chart.

func NewKLine

func NewKLine(routers ...RouterOpts) *Kline

NewKLine creates a new kline chart.

func (*Kline) AddXAxis

func (c *Kline) AddXAxis(xAxis interface{}) *Kline

AddXAxis adds the X axis.

func (*Kline) AddYAxis

func (c *Kline) AddYAxis(name string, yAxis interface{}, options ...seriesOptser) *Kline

AddYAxis adds the Y axis.

type LabelTextOpts

type LabelTextOpts struct {
	// 是否显示标签
	Show   bool `json:"show"`
	Rotate int  `json:"rotate,omitempty"`
	// 文字的颜色
	Color string `json:"color,omitempty"`
	// 标签的位置
	// 通过相对的百分比或者绝对像素值表示标签相对于图形包围盒左上角的位置。示例:
	// 绝对的像素值	position: [10, 10],
	// 相对的百分比	position: ["50%", "50%"]
	// "top", "left", "right", "bottom"
	// "inside", "insideLeft", "insideRight", "insideTop", "insideBottom"
	// "insideTopLeft", "insideBottomLeft", "insideTopRight", "insideBottomRight"
	Position string `json:"position,omitempty"`
	// 标签内容格式器,支持字符串模板和回调函数两种形式,字符串模板与回调函数返回的字符串均支持用 \n 换行。
	// 1. 字符串模板 模板变量有:
	// {a}:系列名。
	// {b}:数据名。
	// {c}:数据值。
	// {@xxx}:数据中名为'xxx'的维度的值,如{@product}表示名为'product'`的维度的值。
	// {@[n]}:数据中维度 n 的值,如{@[3]}` 表示维度 3 的值,从 0 开始计数。
	// 2, 回调函数
	// 回调函数格式:
	// (params: Object|Array, ticket: string, callback: (ticket: string, html: string)) => string
	// 第一个参数 params 是 formatter 需要的数据集。格式如下:
	// {
	//    componentType: 'series',
	//    seriesType: string,	// 系列类型
	//    seriesIndex: number,	// 系列在传入的 option.series 中的 index
	//    seriesName: string,	// 系列名称
	//    name: string,			// 数据名,类目名
	//    dataIndex: number,	// 数据在传入的 data 数组中的 index
	//    data: Object,			// 传入的原始数据项
	//    value: number|Array,	// 传入的数据值
	//    color: string,		// 数据图形的颜色
	//    percent: number,		// 饼图的百分比
	// }
	Formatter string `json:"formatter,omitempty"`
}

LabelTextOpts contains options for a label text.

type LegendOpts

type LegendOpts struct {
	// 图例组件离容器左侧的距离。
	// left 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比
	// 也可以是 'left', 'center', 'right'。
	// 如果 left 的值为'left', 'center', 'right',组件会根据相应的位置自动对齐。
	Left string `json:"left,omitempty"`
	// 图例组件离容器上侧的距离。
	// top 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比
	// 也可以是 'top', 'middle', 'bottom'。
	// 如果 top 的值为'top', 'middle', 'bottom',组件会根据相应的位置自动对齐。
	Top string `json:"top,omitempty"`
	// 图例组件离容器右侧的距离。
	// right 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比。
	// 默认自适应。
	Right string `json:"right,omitempty"`
	// 图例组件离容器下侧的距离。
	// bottom 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比。
	// 默认自适应。
	Bottom string `json:"bottom,omitempty"`
	// Legend 数据项
	// 如果需要隐藏 Legend 则把 Data 设置为 []string{}
	Data interface{} `json:"data,omitempty"`
	// 除此之外也可以设成 "single" 或者 "multiple" 使用单选或者多选模式。默认 "multiple"
	SelectedMode string `json:"selectedMode,omitempty"`
	// 图例的公用文本样式
	TextStyle TextStyleOpts `json:"textStyle,omitempty"`
}

LegendOpts is the option set for a legend component.

type Line

type Line struct {
	RectChart
}

Line represents a line chart.

func NewLine

func NewLine(routers ...RouterOpts) *Line

NewLine creates a new line chart.

func (*Line) AddXAxis

func (c *Line) AddXAxis(xAxis interface{}) *Line

AddXAxis adds the X axis.

func (*Line) AddYAxis

func (c *Line) AddYAxis(name string, yAxis interface{}, options ...seriesOptser) *Line

AddYAxis adds the Y axis.

type Line3D

type Line3D struct {
	Chart3D
}

Line3D represents a 3D line chart.

func NewLine3D

func NewLine3D(routers ...RouterOpts) *Line3D

NewLine3D creates a new 3D line chart.

func (*Line3D) AddXYAxis

func (c *Line3D) AddXYAxis(xAxis, yAxis interface{}) *Line3D

AddXYAxis adds both the X axis and the Y axis.

func (*Line3D) AddZAxis

func (c *Line3D) AddZAxis(name string, zAxis interface{}, options ...seriesOptser) *Line3D

AddZAxis adds the Z axis.

type LineOpts

type LineOpts struct {
	// 数据堆叠,同个类目轴上系列配置相同的 stack 值可以堆叠放置
	Stack string
	// 曲线是否平滑
	Smooth bool
	// 是否使用阶梯图
	Step bool
	// 使用的 x 轴的 index,在单个图表实例中存在多个 x 轴的时候有用
	XAxisIndex int
	// 使用的 y 轴的 index,在单个图表实例中存在多个 y 轴的时候有用
	YAxisIndex int
}

LineOpts is the options set for a line chart.

type LineStyleOpts

type LineStyleOpts struct {
	// 线的颜色
	Color string `json:"color,omitempty"`
	// 线的宽度
	// 默认 1
	Width float32 `json:"width,omitempty"`
	// 线的类型,可选 "solid", "dashed", "dotted"
	// 默认 "solid"
	Type string `json:"type,omitempty"`
	// 线的透明度。支持从 0 到 1 的数字,为 0 时不绘制线
	Opacity float32 `json:"opacity,omitempty"`
	// 线的曲度,支持从 0 到 1 的值,值越大曲度越大
	// 默认 0
	Curveness float32 `json:"curveness,omitempty"`
}

LineStyleOpts is the option set for a link style component.

type Liquid

type Liquid struct {
	BaseOpts
	Series
}

Liquid represents a liquid chart.

func NewLiquid

func NewLiquid(routers ...RouterOpts) *Liquid

NewLiquid creates a new liquid chart.

func (*Liquid) Add

func (c *Liquid) Add(name string, data interface{}, options ...seriesOptser) *Liquid

Add adds new data sets.

func (*Liquid) Render

func (c *Liquid) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Liquid) SetGlobalOptions

func (c *Liquid) SetGlobalOptions(options ...globalOptser) *Liquid

SetGlobalOptions sets options for the Liquid instance.

type LiquidOpts

type LiquidOpts struct {
	// 水球图形状,可选
	// "circle", "rect", "roundRect", "triangle", "diamond", "pin", "arrow", "none"
	Shape string
	// 是否显示水球轮廓
	IsShowOutline bool
	// 是否停止动画
	IsWaveAnimation bool
}

LiquidOpts is the option set for a liquid chart.

type LiquidOutlineOpts

type LiquidOutlineOpts struct {
	Show bool `json:"show"`
}

LiquidOutlineOpts is the options set for a liquid outline.

type MLNameCoordItem

type MLNameCoordItem struct {
	// 标记线名称
	Name string
	// 标记线起始坐标
	Coord0 []interface{}
	// 标记线结束坐标
	Coord1 []interface{}
	// 在使用 type 时有效,用于指定在哪个维度上指定最大值最小值。
	// 可以是维度的直接名称,例如折线图时可以是 x、angle 等
	// candlestick 图时可以是 open、close 等维度名称。
	ValueDim string `json:"valueDim,omitempty"`
}

MLNameCoordItem represents coordinates for a MarkLine.

type MLNameTypeItem

type MLNameTypeItem struct {
	// 标记线名称
	Name string `json:"name"`
	// 内置类型,可选 "average", "min", "max"
	Type string `json:"type"`
	// 在使用 type 时有效,用于指定在哪个维度上指定最大值最小值。
	// 可以是维度的直接名称,例如折线图时可以是 x、angle 等
	// candlestick 图时可以是 open、close 等维度名称。
	ValueDim string `json:"valueDim,omitempty"`
}

MLNameTypeItem represents type for a MarkLine.

type MLNameXAxisItem

type MLNameXAxisItem struct {
	// 标记线名称
	Name string `json:"name"`
	// X 轴数据
	XAxis interface{} `json:"xAxis"`
	// 在使用 type 时有效,用于指定在哪个维度上指定最大值最小值。
	// 可以是维度的直接名称,例如折线图时可以是 x、angle 等
	// candlestick 图时可以是 open、close 等维度名称。
	ValueDim string `json:"valueDim,omitempty"`
}

MLNameXAxisItem represents X axis for a MarkLine.

type MLNameYAxisItem

type MLNameYAxisItem struct {
	// 标记线名称
	Name string `json:"name"`
	// Y 轴数据
	YAxis interface{} `json:"yAxis"`
	// 在使用 type 时有效,用于指定在哪个维度上指定最大值最小值。
	// 可以是维度的直接名称,例如折线图时可以是 x、angle 等
	// candlestick 图时可以是 open、close 等维度名称。
	ValueDim string `json:"valueDim,omitempty"`
}

MLNameYAxisItem represents Y axis for a MarkLine.

type MLStyleOpts

type MLStyleOpts struct {
	// 图元的图形类别
	// 可选 "circle", "rect", "roundRect", "triangle", "diamond", "pin", "arrow", "none"
	Symbol []string `json:"symbol,omitempty"`
	// 图元的大小
	SymbolSize float32 `json:"symbolSize,omitempty"`
	// 标线文本配置项
	Label LabelTextOpts `json:"label,omitempty"`
}

MLStyleOpts contains styling options for a MarkLine.

type MPNameCoordItem

type MPNameCoordItem struct {
	// 标记点名称
	Name string `json:"name"`
	// 标记点坐标
	Coord []interface{} `json:"coord"`
	// 在使用 type 时有效,用于指定在哪个维度上指定最大值最小值。
	// 可以是维度的直接名称,例如折线图时可以是 x、angle 等
	// candlestick 图时可以是 open、close 等维度名称。
	ValueDim string `json:"valueDim,omitempty"`
}

MPNameCoordItem represents coordinates for a MarkPoint.

type MPNameTypeItem

type MPNameTypeItem struct {
	// 标记点名称
	Name string `json:"name"`
	// 内置类型,可选 "average", "min", "max"
	Type string `json:"type"`
	// 在使用 type 时有效,用于指定在哪个维度上指定最大值最小值。
	// 可以是维度的直接名称,例如折线图时可以是 x、angle 等
	// candlestick 图时可以是 open、close 等维度名称。
	ValueDim string `json:"valueDim,omitempty"`
}

MPNameTypeItem represents type for a MarkPoint.

type MPStyleOpts

type MPStyleOpts struct {
	// 图元的图形类别
	// 可选 "circle", "rect", "roundRect", "triangle", "diamond", "pin", "arrow", "none"
	Symbol string `json:"symbol,omitempty"`
	// 图元的大小
	SymbolSize float32 `json:"symbolSize,omitempty"`
	// 标注文本配置项
	Label LabelTextOpts `json:"label,omitempty"`
}

MPStyleOpts contains styling options for a MarkPoint.

type Map

type Map struct {
	BaseOpts
	Series
	// contains filtered or unexported fields
}

Map represents a map chart.

func NewMap

func NewMap(mapType string, routers ...RouterOpts) *Map

NewMap creates a new map chart.

func (*Map) Add

func (c *Map) Add(name string, data map[string]float32, options ...seriesOptser) *Map

Add adds new data sets.

func (*Map) Render

func (c *Map) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Map) SetGlobalOptions

func (c *Map) SetGlobalOptions(options ...globalOptser) *Map

SetGlobalOptions sets options for the Map instance.

type MarkLine

type MarkLine struct {
	Data []interface{} `json:"data,omitempty"`
	MLStyleOpts
}

MarkLine represents a mark line.

type MarkPoint

type MarkPoint struct {
	Data []interface{} `json:"data,omitempty"`
	MPStyleOpts
}

MarkPoint represents a mark point.

type PAOpts

type PAOpts struct {
	// 坐标轴的维度序号
	Dim int `json:"dim,omitempty"`
	// 坐标轴名称
	Name string `json:"name,omitempty"`
	// 坐标轴刻度最大值。
	// 可以设置成特殊值 "dataMax",此时取数据在该轴上的最大值作为最大刻度。
	// 不设置时会自动计算最大值保证坐标轴刻度的均匀分布
	Max interface{} `json:"max,omitempty"`
	// 是否是反向坐标轴
	Inverse bool `json:"inverse,omitempty"`
	// 坐标轴名称显示位置,可选 "start", "middle", "center", "end"
	// 默认 "end"
	NameLocation string `json:"nameLocation,omitempty"`
	// 坐标轴类型,可选:
	// "value":数值轴,适用于连续数据。
	// "category" 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
	// "log" 对数轴。适用于对数数据。
	Type string `json:"type,omitempty"`
	// 类目数据,在类目轴(type: "category")中有效
	Data interface{} `json:"data,omitempty"`
}

PAOpts is the option set for a parallel axis.

type Page

type Page struct {
	InitOpts
	AssetsOpts
	Charts []interface{}
	Routers
	// contains filtered or unexported fields
}

Page represents a page chart.

func NewPage

func NewPage(routers ...RouterOpts) *Page

NewPage creates a new page.

func (*Page) Add

func (page *Page) Add(charts ...charter) *Page

Add adds new charts to the page.

func (*Page) Render

func (page *Page) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

type Parallel

type Parallel struct {
	BaseOpts
	Series
}

Parallel represents a parallel axis.

func NewParallel

func NewParallel(routers ...RouterOpts) *Parallel

NewParallel creates a new parallel instance.

func (*Parallel) Add

func (c *Parallel) Add(name string, data interface{}, options ...seriesOptser) *Parallel

Add adds new data sets.

func (*Parallel) Render

func (c *Parallel) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Parallel) SetGlobalOptions

func (c *Parallel) SetGlobalOptions(options ...globalOptser) *Parallel

SetGlobalOptions sets options for the Parallel instance.

type ParallelAxisOpts

type ParallelAxisOpts []PAOpts

ParallelAxisOpts is a list of ParallelAxisOpts. 平行坐标系中的坐标轴组件配置项

type ParallelComponentOpts

type ParallelComponentOpts struct {
	// parallel 组件离容器左侧的距离。
	// left 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比
	// 也可以是 'left', 'center', 'right'。
	// 如果 left 的值为'left', 'center', 'right',组件会根据相应的位置自动对齐。
	Left string `json:"left,omitempty"`
	// parallel 组件离容器上侧的距离。
	// top 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比
	// 也可以是 'top', 'middle', 'bottom'。
	// 如果 top 的值为'top', 'middle', 'bottom',组件会根据相应的位置自动对齐。
	Top string `json:"top,omitempty"`
	// parallel 组件离容器右侧的距离。
	// right 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比。
	// 默认自适应。
	Right string `json:"right,omitempty"`
	// parallel 组件离容器下侧的距离。
	// bottom 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比。
	// 默认自适应
	Bottom string `json:"bottom,omitempty"`
}

ParallelComponentOpts is the option set for parallel component.

type Pie

type Pie struct {
	BaseOpts
	Series
}

Pie represents a pie chart.

func NewPie

func NewPie(routers ...RouterOpts) *Pie

NewPie creates a new gauge chart.

func (*Pie) Add

func (c *Pie) Add(name string, data map[string]interface{}, options ...seriesOptser) *Pie

Add adds new data sets.

func (*Pie) AddSorted

func (c *Pie) AddSorted(name string, data map[string]interface{}, options ...seriesOptser) *Pie

AddSorted sorts and adds new data sets.

func (*Pie) Render

func (c *Pie) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Pie) SetGlobalOptions

func (c *Pie) SetGlobalOptions(options ...globalOptser) *Pie

SetGlobalOptions sets options for the Pie instance.

type PieOpts

type PieOpts struct {
	// 是否展示成南丁格尔图,通过半径区分数据大小。可选择两种模式:
	// 1."radius": 扇区圆心角展现数据的百分比,半径展现数据的大小。
	// 2."area": 所有扇区圆心角相同,仅通过半径展现数据大小。
	RoseType string
	// 饼图的中心(圆心)坐标,数组的第一项是横坐标,第二项是纵坐标。
	// 支持设置成百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度
	// 使用示例
	// 设置成绝对的像素值: center: [400, 300]
	// 设置成相对的百分比: center: ['50%', '50%']
	// 默认 ["50%", "50%"]
	Center interface{}
	// 饼图的半径。可以为如下类型:
	// 1.number:直接指定外半径值。
	// 2.string:例如,'20%',表示外半径为可视区尺寸(容器高宽中较小一项)的 20% 长度。
	// 3.Array.<number|string>:数组的第一项是内半径,第二项是外半径。
	// 每一项遵从上述 number string 的描述。
	// 默认 [0, "75%"]
	Radius interface{}
}

PieOpts is the option set for a pie chart.

type Radar

type Radar struct {
	BaseOpts
	Series
}

Radar represents a radar chart.

func NewRadar

func NewRadar(routers ...RouterOpts) *Radar

NewRadar creates a new radar chart.

func (*Radar) Add

func (c *Radar) Add(name string, data interface{}, options ...seriesOptser) *Radar

Add adds new data sets.

func (*Radar) Render

func (c *Radar) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Radar) SetGlobalOptions

func (c *Radar) SetGlobalOptions(options ...globalOptser) *Radar

SetGlobalOptions sets options for the Radar instance.

type RadarComponentOpts

type RadarComponentOpts struct {
	// 雷达图的指示器,用来指定雷达图中的多个变量(维度)
	Indicator []IndicatorOpts `json:"indicator,omitempty"`
	// 雷达图绘制类型,支持 "polygon" 和 "circle"
	Shape string `json:"shape,omitempty"`
	// 指示器轴的分割段数。默认 5
	SplitNumber int `json:"splitNumber,omitempty"`
	// 坐标轴在 grid 区域中的分隔区域
	SplitArea SplitAreaOpts `json:"splitArea,omitempty"`
	// 坐标轴在 grid 区域中的分隔线
	SplitLine SplitLineOpts `json:"splitLine,omitempty"`
}

RadarComponentOpts is the option set for a radar component.

type RectChart

type RectChart struct {
	RectOpts
	Series
	// contains filtered or unexported fields
}

RectChart is a chart in RectChart coordinate.

func (*RectChart) Overlap

func (rc *RectChart) Overlap(a ...rectCharter)

Overlap composites multiple charts into one single canvas. 结合不同类型图表叠加画在同张图上 只适用于 RectChart 图表,其实现了 rectCharter 接口 RectChart 图表包括 Bar/BoxPlot/Line/Scatter/EffectScatter/Kline/HeatMap 将 RectChart 图表的 Series 追加到调用者的 Series 里面,Series 是完全独立的 而全局配置使用的是调用者的配置项

func (*RectChart) Render

func (rc *RectChart) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*RectChart) SetGlobalOptions

func (rc *RectChart) SetGlobalOptions(options ...globalOptser) *RectChart

SetGlobalOptions sets options for the RectChart instance.

type RectOpts

type RectOpts struct {
	BaseOpts
	XYAxis
}

RectOpts contains options for the rectangular coordinate.

type RippleEffectOpts

type RippleEffectOpts struct {
	// 动画的周期,秒数
	// 默认 4(s)
	Period float32 `json:"period,omitempty"`
	// 动画中波纹的最大缩放比例
	// 默认 2.5
	Scale float32 `json:"scale,omitempty"`
	// 波纹的绘制方式,可选 "stroke" 和 "fill"
	// 默认 "fill"
	BrushType string `json:"brushType,omitempty"`
}

RippleEffectOpts is the option set for the ripple effect.

type RouterOpts

type RouterOpts struct {
	URL  string // 路由 URL
	Text string // 路由显示文字
}

RouterOpts contains information for routing.

type Routers

type Routers []RouterOpts

Routers is an array of RouterOpts.

func (Routers) Len

func (hr Routers) Len() int

Len returns the count of RouterOpts elements in array.

type Sankey

type Sankey struct {
	BaseOpts
	Series
}

Sankey represents a sankey chart.

func NewSankey

func NewSankey(routers ...RouterOpts) *Sankey

NewSankey creates a new sankey chart.

func (*Sankey) Add

func (c *Sankey) Add(name string, nodes []SankeyNode, links []SankeyLink, options ...seriesOptser) *Sankey

Add adds new data sets.

func (*Sankey) Render

func (c *Sankey) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*Sankey) SetGlobalOptions

func (c *Sankey) SetGlobalOptions(options ...globalOptser) *Sankey

SetGlobalOptions sets options for the Sankey instance.

type SankeyLink struct {
	// 边的源节点名称的字符串,也支持使用数字表示源节点的索引
	Source interface{} `json:"source,omitempty"`
	// 边的目标节点名称的字符串,也支持使用数字表示源节点的索引
	Target interface{} `json:"target,omitempty"`
	// 边的数值,可以在力引导布局中用于映射到边的长度
	Value float32 `json:"value,omitempty"`
}

SankeyLink represents relationship between two data nodes.

type SankeyNode

type SankeyNode struct {
	// 数据项名称
	Name string `json:"name,omitempty"`
	// 数据项值
	Value string `json:"value,omitempty"`
}

SankeyNode represents a data node.

type SaveAsImage

type SaveAsImage struct {
	PixelRatio int `json:"pixelRatio"`
}

type Scatter

type Scatter struct {
	RectChart
}

Scatter represents a scatter chart.

func NewScatter

func NewScatter(routers ...RouterOpts) *Scatter

NewScatter creates a new scatter chart.

func (*Scatter) AddXAxis

func (c *Scatter) AddXAxis(xAxis interface{}) *Scatter

AddXAxis adds the X axis.

func (*Scatter) AddYAxis

func (c *Scatter) AddYAxis(name string, yAxis interface{}, options ...seriesOptser) *Scatter

AddYAxis adds the Y axis.

type Scatter3D

type Scatter3D struct {
	Chart3D
}

Scatter3D represents a 3D scatter chart.

func NewScatter3D

func NewScatter3D(routers ...RouterOpts) *Scatter3D

NewScatter3D creates a new 3D scatter chart.

func (*Scatter3D) AddXYAxis

func (c *Scatter3D) AddXYAxis(xAxis, yAxis interface{}) *Scatter3D

AddXYAxis adds both the X axis and the Y axis.

func (*Scatter3D) AddZAxis

func (c *Scatter3D) AddZAxis(name string, zAxis interface{}, options ...seriesOptser) *Scatter3D

AddZAxis adds the Z axis.

type ScatterOpts

type ScatterOpts struct {
	// 使用的 x 轴的 index,在单个图表实例中存在多个 x 轴的时候有用
	XAxisIndex int
	// 使用的 y 轴的 index,在单个图表实例中存在多个 y 轴的时候有用
	YAxisIndex int
}

ScatterOpts is the option set for a scatter chart.

type Series

type Series []singleSeries

Series represents multiple series.

func (*Series) SetSeriesOptions

func (series *Series) SetSeriesOptions(options ...seriesOptser)

SetSeriesOptions sets options for the series.

type SingleAxisOpts

type SingleAxisOpts struct {
	// 坐标轴刻度最小值。
	// 可以设置成特殊值 "dataMin",此时取数据在该轴上的最小值作为最小刻度
	Min interface{} `json:"min,omitempty"`
	// 坐标轴刻度最大值。
	// 可以设置成特殊值 "dataMax",此时取数据在该轴上的最大值作为最大刻度
	Max interface{} `json:"max,omitempty"`
	// 坐标轴类型
	// "value" 数值轴,适用于连续数据。
	// "category" 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
	// "time" 时间轴,适用于连续的时序数据,与数值轴相比时间轴带有时间的格式化,
	// 在刻度计算上也有所不同,例如会根据跨度的范围来决定使用月,星期,日还是小时范围的刻度。
	// "log" 对数轴。适用于对数数据。
	Type string `json:"type,omitempty"`
	// single 组件离容器左侧的距离。
	// left 的值可以是像 20 这样的具体像素值,可以是像 "20%" 这样相对于容器高宽的百分比,
	// 也可以是 "left", "center", "right"。
	// 如果 left 的值为 "left", "center", "right",组件会根据相应的位置自动对齐
	Left string `json:"left,omitempty"`
	// single 组件离容器右侧的距离。
	// left 的值可以是像 20 这样的具体像素值,可以是像 "20%" 这样相对于容器高宽的百分比,
	// 也可以是 "left", "center", "right"。
	// 如果 left 的值为 "left", "center", "right",组件会根据相应的位置自动对齐
	Right string `json:"right,omitempty"`
	// single 组件离容器顶侧的距离。
	// left 的值可以是像 20 这样的具体像素值,可以是像 "20%" 这样相对于容器高宽的百分比,
	// 也可以是 "left", "center", "right"。
	// 如果 left 的值为 "left", "center", "right",组件会根据相应的位置自动对齐
	Top string `json:"top,omitempty"`
	// single 组件离容器底侧的距离。
	// left 的值可以是像 20 这样的具体像素值,可以是像 "20%" 这样相对于容器高宽的百分比,
	// 也可以是 "left", "center", "right"。
	// 如果 left 的值为 "left", "center", "right",组件会根据相应的位置自动对齐
	Bottom string `json:"bottom,omitempty"`
}

SingleAxisOpts is the option set for single axis.

type SplitAreaOpts

type SplitAreaOpts struct {
	// 是否显示分隔区域
	Show bool `json:"show"`
	// 风格区域风格
	AreaStyle AreaStyleOpts `json:"areaStyle,omitempty"`
}

SplitAreaOpts is the option set for a split area.

type SplitLineOpts

type SplitLineOpts struct {
	// 是否显示分隔线
	Show bool `json:"show"`
	// 分割线风格
	LineStyle LineStyleOpts `json:"lineStyle,omitempty"`
}

SplitLineOpts is the option set for a split line.

type Surface3D

type Surface3D struct {
	Chart3D
}

Surface3D represents a 3D surface chart.

func NewSurface3D

func NewSurface3D(routers ...RouterOpts) *Surface3D

NewSurface3D creates a new 3d surface chart.

func (*Surface3D) AddXYAxis

func (c *Surface3D) AddXYAxis(xAxis, yAxis interface{}) *Surface3D

AddXYAxis adds both the X axis and the Y axis.

func (*Surface3D) AddZAxis

func (c *Surface3D) AddZAxis(name string, zAxis interface{}, options ...seriesOptser) *Surface3D

AddZAxis adds the Z axis.

type TBFeature

type TBFeature struct {
	// 保存为图片
	SaveAsImage `json:"saveAsImage"`
	// 数据区域缩放。目前只支持直角坐标系的缩放
	DataZoom struct{} `json:"dataZoom"`
	// 数据视图工具,可以展现当前图表所用的数据,编辑后可以动态更新
	DataView struct{} `json:"dataView"`
	// 配置项还原
	Restore struct{} `json:"restore"`
}

TBFeature is a feature component under toolbox.

type TextStyleOpts

type TextStyleOpts struct {
	// 文字字体颜色
	Color string `json:"color,omitempty"`
	// 文字字体的风格
	// 可选  'normal', 'italic', 'oblique'
	FontStyle string `json:"fontStyle,omitempty"`
	// 字体大小
	FontSize int `json:"fontSize,omitempty"`
	// 递归结构,为了兼容 wordCloud
	Normal *TextStyleOpts `json:"normal,omitempty"`
}

TextStyleOpts is the option set for a text style component.

type ThemeRiver

type ThemeRiver struct {
	BaseOpts
	Series
}

ThemeRiver represents a theme river chart.

func NewThemeRiver

func NewThemeRiver(routers ...RouterOpts) *ThemeRiver

NewThemeRiver creates a new theme river chart.

func (*ThemeRiver) Add

func (c *ThemeRiver) Add(name string, data interface{}, options ...seriesOptser) *ThemeRiver

Add adds new data sets.

func (*ThemeRiver) Render

func (c *ThemeRiver) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*ThemeRiver) SetGlobalOptions

func (c *ThemeRiver) SetGlobalOptions(options ...globalOptser) *ThemeRiver

SetGlobalOptions sets options for the ThemeRiver instance.

type TitleOpts

type TitleOpts struct {
	// 主标题
	Title string `json:"text,omitempty"`
	// 主标题样式配置项
	TitleStyle TextStyleOpts `json:"textStyle,omitempty"`
	// 副标题
	Subtitle string `json:"subtext,omitempty"`
	// 副标题样式配置项
	SubtitleStyle TextStyleOpts `json:"subtextStyle,omitempty"`
	// 主标题文本超链接
	Link string `json:"link,omitempty"`
	// 指定窗口打开主标题超链接
	// 'self' 当前窗口打开
	// 'blank' 新窗口打开
	Target string `json:"target,omitempty"`
	// grid 组件离容器上侧的距离。
	// top 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比
	// 也可以是 'top', 'middle', 'bottom'。
	// 如果 top 的值为'top', 'middle', 'bottom',组件会根据相应的位置自动对齐
	Top string `json:"top,omitempty"`
	// 图例组件离容器下侧的距离。
	// bottom 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比。
	// 默认自适应。
	Bottom string `json:"bottom,omitempty"`
	// 图例组件离容器左侧的距离。
	// left 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比
	// 也可以是 'left', 'center', 'right'。
	// 如果 left 的值为'left', 'center', 'right',组件会根据相应的位置自动对齐。
	Left string `json:"left,omitempty"`
	// 图例组件离容器右侧的距离。
	// right 的值可以是像 20 这样的具体像素值,可以是像 '20%' 这样相对于容器高宽的百分比。
	// 默认自适应。
	Right string `json:"right,omitempty"`
}

TitleOpts is the option set for a title component.

type ToolboxOpts

type ToolboxOpts struct {
	// 是否显示工具栏组件
	Show bool `json:"show"`
	// 工具箱功能种类,不支持自定义
	TBFeature `json:"feature"`
}

ToolboxOpts is the option set for a toolbox component.

type TooltipOpts

type TooltipOpts struct {
	// 是否显示提示框
	Show bool `json:"show,omitempty"`
	// 触发类型。
	// "item": 数据项图形触发,主要在散点图,饼图等无类目轴的图表中使用。
	// "axis": 坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用。
	// "none": 什么都不触发。
	Trigger string `json:"trigger,omitempty"`
	// 提示框触发的条件,可选:
	// "mousemove": 鼠标移动时触发。
	// "click": 鼠标点击时触发。
	// "mousemove|click": 同时鼠标移动和点击时触发。
	// "none": 不在 "mousemove" 或 "click" 时触发
	TriggerOn string `json:"triggerOn,omitempty"`
	// 1, 字符串模板
	// 模板变量有 {a}, {b},{c},{d},{e},分别表示系列名,数据名,数据值等。
	// 在 trigger 为 'axis' 的时候,会有多个系列的数据,此时可以通过 {a0}, {a1}, {a2}
	// 这种后面加索引的方式表示系列的索引。 不同图表类型下的 {a},{b},{c},{d} 含义不一样。
	// 其中变量{a}, {b}, {c}, {d} 在不同图表类型下代表数据含义为:
	// 折线(区域)图、柱状(条形)图、K 线图 : {a}(系列名称),{b}(类目值),{c}(数值), {d}(无)
	// 散点图(气泡)图 : {a}(系列名称),{b}(数据名称),{c}(数值数组), {d}(无)
	// 地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)
	// 饼图、仪表盘、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)
	//
	// 2, 回调函数
	// 回调函数格式:
	// (params: Object|Array, ticket: string, callback: (ticket: string, html: string)) => string
	// 第一个参数 params 是 formatter 需要的数据集。格式如下:
	// {
	//    componentType: 'series',
	//    seriesType: string,	// 系列类型
	//    seriesIndex: number,	// 系列在传入的 option.series 中的 index
	//    seriesName: string,	// 系列名称
	//    name: string,			// 数据名,类目名
	//    dataIndex: number,	// 数据在传入的 data 数组中的 index
	//    data: Object,			// 传入的原始数据项
	//    value: number|Array,	// 传入的数据值
	//    color: string,		// 数据图形的颜色
	//    percent: number,		// 饼图的百分比
	// }
	Formatter string `json:"formatter,omitempty"`
}

TooltipOpts is the option set for a tooltip component.

type VMInRange

type VMInRange struct {
	// 图元的颜色
	Color []string `json:"color,omitempty"`
	// 图元的图形类别
	// 可选 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none'
	Symbol string `json:"symbol,omitempty"`
	// 图元的大小
	SymbolSize float32 `json:"symbolSize,omitempty"`
}

VMInRange is a visual map instance in a range.

type ViewControlOpts

type ViewControlOpts struct {
	// 是否开启视角绕物体的自动旋转查看
	AutoRotate bool `json:"autoRotate,omitempty"`
	// 物体自转的速度。单位为角度 / 秒,默认为 10 ,也就是 36 秒转一圈
	AutoRotateSpeed float32 `json:"autoRotateSpeed,omitempty"`
}

ViewControlOpts contains options for view controlling.

type VisualMapOpts

type VisualMapOpts struct {
	// 映射类型,可选 "continuous", "piecewise"
	Type string `json:"type,omitempty" default:"continuous"`
	// 是否显示拖拽用的手柄(手柄能拖拽调整选中范围)
	Calculable bool `json:"calculable"`
	// VisualMap 组件的允许的最小值
	Min float32 `json:"min,omitempty"`
	// VisualMap 组件的允许的最大值
	Max float32 `json:"max,omitempty"`
	// 指定手柄对应数值的位置。range 应在 min max 范围内
	Range []float32 `json:"range,omitempty"`
	// 两端的文本,如 ['High', 'Low']
	Text []string `json:"text,omitempty"`
	// 定义在选中范围中的视觉元素
	InRange VMInRange `json:"inRange,omitempty"`
}

VisualMapOpts is the option set for a visual map component. 用于进行『视觉编码』,也就是将数据映射到视觉元素(视觉通道)

type VisualMapOptsList

type VisualMapOptsList []VisualMapOpts

VisualMapOptsList is a list of VisualMapOpts.

func (VisualMapOptsList) Len

func (vm VisualMapOptsList) Len() int

Len returns the count of VisualMapOptsList in array.

type WordCloud

type WordCloud struct {
	BaseOpts
	Series
}

WordCloud represents a word cloud chart.

func NewWordCloud

func NewWordCloud(routers ...RouterOpts) *WordCloud

NewWordCloud creates a new word cloud chart.

func (*WordCloud) Add

func (c *WordCloud) Add(name string, data map[string]interface{}, options ...seriesOptser) *WordCloud

Add adds new data sets.

func (*WordCloud) Render

func (c *WordCloud) Render(w ...io.Writer) error

Render renders the chart and writes the output to given writers.

func (*WordCloud) SetGlobalOptions

func (c *WordCloud) SetGlobalOptions(options ...globalOptser) *WordCloud

SetGlobalOptions sets options for the WordCloud instance.

type WordCloudOpts

type WordCloudOpts struct {
	// shape of WordCloud
	// Optional: "circle", "rect", "roundRect", "triangle", "diamond", "pin", "arrow"
	Shape string
	// range of font size
	SizeRange []float32
	// range of font rotation angle
	RotationRange []float32
}

WordCloudOpts is the option set for a word cloud chart.

type XAxis3DOpts

type XAxis3DOpts struct {
	// 是否显示 3D X 轴
	Show bool `json:"show,omitempty"`
	// X 坐标轴名称
	Name bool `json:"name,omitempty"`
	// X 坐标轴使用的 grid3D 组件的索引。默认使用第一个 grid3D 组件
	Grid3DIndex int `json:"grid3DIndex,omitempty"`
	// X 坐标轴类型,可选:
	// "value" 数值轴,适用于连续数据。
	// "category" 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
	// "log" 对数轴。适用于对数数据。
	Type string `json:"type,omitempty"`
	// X 坐标轴刻度最小值。
	// 可以设置成特殊值 "dataMin",此时取数据在该轴上的最小值作为最小刻度。
	// 不设置时会自动计算最小值保证坐标轴刻度的均匀分布
	Min interface{} `json:"min,omitempty"`
	// X 坐标轴刻度最大值。
	// 可以设置成特殊值 "dataMax",此时取数据在该轴上的最大值作为最大刻度。
	// 不设置时会自动计算最大值保证坐标轴刻度的均匀分布
	Max interface{} `json:"max,omitempty"`
	// 类目数据,在类目轴(type: 'category')中有效
	Data interface{} `json:"data,omitempty"`
}

XAxis3DOpts contains options for X axis in the 3D coordinate.

type XAxisOpts

type XAxisOpts struct {
	// X 轴名称
	Name string `json:"name,omitempty"`
	// X 坐标轴类型,可选:
	// "value":数值轴,适用于连续数据。
	// "category" 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
	// "time" 时间轴,适用于连续的时序数据,与数值轴相比时间轴带有时间的格式化,
	// 在刻度计算上也有所不同,例如会根据跨度的范围来决定使用月,星期,日还是小时范围的刻度。
	// "log" 对数轴。适用于对数数据。
	Type string `json:"type,omitempty"`
	// 是否显示 X 轴
	Show bool `json:"show,omitempty"`
	// X 轴数据项
	Data interface{} `json:"data,omitempty"`
	// X 坐标轴的分割段数,需要注意的是这个分割段数只是个预估值,
	// 最后实际显示的段数会在这个基础上根据分割后坐标轴刻度显示的易读程度作调整。
	// 在类目轴中无效
	SplitNumber int `json:"splitNumber,omitempty"`
	// 只在数值轴中(type: 'value')有效。
	// 是否是脱离 0 值比例。设置成 true 后坐标刻度不会强制包含零刻度。在双数值轴的散点图中比较有用。
	// 在设置 min 和 max 之后该配置项无效
	// 默认为 false
	Scale bool `json:"scale,omitempty"`
	// X 坐标轴刻度最小值
	// 可以设置成特殊值 'dataMin',此时取数据在该轴上的最小值作为最小刻度,数值轴有效
	Min interface{} `json:"min,omitempty"`
	// X 坐标轴刻度最大值
	// 可以设置成特殊值 'dataMax',此时取数据在该轴上的最小值作为最小刻度,数值轴有效
	Max interface{} `json:"max,omitempty"`
	// X 轴所在的 grid 的索引
	// 默认 0
	GridIndex int `json:"gridIndex,omitempty"`
	// X 轴在 grid 区域中的分隔区域配置项
	SplitArea SplitAreaOpts `json:"splitArea,omitempty"`
	// X 轴在 grid 区域中的分隔线配置项
	SplitLine  SplitLineOpts `json:"splitLine,omitempty"`
	NameRotate int           `json:"nameRotate,omitempty"`
	// 刻度标签的内容格式器,支持字符串模板和回调函数两种形式
	// 1.使用字符串模板,模板变量为刻度默认标签 {value}
	// formatter: '{value} kg'
	// 2.使用函数模板,函数参数分别为刻度数值(类目),刻度的索引
	// formatter: function (value, index) {
	//    // 格式化成月/日,只在第一个刻度显示年份
	//    var date = new Date(value);
	//    var texts = [(date.getMonth() + 1), date.getDate()];
	//    if (index === 0) {
	//        texts.unshift(date.getYear());
	//    }
	//    return texts.join('/');
	// }
	AxisLabel LabelTextOpts `json:"axisLabel,omitempty"`
}

XAxisOpts is the option set for X axis.

type XYAxis

type XYAxis struct {
	XAxisOptsList []XAxisOpts
	YAxisOptsList []YAxisOpts
}

XYAxis represent the X and Y axis in the rectangular coordinate.

func (*XYAxis) ExtendXAxis

func (xy *XYAxis) ExtendXAxis(xAxis ...XAxisOpts)

ExtendXAxis adds new X axes.

func (*XYAxis) ExtendYAxis

func (xy *XYAxis) ExtendYAxis(yAxis ...YAxisOpts)

ExtendYAxis adds new Y axes.

type YAxis3DOpts

type YAxis3DOpts struct {
	// 是否显示 3D Y 轴
	Show bool `json:"show,omitempty"`
	// Y 坐标轴名称
	Name bool `json:"name,omitempty"`
	// Y 坐标轴使用的 grid3D 组件的索引。默认使用第一个 grid3D 组件
	Grid3DIndex int `json:"grid3DIndex,omitempty"`
	// Y 坐标轴类型,可选:
	// "value" 数值轴,适用于连续数据。
	// "category" 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
	// "log" 对数轴。适用于对数数据。
	Type string `json:"type,omitempty"`
	// Y 坐标轴刻度最小值。
	// 可以设置成特殊值 "dataMin",此时取数据在该轴上的最小值作为最小刻度。
	// 不设置时会自动计算最小值保证坐标轴刻度的均匀分布
	Min interface{} `json:"min,omitempty"`
	// Y 坐标轴刻度最大值。
	// 可以设置成特殊值 "dataMax",此时取数据在该轴上的最大值作为最大刻度。
	// 不设置时会自动计算最大值保证坐标轴刻度的均匀分布
	Max interface{} `json:"max,omitempty"`
	// 类目数据,在类目轴(type: 'category')中有效
	Data interface{} `json:"data,omitempty"`
}

YAxis3DOpts contains options for Y axis in the 3D coordinate.

type YAxisOpts

type YAxisOpts struct {
	// Y 轴名称
	Name string `json:"name,omitempty"`
	// Y 坐标轴类型,可选:
	// "value":数值轴,适用于连续数据。
	// "category" 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
	// "time" 时间轴,适用于连续的时序数据,与数值轴相比时间轴带有时间的格式化,
	// 在刻度计算上也有所不同,例如会根据跨度的范围来决定使用月,星期,日还是小时范围的刻度。
	// "log" 对数轴。适用于对数数据。
	Type string `json:"type,omitempty"`
	// 是否显示 Y 轴
	Show bool `json:"show,omitempty"`
	// 刻度标签的内容格式器,支持字符串模板和回调函数两种形式
	// 1.使用字符串模板,模板变量为刻度默认标签 {value}
	// formatter: '{value} kg'
	// 2.使用函数模板,函数参数分别为刻度数值(类目),刻度的索引
	// formatter: function (value, index) {
	//    // 格式化成月/日,只在第一个刻度显示年份
	//    var date = new Date(value);
	//    var texts = [(date.getMonth() + 1), date.getDate()];
	//    if (index === 0) {
	//        texts.unshift(date.getYear());
	//    }
	//    return texts.join('/');
	// }
	AxisLabel LabelTextOpts `json:"axisLabel,omitempty"`
	// Y 轴数据项
	Data interface{} `json:"data,omitempty"`
	// Y 坐标轴的分割段数,需要注意的是这个分割段数只是个预估值,
	// 最后实际显示的段数会在这个基础上根据分割后坐标轴刻度显示的易读程度作调整。
	// 在类目轴中无效
	SplitNumber int `json:"splitNumber,omitempty"`
	// 只在数值轴中(type: 'value')有效。
	// 是否是脱离 0 值比例。设置成 true 后坐标刻度不会强制包含零刻度。在双数值轴的散点图中比较有用。
	// 在设置 min 和 max 之后该配置项无效
	// 默认为 false
	Scale bool `json:"scale,omitempty"`
	// Y 坐标轴刻度最小值
	// 可以设置成特殊值 'dataMin',此时取数据在该轴上的最小值作为最小刻度,数值轴有效
	Min interface{} `json:"min,omitempty"`
	// Y 坐标轴刻度最大值
	// 可以设置成特殊值 'dataMax',此时取数据在该轴上的最小值作为最小刻度,数值轴有效
	Max interface{} `json:"max,omitempty"`
	// Y 轴所在的 grid 的索引
	// 默认 0
	GridIndex int `json:"gridIndex,omitempty"`
	// Y 轴在 grid 区域中的分隔区域配置项
	SplitArea SplitAreaOpts `json:"splitArea,omitempty"`
	// Y 轴在 grid 区域中的分隔线配置项
	SplitLine  SplitLineOpts `json:"splitLine,,omitempty"`
	NameRotate int           `json:"nameRotate,omitempty"`
}

YAxisOpts is the option set for Y axis.

type ZAxis3DOpts

type ZAxis3DOpts struct {
	// 是否显示 3D Z 轴
	Show bool `json:"show,omitempty"`
	// Z 坐标轴名称
	Name bool `json:"name,omitempty"`
	// Z 坐标轴使用的 grid3D 组件的索引。默认使用第一个 grid3D 组件
	Grid3DIndex int `json:"grid3DIndex,omitempty"`
	// Z 坐标轴类型,可选:
	// "value" 数值轴,适用于连续数据。
	// "category" 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
	// "log" 对数轴。适用于对数数据。
	Type string `json:"type,omitempty"`
	// Z 坐标轴刻度最小值。
	// 可以设置成特殊值 "dataMin",此时取数据在该轴上的最小值作为最小刻度。
	// 不设置时会自动计算最小值保证坐标轴刻度的均匀分布
	Min interface{} `json:"min,omitempty"`
	// Z 坐标轴刻度最大值。
	// 可以设置成特殊值 "dataMax",此时取数据在该轴上的最大值作为最大刻度。
	// 不设置时会自动计算最大值保证坐标轴刻度的均匀分布
	Max interface{} `json:"max,omitempty"`
	// 类目数据,在类目轴(type: 'category')中有效
	Data interface{} `json:"data,omitempty"`
}

ZAxis3DOpts contains options for Z axis in the 3D coordinate.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL