ghtml

package
v0.0.0-...-f3abbe6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDocFromHtmlSrc

func NewDocFromHtmlSrc(htmlSrc *string) (*goquery.Document, error)

func ServeChart

func ServeChart(listen string, tpl ChartTemplate)

TODO: implement 要求光标同步

Types

type Bar

type Bar struct {
	Name   string              // 值名称,光标放在绘图区时在绘图区上沿要显示值名称和值
	Data   []gnum.ElegantFloat // 数据
	Colors []gcolor.Color      // 每根bar的颜色
}

柱状图

type CandleStick

type CandleStick struct {
	Name          string                 // 值名称,光标放在绘图区时在绘图区上沿要显示值名称和值
	Ohlc          [4][]gnum.ElegantFloat // O,H,L,C
	DownColor     gcolor.Color           // 阴线样式,支持背景颜色
	UpColor       gcolor.Color           // 阳线样式,支持背景颜色
	Tips          []Tip                  // 文字注释
	Rects         []Rect                 // 矩形色块
	StraightLines []StraightLine         // 直线,比如压力位、之字形折线、趋势线
}

蜡烛图

type ChartLines

type ChartLines struct {
	// contains filtered or unexported fields
}

func NewChartLines

func NewChartLines() *ChartLines

func (*ChartLines) Clone

func (cl *ChartLines) Clone() *ChartLines

func (*ChartLines) JSONAutoDetect

func (cl *ChartLines) JSONAutoDetect() ([]byte, error)

func (*ChartLines) JSONTimes

func (cl *ChartLines) JSONTimes() []gtime.ElegantTime

func (*ChartLines) LineMode

func (cl *ChartLines) LineMode() *ClLineMode

func (*ChartLines) LinesMode

func (cl *ChartLines) LinesMode() *ClLinesMode

func (*ChartLines) OclhMode

func (cl *ChartLines) OclhMode() *ClOclhMode

func (*ChartLines) SetHumanReadPrec

func (cl *ChartLines) SetHumanReadPrec(hrp int)

func (*ChartLines) SetTimeLayout

func (cl *ChartLines) SetTimeLayout(layout string)

func (*ChartLines) Times

func (cl *ChartLines) Times() []time.Time

type ChartTemplate

type ChartTemplate struct {
	Title   string              // 整个图表的大标题
	Times   []gtime.ElegantTime // 时间轴
	Series  []Series            // 所有子图表
	Heights []int               // 比如有4个Series,那么就用[60,10,10,20]表示每个Series的显示百分比
}

一个绘图模板,包含了整个页面需要的数据,包括一个共享的时间轴和多个绘图区域,多种数据显示样式

type ClLineMode

type ClLineMode ChartLines

func (*ClLineMode) Set

func (cl *ClLineMode) Set(lineName string, times []time.Time, values []float64)

type ClLinesMode

type ClLinesMode ChartLines

func (*ClLinesMode) Append

func (cl *ClLinesMode) Append(lineName string, times []time.Time, values []float64)

type ClOclhMode

type ClOclhMode ChartLines

func (*ClOclhMode) Append

func (cl *ClOclhMode) Append(name string, vals []float64) error

func (*ClOclhMode) GetLine

func (cl *ClOclhMode) GetLine(i int) []float64

func (*ClOclhMode) Init

func (cl *ClOclhMode) Init(OCLHName string, times []time.Time, OCLHs [][4]float64)

type Line

type Line struct {
	Name  string               // 值名称,光标放在绘图区时在绘图区上沿要显示值名称和值
	Data  []*gnum.ElegantFloat // 数据,空指针表示不画点,在eCharts输入数据中就是null
	Color gcolor.Color         // 样式,支持背景颜色
}

散点连线

type Node

type Node struct {
	// contains filtered or unexported fields
}

html node

func NewFromString

func NewFromString(s string) (*Node, error)

build node from HTML string

func (*Node) Attr

func (n *Node) Attr(attrKey string) string

get attribute value by key

func (*Node) Parent

func (n *Node) Parent() *Node

get father node

func (*Node) Query

func (n *Node) Query(xpathExpr string) *Nodes

query with xpath expr

func (*Node) QueryByElementAndFullAttrVal

func (n *Node) QueryByElementAndFullAttrVal(element, attrKey, fullAttrVal string) *Nodes

query nodes by element + attribute key + attribute full value

func (*Node) QueryByElementAndPartAttrVal

func (n *Node) QueryByElementAndPartAttrVal(element, attrKey, partAttrVal string) *Nodes

query nodes by element + attribute key + attribute part value

func (*Node) Text

func (n *Node) Text() string

get text of node

type NodeEachCallback

type NodeEachCallback func(i int, n *Node)

callback function of Each()

type Nodes

type Nodes struct {
	// contains filtered or unexported fields
}

nodes list with it's own methods

func (*Nodes) Attrs

func (ns *Nodes) Attrs(attrKey string) []string

get attribute values of all nodes by attribute key

func (*Nodes) Each

func (ns *Nodes) Each(cb NodeEachCallback)

loop through all members

func (*Nodes) First

func (ns *Nodes) First() *Node

get first node, return nil if index not exist

func (*Nodes) Get

func (ns *Nodes) Get(i int) *Node

get by index, return nil if index not exist

func (*Nodes) Last

func (ns *Nodes) Last() *Node

get last node, return nil if index not exist

func (*Nodes) Len

func (ns *Nodes) Len() int

get length

func (*Nodes) Texts

func (ns *Nodes) Texts() []string

get texts of all nodes

type Rect

type Rect struct {
	X1    string           // 矩形第一个点的X坐标,即时间
	Y1    gdecimal.Decimal // 矩形第一个点的Y坐标
	X2    string           // 矩形第二个点的X坐标,即时间
	Y2    gdecimal.Decimal // 矩形第二个点的Y坐标
	Color gcolor.Color     // 样式,默认半透明的
}

矩形色块

type Series

type Series struct {
	Name        string       // 绘图区左上角显示的名字,比如"601398(工商银行)"
	CandleStick *CandleStick // 时间轴线条类型1:蜡烛图, 每个Series最多一个蜡烛图
	BarStick    *Bar         // 时间轴线条类型2:柱状图, 每个Series最多一个柱状图
	Lines       []Line       // 时间轴线条类型3:曲线图或者折线图
}

一个绘图区域,CandleStick和Bar不可以同时绘制,Lines可以有多个

type StraightLine

type StraightLine struct {
	X1    string           // 直线第一个点的X坐标,即时间
	Y1    gdecimal.Decimal // 直线第一个点的Y坐标
	X2    string           // 直线第二个点的X坐标
	Y2    gdecimal.Decimal // 直线第二个点的Y坐标
	Color gcolor.Color     // 样式
}

直线

type Tip

type Tip struct {
	X     string       // X坐标,即时间
	Y     float64      // Y坐标
	Text  string       // 内容
	Color gcolor.Color // 样式
}

一个点+文字注释

type XAxisSync

type XAxisSync struct {
	// contains filtered or unexported fields
}

func NewXAxisSync

func NewXAxisSync() *XAxisSync

func (*XAxisSync) AddFloats

func (s *XAxisSync) AddFloats(name string, times []time.Time, vals []float64) error

func (*XAxisSync) GetFloatValuesPanic

func (s *XAxisSync) GetFloatValuesPanic(name string) []*float64

func (*XAxisSync) GetNames

func (s *XAxisSync) GetNames() []string

func (*XAxisSync) GetTimes

func (s *XAxisSync) GetTimes() []time.Time

func (*XAxisSync) GetValues

func (s *XAxisSync) GetValues(name string) []interface{}

returns []*float / []*KDot

func (*XAxisSync) Sync

func (s *XAxisSync) Sync()

Jump to

Keyboard shortcuts

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