plot

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 13 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 CreateHeatmapChart added in v0.0.10

func CreateHeatmapChart(config HeatmapChartConfig) *charts.HeatMap

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

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 CreateScatterChart added in v0.0.10

func CreateScatterChart(config ScatterChartConfig) *charts.Scatter

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

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.
	SeriesData   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 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 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.
	SeriesData   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.
	SeriesData      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.
	SeriesData  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 Renderable added in v0.0.9

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

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

type ScatterChartConfig added in v0.0.10

type ScatterChartConfig struct {
	Title      string                 // Title of the chart.
	Subtitle   string                 // Subtitle of the chart.
	SeriesData 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.

Jump to

Keyboard shortcuts

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