plot

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 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 CreateBoxPlot added in v0.0.11

func CreateBoxPlot(config BoxPlotConfig) *charts.BoxPlot

CreateBoxPlot generates and returns a *charts.BoxPlot object

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

func CreateScatterChart(config ScatterChartConfig) *charts.Scatter

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

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.
	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 BoxPlotConfig added in v0.0.11

type BoxPlotConfig struct {
	Title      string
	Subtitle   string
	XAxis      []string // X-axis data.
	SeriesData 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 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
	SeriesData 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.
	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 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.
	SeriesData map[string]map[string]float32
}

RadarChartConfig 定義雷達圖的配置

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.

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.
	SeriesData 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