Aggregate Functions
Graph and visualization
Generate data for graph and visualization purposes.
ClickHouse function reference
sparkbar
Generates a frequency histogram as an ASCII bar chart for a set of values and their repetition rates.
Syntax:
Alias:
- sparkBar
Arguments:
buckets
(UInt8
): The number of segments in the histogram.min_x
(numeric, optional): The start of the interval.max_x
(numeric, optional): The end of the interval.x
(numeric): The field containing the values.y
(numeric): The field containing the frequency of values.
Returns:
An ASCII bar chart representing the frequency histogram.
- The function plots a frequency histogram for values
x
and their repetition ratesy
over the interval [min_x
,max_x
]. - If no interval is specified, the minimum
x
value is used as the interval start, and the maximumx
value as the interval end. - Values outside the specified interval are ignored.
- Repetitions for all
x
falling into the same bucket are averaged, so data should be pre-aggregated. - Negative repetitions are ignored.
Example:
Result:
In this example, the sparkbar
function creates an ASCII bar chart showing the trend of taco sales over the 9-day period, divided into 9 buckets. Each character in the result represents the relative height of taco sales for that period.
Was this page helpful?