plot

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBarChart added in v0.0.9

func CreateBarChart(config BarChartConfig) *charts.Bar

CreateBarChart generates and returns a *charts.Bar object based on BarChartConfig.

func CreateBoxPlot added in v0.0.11

func CreateBoxPlot(config BoxPlotConfig) *charts.BoxPlot

CreateBoxPlot generates and returns a *charts.BoxPlot object

func CreateFunnelChart added in v0.0.12

func CreateFunnelChart(config FunnelChartConfig) *charts.Funnel

CreateFunnelChart generates a funnel chart based on the provided configuration.

func CreateGaugeChart added in v0.0.11

func CreateGaugeChart(config GaugeChartConfig) *charts.Gauge

CreateGaugeChart 生成並返回 *charts.Gauge 對象

func CreateHeatmapChart added in v0.0.10

func CreateHeatmapChart(config HeatmapChartConfig) *charts.HeatMap

CreateHeatmapChart generates and returns a *charts.HeatMap object based on HeatmapChartConfig.

func CreateKlineChart added in v0.0.11

func CreateKlineChart(config KlineChartConfig) *charts.Kline

CreateKlineChart generates and returns a *charts.Kline object.

func CreateLineChart added in v0.0.9

func CreateLineChart(config LineChartConfig) *charts.Line

CreateLineChart generates and returns a *charts.Line object based on LineChartConfig.

func CreateLiquidChart added in v0.0.10

func CreateLiquidChart(config LiquidChartConfig) *charts.Liquid

CreateLiquidChart generates and returns a *charts.Liquid object based on LiquidChartConfig.

func CreatePieChart added in v0.0.9

func CreatePieChart(config PieChartConfig) *charts.Pie

CreatePieChart generates and returns a *charts.Pie object based on PieChartConfig.

func CreateRadarChart added in v0.0.11

func CreateRadarChart(config RadarChartConfig) *charts.Radar

CreateRadarChart 生成並返回 *charts.Radar 對象

func CreateSankeyChart added in v0.0.12

func CreateSankeyChart(config SankeyChartConfig) *charts.Sankey

CreateSankeyChart generates and returns a *charts.Sankey object based on SankeyChartConfig.

func CreateScatterChart added in v0.0.10

func CreateScatterChart(config ScatterChartConfig) *charts.Scatter

CreateScatterChart generates and returns a *charts.Scatter object based on ScatterChartConfig.

func CreateThemeRiverChart added in v0.0.12

func CreateThemeRiverChart(config ThemeRiverChartConfig) *charts.ThemeRiver

CreateThemeRiverChart create and return *charts.ThemeRiver object

func CreateWordCloud added in v0.0.11

func CreateWordCloud(config WordCloudConfig) *charts.WordCloud

CreateWordCloud generates and returns a *charts.WordCloud object based on WordCloudChartConfig.

func SaveHTML added in v0.0.9

func SaveHTML(chart Renderable, path string, animation ...bool)

SaveHTML 將圖表渲染並保存為 HTML 文件

func SavePNG added in v0.0.9

func SavePNG(chart Renderable, pngPath string)

SavePNG 將圖表渲染為 PNG 文件,使用 snapshot-chromedp

Types

type BarChartConfig added in v0.0.9

type BarChartConfig struct {
	Title        string   // Title of the chart.
	Subtitle     string   // Subtitle of the chart.
	XAxis        []string // X-axis data.
	Data         any      // Accepts map[string][]float64, []*insyra.DataList, or []insyra.IDataList.
	XAxisName    string   // Optional: X-axis name.
	YAxisName    string   // Optional: Y-axis name.
	YAxisNameGap int      // Optional: Gap between Y-axis name and subtitle.
	Colors       []string // Optional: Colors for the bars, for example: ["green", "orange"].
	ShowLabels   bool     // Optional: Show labels on the bars.
	LabelPos     string   // Optional: "top" | "bottom" | "left" | "right", default: "top".
	GridTop      string   // Optional: default: "80".
}

BarChartConfig defines the configuration for a bar chart.

type BoxPlotConfig added in v0.0.11

type BoxPlotConfig struct {
	Title    string
	Subtitle string
	XAxis    []string // X-axis data.
	Data     any      // Accepts map[string][][]float64, []*insyra.DataList, or map[string]any for multiple series.
	GridTop  string   // Optional: Top grid line. Default: "80".
}

BoxPlotConfig defines the configuration for a box plot chart.

type FunnelChartConfig added in v0.0.12

type FunnelChartConfig struct {
	Title      string             // chart title
	Subtitle   string             // chart subtitle
	SeriesName string             // series name
	Data       map[string]float64 // data points (dimension name -> value)
	ShowLabels bool               // whether to show labels
	LabelPos   string             // label position (e.g., "left", "right")
}

FunnelChartConfig defines the configuration for a funnel chart.

type GaugeChartConfig added in v0.0.11

type GaugeChartConfig struct {
	Title      string  // chart title
	Subtitle   string  // chart subtitle
	SeriesName string  // series name
	Value      float64 // value to display
}

GaugeChartConfig defines the configuration for a gauge chart.

type HeatmapChartConfig added in v0.0.10

type HeatmapChartConfig struct {
	Title    string   // Title of the heatmap.
	Subtitle string   // Subtitle of the heatmap.
	XAxis    []string // X-axis data.
	YAxis    []string // Y-axis data (typically categories).
	Data     [][3]int // Heatmap data in the form of [x, y, value].
	Colors   []string // Optional: Colors for the heatmap. Default is ["#50a3ba", "#eac736", "#d94e5d"].
	Min      int      // Minimum value for visual map.
	Max      int      // Maximum value for visual map.
	GridTop  string   // Optional: Space between the top of the chart and the title. Default is "80".
}

HeatmapChartConfig defines the configuration for a heatmap chart.

type KlineChartConfig added in v0.0.11

type KlineChartConfig struct {
	Title    string
	Subtitle string
	Data     any  // Accepts map[string][4]float32 or []*insyra.DataList
	DataZoom bool // Turn on/off data zoom
}

KlineChartConfig defines the configuration for a K-line chart.

type LineChartConfig added in v0.0.9

type LineChartConfig struct {
	Title        string   // Title of the chart.
	Subtitle     string   // Subtitle of the chart.
	XAxis        []string // X-axis data.
	Data         any      // Accepts map[string][]float64, []*insyra.DataList, or []insyra.IDataList.
	XAxisName    string   // Optional: X-axis name.
	YAxisName    string   // Optional: Y-axis name.
	YAxisNameGap int      // Optional: Gap between Y-axis name and subtitle.
	Colors       []string // Optional: Colors for the lines, for example: ["blue", "red"].
	ShowLabels   bool     // Optional: Show labels on the lines.
	LabelPos     string   // Optional: "top" | "bottom" | "left" | "right", default: "top".
	Smooth       bool     // Optional: Make the lines smooth.
	FillArea     bool     // Optional: Fill the area under the lines.
	GridTop      string   // Optional, default: "80".
}

LineChartConfig defines the configuration for a line chart.

type LiquidChartConfig added in v0.0.10

type LiquidChartConfig struct {
	Title           string             // Title of the chart.
	Subtitle        string             // Subtitle of the chart.
	Data            map[string]float32 // Accepts map[string]float32.
	ShowLabels      bool               // Optional: Show labels on the liquid chart.
	IsWaveAnimation bool               // Optional: Enable/Disable wave animation.
	Shape           string             // Optional: Shape of the liquid chart (e.g., "diamond", "pin", "arrow", "triangle").
}

LiquidChartConfig defines the configuration for a liquid chart.

type PieChartConfig added in v0.0.9

type PieChartConfig struct {
	Title       string   // Title of the chart.
	Subtitle    string   // Subtitle of the chart.
	Data        any      // Accepts []float64 or []*insyra.DataList.
	Labels      []string // Labels for each slice (for example: product names).
	Colors      []string // Optional: Colors for the slices, for example: ["green", "orange"].
	ShowLabels  bool     // Optional: Show labels on the slices.
	LabelPos    string   // Optional: "inside" | "outside", default: "outside".
	RoseType    string   // Optional: "radius" or "area" for rose charts.
	Radius      []string // Optional: Radius configuration. First value is inner radius, second is outer radius, for example: ["40%", "75%"].
	Center      []string // Optional: Center position, for example: ["50%", "50%"].
	ShowPercent bool     // Optional: Show percentage on labels.
}

PieChartConfig defines the configuration for a pie chart.

type RadarChartConfig added in v0.0.11

type RadarChartConfig struct {
	Title      string
	Subtitle   string
	Indicators []string           // Optional: Automatically generated if not provided.
	MaxValues  map[string]float32 // Optional: Automatically generated if not provided.
	Data       map[string]map[string]float32
}

RadarChartConfig 定義雷達圖的配置

type Renderable added in v0.0.9

type Renderable interface {
	Render(w io.Writer) error
}

Renderable 定義了可以被渲染的圖表接口

type SankeyChartConfig added in v0.0.12

type SankeyChartConfig struct {
	Title      string       // Chart title
	Subtitle   string       // Chart subtitle
	Nodes      []string     // Sankey chart node data (string slice)
	Links      []SankeyLink // Sankey chart link data
	Curveness  float32      // Line curvature
	Color      string       // Line color
	ShowLabels bool         // Whether to display labels
}

SankeyChartConfig defines the configuration for a Sankey chart.

type SankeyLink struct {
	Source string  `json:"source"`
	Target string  `json:"target"`
	Value  float32 `json:"value"`
}

SankeyLink custom link structure.

func LoadSankeyDataFromFile added in v0.0.12

func LoadSankeyDataFromFile(filePath string) ([]string, []SankeyLink)

LoadSankeyDataFromFile reads the Sankey chart node and link data from a JSON file.

type ScatterChartConfig added in v0.0.10

type ScatterChartConfig struct {
	Title      string                 // Title of the chart.
	Subtitle   string                 // Subtitle of the chart.
	Data       map[string][][]float64 // Accepts multiple series, where each series is identified by a string and contains two-dimensional data (X, Y).
	XAxisName  string                 // Optional: X-axis name.
	YAxisName  string                 // Optional: Y-axis name.
	Colors     []string               // Optional: Colors for the scatter points.
	ShowLabels bool                   // Optional: Show labels on the scatter points.
	LabelPos   string                 // Optional: Position of the labels, default is "right".
	GridTop    string                 // Optional: Space between the top of the chart and the title. Default is "80".
	SplitLine  bool                   // Optional: Whether to show split lines on the X and Y axes.
	Symbol     []string               // Optional: Symbol of the scatter points. Default is "circle". If there are multiple series, you can specify different symbols for each series. If the length of the array is less than the number of series, the remaining series will repeat the order of the symbols.
	SymbolSize int                    // Optional: Size of the scatter points. Default is 10.
}

ScatterChartConfig defines the configuration for a scatter chart.

type ThemeRiverChartConfig added in v0.0.12

type ThemeRiverChartConfig struct {
	Title    string           // title
	Subtitle string           // subtitle
	Data     []ThemeRiverData // data
}

ThemeRiverChartConfig define chart config, fixed X-axis to time axis.

type ThemeRiverData added in v0.0.12

type ThemeRiverData struct {
	Date  string  // date, format: "yyyy/MM/dd"
	Value float64 // value
	Name  string  // name/series name
}

ThemeRiverData define single data struct.

type WordCloudConfig added in v0.0.11

type WordCloudConfig struct {
	Title     string             // Title of the word cloud chart.
	Subtitle  string             // Subtitle of the word cloud chart.
	Data      map[string]float32 // Accepts map[string]float32 for words and their frequencies.
	Shape     string             // Optional: Shape of the word cloud (e.g., "circle", "cardioid", "star").
	SizeRange []float32          // Optional: Size range for the words, e.g., [14, 80].
}

WordCloudConfig defines the configuration for a word cloud chart.

Jump to

Keyboard shortcuts

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