Documentation
¶
Index ¶
- func ColorForIndex(idx int) lipgloss.Color
- func ComplianceColor(value, target float64) lipgloss.Color
- func RenderBarChart(w io.Writer, data *ChartData, opts ChartOptions) error
- func RenderChart(w io.Writer, data *ChartData, opts ChartOptions) error
- func RenderLineChart(w io.Writer, data *ChartData, opts ChartOptions) error
- func RenderPercentageBars(w io.Writer, title string, items []PercentageBarItem, opts ChartOptions) error
- type ChartData
- func FromLokiMetricResponse(resp *loki.MetricQueryResponse) (*ChartData, error)
- func FromLokiResponse(resp *loki.QueryResponse) (*ChartData, error)
- func FromPrometheusResponse(resp *prometheus.QueryResponse) (*ChartData, error)
- func FromPyroscopeResponse(resp *pyroscope.QueryResponse) (*ChartData, error)
- func FromPyroscopeSeriesResponse(resp *pyroscope.SelectSeriesResponse) (*ChartData, error)
- func FromTempoMetricsResponse(resp *tempo.MetricsResponse) (*ChartData, error)
- func FromTopSeriesResponse(resp *pyroscope.TopSeriesResponse) *ChartData
- type ChartOptions
- type PercentageBarItem
- type Point
- type Series
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorForIndex ¶
ColorForIndex returns the color for a given series index, cycling through the Grafana chart palette.
func ComplianceColor ¶
ComplianceColor returns a color reflecting how close value is to target. Both value and target are percentages (0–100).
func RenderBarChart ¶
func RenderBarChart(w io.Writer, data *ChartData, opts ChartOptions) error
RenderBarChart renders instant query data as a horizontal bar chart.
func RenderChart ¶
func RenderChart(w io.Writer, data *ChartData, opts ChartOptions) error
RenderChart auto-selects chart type based on data characteristics. For instant queries (single point per series at same timestamp), uses bar chart. For range queries (multiple points over time), uses line chart.
func RenderLineChart ¶
func RenderLineChart(w io.Writer, data *ChartData, opts ChartOptions) error
RenderLineChart renders a line chart to the writer.
func RenderPercentageBars ¶
func RenderPercentageBars(w io.Writer, title string, items []PercentageBarItem, opts ChartOptions) error
RenderPercentageBars renders labeled horizontal bars scaled 0–100%. Each item gets a line: name, filled/unfilled bar, value, and optional target.
Types ¶
type ChartData ¶
ChartData represents data ready to be rendered as a chart.
func FromLokiMetricResponse ¶ added in v0.2.2
func FromLokiMetricResponse(resp *loki.MetricQueryResponse) (*ChartData, error)
FromLokiMetricResponse converts a Loki metric query response (time-series) to ChartData.
func FromLokiResponse ¶
func FromLokiResponse(resp *loki.QueryResponse) (*ChartData, error)
FromLokiResponse converts a Loki query response to ChartData.
func FromPrometheusResponse ¶
func FromPrometheusResponse(resp *prometheus.QueryResponse) (*ChartData, error)
FromPrometheusResponse converts a Prometheus query response to ChartData.
func FromPyroscopeResponse ¶
func FromPyroscopeResponse(resp *pyroscope.QueryResponse) (*ChartData, error)
FromPyroscopeResponse converts a Pyroscope query response to ChartData for visualization. It extracts the top functions by self-time and renders them as a horizontal bar chart.
func FromPyroscopeSeriesResponse ¶ added in v0.2.0
func FromPyroscopeSeriesResponse(resp *pyroscope.SelectSeriesResponse) (*ChartData, error)
FromPyroscopeSeriesResponse converts a SelectSeries response to ChartData for time-series visualization.
func FromTempoMetricsResponse ¶ added in v0.2.2
func FromTempoMetricsResponse(resp *tempo.MetricsResponse) (*ChartData, error)
FromTempoMetricsResponse converts a Tempo metrics query response to ChartData.
func FromTopSeriesResponse ¶ added in v0.2.0
func FromTopSeriesResponse(resp *pyroscope.TopSeriesResponse) *ChartData
FromTopSeriesResponse converts a TopSeriesResponse to ChartData for bar chart visualization.
func (*ChartData) IsInstantQuery ¶
IsInstantQuery returns true if all series have exactly one data point at the same timestamp (typical of Prometheus instant/vector queries).
type ChartOptions ¶
type ChartOptions struct {
Width int
Height int
Title string
TextOnly bool
MaxValue *float64 // Optional max value for bar charts (e.g., 100 for percentages)
}
ChartOptions configures chart rendering.
func DefaultChartOptions ¶
func DefaultChartOptions() ChartOptions
DefaultChartOptions returns default chart options.
type PercentageBarItem ¶
type PercentageBarItem struct {
Name string // Label shown to the left of the bar
Value float64 // Current value as percentage (0–100)
Target float64 // Target/objective as percentage (0–100); 0 means no target
}
PercentageBarItem represents a single item in a percentage bar chart.