Documentation
¶
Index ¶
- func ApplyYAxis[T any](chart Chart[T], name string, labels *[]string, min *float64, max *float64, ...) (bool, map[string]int, func(insyra.IDataList) []opts.LineData, ...)
- func DefaultColors() []string
- func GenerateHTMLColorPreview() string
- func GetColor(index int) string
- func GetColors(n int) []string
- func PrintColorPalette()
- func PrintColorsByFamily()
- func SetBaseChartGlobalOptions[T any](chart Chart[T], config BaseChartConfig)
- func SetShowLabels[T any](chart Chart[T], showLabels bool, labelPos string, defaultLabelPos string)
- type BaseChartConfig
- type Chart
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyYAxis ¶
func ApplyYAxis[T any](chart Chart[T], name string, labels *[]string, min *float64, max *float64, splitNumber *int, formatter string, data ...insyra.IDataList) (bool, map[string]int, func(insyra.IDataList) []opts.LineData, func(insyra.IDataList) []float64)
ApplyYAxis builds Y-axis options, applies them to the provided chart, and returns isCategory and mapping (if any). It will also set caller's labels if a pointer is provided so callers get derived labels automatically.
func DefaultColors ¶ added in v0.2.13
func DefaultColors() []string
DefaultColors returns a carefully curated palette of 64 colors designed for data visualization. This palette is designed to be: - Comfortable and easy on the eyes - Aesthetically pleasing and timeless - Well-balanced across the color spectrum - Suitable for both light and dark backgrounds - Accessible with good contrast - Professional and modern
The colors are arranged in an interleaved pattern across 8 color families. This ensures that consecutive colors in the palette are visually distinct, making it easy to differentiate between adjacent data series in charts.
Color families: 1. Blues (trust, stability, professionalism) 2. Greens (growth, harmony, nature) 3. Purples (creativity, luxury, wisdom) 4. Reds/Pinks (energy, passion, warmth) 5. Oranges/Ambers (enthusiasm, confidence, vitality) 6. Teals/Cyans (balance, clarity, freshness) 7. Warm Neutrals (sophistication, elegance) 8. Cool Accents (diversity, interest, depth)
Arrangement: Colors are interleaved so that index 0 is from family 1, index 1 is from family 2, index 2 is from family 3, etc. This maximizes visual distinction between consecutive series.
func GenerateHTMLColorPreview ¶ added in v0.2.13
func GenerateHTMLColorPreview() string
GenerateHTMLColorPreview generates an HTML file content that displays all colors in a visually appealing grid format showing the interleaved arrangement.
func GetColor ¶ added in v0.2.13
GetColor returns the color at the specified index from the default palette. If the index exceeds the palette size, it wraps around using modulo operation.
func GetColors ¶ added in v0.2.13
GetColors returns a slice of n colors from the default palette. If n exceeds the palette size, colors will repeat in a cyclic manner.
func PrintColorPalette ¶ added in v0.2.13
func PrintColorPalette()
PrintColorPalette prints all colors in the default palette with their hex codes and descriptions. Colors are displayed in their usage order (interleaved), showing how they appear when used in charts.
func PrintColorsByFamily ¶ added in v0.2.13
func PrintColorsByFamily()
PrintColorsByFamily prints colors organized by their color families. Useful for understanding the color system structure.
func SetBaseChartGlobalOptions ¶
func SetBaseChartGlobalOptions[T any](chart Chart[T], config BaseChartConfig)
Types ¶
type BaseChartConfig ¶
type BaseChartConfig struct {
Width string // Width of the chart (default "900px").
Height string // Height of the chart (default "500px").
BackgroundColor string // Background color of the chart (default "white").
Theme string // Theme of the chart.
Title string // Title of the chart.
Subtitle string // Subtitle of the chart.
TitlePos string // Title position: "top" or "bottom".
HideLegend bool // Whether to hide the legend.
LegendPos string // Legend position: "top" or "bottom".
}