> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 이 함수는 구간 `[min_x, max_x]`에서 값 `x`와 해당 값의 반복 빈도 `y`에 대한 빈도 히스토그램을 그립니다.

# sparkbar

<div id="sparkbar">
  ## sparkbar
</div>

도입 버전: v21.11.0

이 함수는 값 `x`와 해당 값의 반복 빈도 `y`를 기준으로 인터벌 `[min_x, max_x]` 구간에 대한 빈도 히스토그램을 그립니다.
동일한 버킷에 속하는 모든 `x`의 반복 횟수는 평균값으로 계산되므로, 데이터는 미리 집계되어 있어야 합니다.
음수 반복 횟수는 무시됩니다.

인터벌을 지정하지 않으면 최소 `x`를 인터벌 시작점으로, 최대 `x`를 인터벌 끝점으로 사용합니다.
인터벌을 지정한 경우에는 해당 구간 밖의 값은 무시됩니다.

**구문**

```sql theme={null}
sparkbar(buckets[, min_x, max_x])(x, y)
```

**별칭**: `sparkBar`

**매개변수**

* `buckets` — 세그먼트 수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint)
* `min_x` — 선택 사항입니다. 인터벌 시작값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal`](/ko/reference/data-types/decimal)
* `max_x` — 선택 사항입니다. 인터벌 종료값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal`](/ko/reference/data-types/decimal)

**인수**

* `x` — 값이 들어 있는 필드입니다. [`const String`](/ko/reference/data-types/string)
* `y` — 값의 빈도가 들어 있는 필드입니다. [`const String`](/ko/reference/data-types/string)

**반환 값**

빈도 히스토그램을 반환합니다. [`String`](/ko/reference/data-types/string)

**예시**

**인터벌 지정 없이**

```sql title=Query theme={null}
CREATE TABLE spark_bar_data (`value` Int64, `event_date` Date) ENGINE = MergeTree ORDER BY event_date;

INSERT INTO spark_bar_data VALUES (1,'2020-01-01'), (3,'2020-01-02'), (4,'2020-01-02'), (-3,'2020-01-02'), (5,'2020-01-03'), (2,'2020-01-04'), (3,'2020-01-05'), (7,'2020-01-06'), (6,'2020-01-07'), (8,'2020-01-08'), (2,'2020-01-11');

SELECT sparkbar(9)(event_date, cnt) FROM (SELECT sum(value) AS cnt, event_date FROM spark_bar_data GROUP BY event_date);
```

```response title=Response theme={null}
┌─sparkbar(9)(event_date, cnt)─┐
│ ▂▅▂▃▆█  ▂                    │
└──────────────────────────────┘
```

**인터벌 지정 시**

```sql title=Query theme={null}
SELECT sparkbar(9, toDate('2020-01-01'), toDate('2020-01-10'))(event_date, cnt) FROM (SELECT sum(value) AS cnt, event_date FROM spark_bar_data GROUP BY event_date);
```

```response title=Response theme={null}
┌─sparkbar(9, toDate('2020-01-01'), toDate('2020-01-10'))(event_date, cnt)─┐
│ ▂▅▂▃▇▆█                                                                  │
└──────────────────────────────────────────────────────────────────────────┘
```
