Documentation
¶
Index ¶
- type BarChart
- func (c *BarChart) AddSeries(name string, data []float64) Chart
- func (c *BarChart) Render() string
- func (c *BarChart) SetAutoHeight(auto bool) Chart
- func (c *BarChart) SetColors(colors []string) Chart
- func (c *BarChart) SetData(data []float64) Chart
- func (c *BarChart) SetHorizontal(horizontal bool) *BarChart
- func (c *BarChart) SetLabels(labels []string) Chart
- func (c *BarChart) SetLegendWidth(percentage float64) Chart
- func (c *BarChart) SetPalette(palette string) Chart
- func (c *BarChart) SetSeriesColors(colors []string) Chart
- func (c *BarChart) SetSize(width, height int) Chart
- func (c *BarChart) SetStacked(stacked bool) *BarChart
- func (c *BarChart) SetTitle(title string) Chart
- type BaseChart
- func (chart *BaseChart) EnableDarkModeSupport(enable bool) *BaseChart
- func (chart *BaseChart) SetDarkTheme(backgroundColor, textColor, axisColor, gridColor string) *BaseChart
- func (chart *BaseChart) SetLegendWidth(percentage float64) *BaseChart
- func (chart *BaseChart) SetLightTheme(backgroundColor, textColor, axisColor, gridColor string) *BaseChart
- func (chart *BaseChart) SetPalette(palette string) *BaseChart
- type Chart
- type HeatmapChart
- func (c *HeatmapChart) AddSeries(name string, data []float64) Chart
- func (c *HeatmapChart) EnableNegativeValues(enable bool) *HeatmapChart
- func (c *HeatmapChart) Render() string
- func (c *HeatmapChart) SetAutoHeight(auto bool) Chart
- func (c *HeatmapChart) SetCellRounding(radius int) *HeatmapChart
- func (c *HeatmapChart) SetCellSize(size int) *HeatmapChart
- func (c *HeatmapChart) SetCellSpacing(spacing int) *HeatmapChart
- func (c *HeatmapChart) SetColors(colors []string) Chart
- func (c *HeatmapChart) SetData(data []float64) Chart
- func (c *HeatmapChart) SetDateFormat(format string) *HeatmapChart
- func (c *HeatmapChart) SetDayLabels(labels []string) *HeatmapChart
- func (c *HeatmapChart) SetLabels(labels []string) Chart
- func (c *HeatmapChart) SetLegendWidth(percentage float64) Chart
- func (c *HeatmapChart) SetMaxValue(max float64) *HeatmapChart
- func (c *HeatmapChart) SetMinValue(min float64) *HeatmapChart
- func (c *HeatmapChart) SetMonthLabels(labels []string) *HeatmapChart
- func (c *HeatmapChart) SetNegativeColors(colors []string) *HeatmapChart
- func (c *HeatmapChart) SetPalette(palette string) Chart
- func (c *HeatmapChart) SetSeriesColors(colors []string) Chart
- func (c *HeatmapChart) SetSize(width, height int) Chart
- func (c *HeatmapChart) SetTitle(title string) Chart
- type LineChart
- func (c *LineChart) AddSeries(name string, data []float64) Chart
- func (c *LineChart) Render() string
- func (c *LineChart) SetAutoHeight(auto bool) Chart
- func (c *LineChart) SetColors(colors []string) Chart
- func (c *LineChart) SetData(data []float64) Chart
- func (c *LineChart) SetLabels(labels []string) Chart
- func (c *LineChart) SetLegendWidth(percentage float64) Chart
- func (c *LineChart) SetPalette(palette string) Chart
- func (c *LineChart) SetSeriesColors(colors []string) Chart
- func (c *LineChart) SetSize(width, height int) Chart
- func (c *LineChart) SetSmooth(smooth bool) *LineChart
- func (c *LineChart) SetTitle(title string) Chart
- func (c *LineChart) ShowDataPoints(show bool) *LineChart
- type PieChart
- func (c *PieChart) AddSeries(name string, data []float64) Chart
- func (c *PieChart) EnableTooltips(enable bool) *PieChart
- func (c *PieChart) Render() string
- func (c *PieChart) SetAutoHeight(auto bool) Chart
- func (c *PieChart) SetColors(colors []string) Chart
- func (c *PieChart) SetData(data []float64) Chart
- func (c *PieChart) SetDonutHole(percentage float64) *PieChart
- func (c *PieChart) SetLabels(labels []string) Chart
- func (c *PieChart) SetLegendWidth(percentage float64) Chart
- func (c *PieChart) SetMaxLabelLength(length int) *PieChart
- func (c *PieChart) SetPalette(palette string) Chart
- func (c *PieChart) SetSeriesColors(colors []string) Chart
- func (c *PieChart) SetSize(width, height int) Chart
- func (c *PieChart) SetTitle(title string) Chart
- type Series
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BarChart ¶
BarChart implements a bar chart
func NewBarChart ¶
func NewBarChart() *BarChart
NewBarChart creates a new bar chart with default settings
func (*BarChart) SetAutoHeight ¶ added in v0.5.0
SetAutoHeight enables automatic height calculation based on width
func (*BarChart) SetHorizontal ¶
SetHorizontal displays bars horizontally
func (*BarChart) SetLegendWidth ¶ added in v0.9.0
SetLegendWidth sets the width of the legend area as a percentage of the chart width
func (*BarChart) SetPalette ¶ added in v0.9.3
SetPalette sets the color palette mode for automatic color assignment
func (*BarChart) SetSeriesColors ¶ added in v0.8.0
SetSeriesColors sets the colors for multiple data series
func (*BarChart) SetStacked ¶
SetStacked stacks multiple data series
type BaseChart ¶
type BaseChart struct {
ChartType string
Title string
Width int
Height int
AutoHeight bool
Data []float64
Labels []string
Colors []string
// New fields for multiple series support
Series []Series
SeriesColors []string
ShowTitle bool
ShowLegend bool
LegendWidth float64 // Percentage of chart width (0.0-0.5) reserved for legend
Palette string // "auto" or "gradient" for automatic color assignment
Margin struct {
Top int
Right int
Bottom int
Left int
}
BackgroundColor string
DarkModeSupport bool
DarkTheme struct {
BackgroundColor string
TextColor string
AxisColor string
GridColor string
}
LightTheme struct {
BackgroundColor string
TextColor string
AxisColor string
GridColor string
}
}
BaseChart contains common properties and methods for all chart types
func (*BaseChart) EnableDarkModeSupport ¶ added in v0.5.0
EnableDarkModeSupport enables automatic adaptation between light and dark mode based on the user's system preferences
func (*BaseChart) SetDarkTheme ¶ added in v0.5.0
func (chart *BaseChart) SetDarkTheme(backgroundColor, textColor, axisColor, gridColor string) *BaseChart
SetDarkTheme sets the color scheme for dark mode
func (*BaseChart) SetLegendWidth ¶ added in v0.9.0
SetLegendWidth sets the width of the legend area as a percentage of the chart width
func (*BaseChart) SetLightTheme ¶ added in v0.5.0
func (chart *BaseChart) SetLightTheme(backgroundColor, textColor, axisColor, gridColor string) *BaseChart
SetLightTheme sets the color scheme for light mode
func (*BaseChart) SetPalette ¶ added in v0.9.3
SetPalette sets the color palette mode for automatic color assignment Valid options are "auto" and "gradient"
type Chart ¶
type Chart interface {
SetTitle(title string) Chart
SetSize(width, height int) Chart
SetAutoHeight(auto bool) Chart
SetData(data []float64) Chart
SetLabels(labels []string) Chart
SetColors(colors []string) Chart
// New methods for multiple series support
AddSeries(name string, data []float64) Chart
SetSeriesColors(colors []string) Chart
// Layout control
SetLegendWidth(percentage float64) Chart
// Color management
SetPalette(palette string) Chart
Render() string
}
Chart is the interface that all chart types must implement
type HeatmapChart ¶ added in v0.4.0
type HeatmapChart struct {
BaseChart
CellSize int // Size of each cell in pixels
CellSpacing int // Spacing between cells in pixels
CellRounding int // Corner radius of cells
DateFormat string // Date format string
DayLabels []string // Labels for days of week (Sunday-Saturday)
MonthLabels []string // Labels for months
MaxValue float64 // Maximum value for color scaling (0 for auto)
MinValue float64 // Minimum value for color scaling (0 for auto)
NegativeColors []string // Colors for negative values (from least to most intense)
SupportNegative bool // Whether to support negative values
}
HeatmapChart implements a heatmap chart similar to GitHub's activity heatmap
func NewHeatmapChart ¶ added in v0.4.0
func NewHeatmapChart() *HeatmapChart
NewHeatmapChart creates a new heatmap chart with default settings
func (*HeatmapChart) AddSeries ¶ added in v0.8.0
func (c *HeatmapChart) AddSeries(name string, data []float64) Chart
AddSeries adds a new data series to the heatmap chart Note: Heatmap charts typically don't support multiple series in the same way as line/bar charts This implementation will replace the existing data with the new series
func (*HeatmapChart) EnableNegativeValues ¶ added in v0.10.0
func (c *HeatmapChart) EnableNegativeValues(enable bool) *HeatmapChart
EnableNegativeValues enables or disables negative value support
func (*HeatmapChart) Render ¶ added in v0.4.0
func (c *HeatmapChart) Render() string
Render renders the heatmap chart to an SVG string
func (*HeatmapChart) SetAutoHeight ¶ added in v0.5.0
func (c *HeatmapChart) SetAutoHeight(auto bool) Chart
SetAutoHeight enables automatic height calculation based on width
func (*HeatmapChart) SetCellRounding ¶ added in v0.4.0
func (c *HeatmapChart) SetCellRounding(radius int) *HeatmapChart
SetCellRounding sets the corner radius of cells
func (*HeatmapChart) SetCellSize ¶ added in v0.4.0
func (c *HeatmapChart) SetCellSize(size int) *HeatmapChart
SetCellSize sets the size of each cell in pixels
func (*HeatmapChart) SetCellSpacing ¶ added in v0.4.0
func (c *HeatmapChart) SetCellSpacing(spacing int) *HeatmapChart
SetCellSpacing sets the spacing between cells in pixels
func (*HeatmapChart) SetColors ¶ added in v0.4.0
func (c *HeatmapChart) SetColors(colors []string) Chart
SetColors sets the color palette as hex values (from least to most intense)
func (*HeatmapChart) SetData ¶ added in v0.4.0
func (c *HeatmapChart) SetData(data []float64) Chart
SetData sets the chart data values
func (*HeatmapChart) SetDateFormat ¶ added in v0.4.0
func (c *HeatmapChart) SetDateFormat(format string) *HeatmapChart
SetDateFormat sets the date format string (Go time format)
func (*HeatmapChart) SetDayLabels ¶ added in v0.4.0
func (c *HeatmapChart) SetDayLabels(labels []string) *HeatmapChart
SetDayLabels sets the labels for days of the week Note: This method is deprecated as single-letter day labels are now used by default
func (*HeatmapChart) SetLabels ¶ added in v0.4.0
func (c *HeatmapChart) SetLabels(labels []string) Chart
SetLabels sets the chart labels (should be ISO dates: YYYY-MM-DD)
func (*HeatmapChart) SetLegendWidth ¶ added in v0.9.0
func (c *HeatmapChart) SetLegendWidth(percentage float64) Chart
SetLegendWidth sets the width of the legend area as a percentage of the chart width
func (*HeatmapChart) SetMaxValue ¶ added in v0.4.0
func (c *HeatmapChart) SetMaxValue(max float64) *HeatmapChart
SetMaxValue sets the maximum value for color scaling
func (*HeatmapChart) SetMinValue ¶ added in v0.10.0
func (c *HeatmapChart) SetMinValue(min float64) *HeatmapChart
SetMinValue sets the minimum value for color scaling
func (*HeatmapChart) SetMonthLabels ¶ added in v0.4.0
func (c *HeatmapChart) SetMonthLabels(labels []string) *HeatmapChart
SetMonthLabels sets the labels for months
func (*HeatmapChart) SetNegativeColors ¶ added in v0.10.0
func (c *HeatmapChart) SetNegativeColors(colors []string) *HeatmapChart
SetNegativeColors sets the color palette for negative values (from least to most intense)
func (*HeatmapChart) SetPalette ¶ added in v0.9.3
func (c *HeatmapChart) SetPalette(palette string) Chart
SetPalette sets the color palette mode for automatic color assignment
func (*HeatmapChart) SetSeriesColors ¶ added in v0.8.0
func (c *HeatmapChart) SetSeriesColors(colors []string) Chart
SetSeriesColors sets the colors for multiple data series For heatmaps, this is the same as SetColors
func (*HeatmapChart) SetSize ¶ added in v0.4.0
func (c *HeatmapChart) SetSize(width, height int) Chart
SetSize sets the chart dimensions in pixels
func (*HeatmapChart) SetTitle ¶ added in v0.4.0
func (c *HeatmapChart) SetTitle(title string) Chart
SetTitle sets the chart title
type LineChart ¶
LineChart implements a line chart
func NewLineChart ¶
func NewLineChart() *LineChart
NewLineChart creates a new line chart with default settings
func (*LineChart) SetAutoHeight ¶ added in v0.5.0
SetAutoHeight enables automatic height calculation based on width
func (*LineChart) SetLegendWidth ¶ added in v0.9.0
SetLegendWidth sets the width of the legend area as a percentage of the chart width
func (*LineChart) SetPalette ¶ added in v0.9.3
SetPalette sets the color palette mode for automatic color assignment
func (*LineChart) SetSeriesColors ¶ added in v0.8.0
SetSeriesColors sets the colors for multiple data series
func (*LineChart) ShowDataPoints ¶
ShowDataPoints shows or hides data points for line charts
type PieChart ¶
type PieChart struct {
BaseChart
DonutHolePercentage float64
MaxLabelLength int // Maximum label length before truncation
ShowTooltips bool // Show tooltips on hover for truncated labels
}
PieChart implements a pie/donut chart
func NewPieChart ¶
func NewPieChart() *PieChart
NewPieChart creates a new pie chart with default settings
func (*PieChart) AddSeries ¶ added in v0.8.0
AddSeries adds a new data series to the pie chart Note: Pie charts typically don't support multiple series in the same way as line/bar charts This implementation will replace the existing data with the new series
func (*PieChart) EnableTooltips ¶ added in v0.5.1
EnableTooltips enables or disables tooltips for labels
func (*PieChart) SetAutoHeight ¶ added in v0.5.0
SetAutoHeight enables automatic height calculation based on width
func (*PieChart) SetDonutHole ¶
SetDonutHole sets the inner circle size for donut charts
func (*PieChart) SetLegendWidth ¶ added in v0.9.0
SetLegendWidth sets the width of the legend area as a percentage of the chart width
func (*PieChart) SetMaxLabelLength ¶ added in v0.5.1
SetMaxLabelLength sets the maximum length for labels before truncation
func (*PieChart) SetPalette ¶ added in v0.9.3
SetPalette sets the color palette mode for automatic color assignment
func (*PieChart) SetSeriesColors ¶ added in v0.8.0
SetSeriesColors sets the colors for multiple data series For pie charts, this is the same as SetColors
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
examples
command
|
|
|
mdchart
command
|
|
|
mdchartserver
command
|
|
|
examples
|
|
|
feedback_heatmap
command
Example showing a heatmap with positive and negative values for feedback
|
Example showing a heatmap with positive and negative values for feedback |
|
multiple_series_example
command
Example of multiple series support in GoSVGChart
|
Example of multiple series support in GoSVGChart |
|
examples
command
|
|