KNOW IDEA UIv0.18.0GitHub

Chart

時系列の数値を、棒グラフか折れ線グラフで示す。通常はグレーの棒で、選択した 1 本だけをプライマリカラーにする。値は文字と表でも表示する。

tsx
import { Chart, Sparkline } from "knowidea-ui";

カテゴリ: Charts。

Demos

デモの数値はすべてサンプルであり、実際の値ではない。

Bars

クリックまたは矢印キーで選択すると、値と内訳が表示される。基準線には直接ラベルを付ける。値のない点は「記録なし」と表示する。

10 月 13 日35,701件

01万2万3万4万目標 25,0009/149/189/229/269/3010/410/810/12

10 月 13 日の内訳

  • A17,851
  • B10,710
  • C7,140
Show code
tsx
import { Chart, type ChartPoint } from "knowidea-ui";​const days = Array.from({ length: 30 }, (_, i) => {  const d = new Date(2026, 8, 14 + i);  const v = i === 16 ? null : 18000 + ((i * 7919) % 9000) + i * 450;  return {    key: `d${i}`,    label: `${d.getMonth() + 1}/${d.getDate()}`,    detail: `${d.getMonth() + 1} 月 ${d.getDate()} 日`,    value: v,    breakdown: v == null ? undefined : [{ label: "A", value: Math.round(v * 0.5) }, { label: "B", value: Math.round(v * 0.3) }, { label: "C", value: Math.round(v * 0.2) }],  } satisfies ChartPoint;});​function Bars() {  return <div style={{ width: "100%" }}><Chart data={days} unit="件" ariaLabel="日ごとの件数(棒)" reference={{ value: 25000, label: "目標 25,000" }} /></div>;}

Line

値のない点があると、線が途切れる。

10 月 13 日35,701件

01万2万3万4万9/3010/210/410/610/810/1010/123.6万

10 月 13 日の内訳

  • A17,851
  • B10,710
  • C7,140
Show code
tsx
import { Chart, type ChartPoint } from "knowidea-ui";​const days = Array.from({ length: 30 }, (_, i) => {  const d = new Date(2026, 8, 14 + i);  const v = i === 16 ? null : 18000 + ((i * 7919) % 9000) + i * 450;  return {    key: `d${i}`,    label: `${d.getMonth() + 1}/${d.getDate()}`,    detail: `${d.getMonth() + 1} 月 ${d.getDate()} 日`,    value: v,    breakdown: v == null ? undefined : [{ label: "A", value: Math.round(v * 0.5) }, { label: "B", value: Math.round(v * 0.3) }, { label: "C", value: Math.round(v * 0.2) }],  } satisfies ChartPoint;});​function Line() {  return <div style={{ width: "100%" }}><Chart type="line" data={days.slice(-14)} unit="件" ariaLabel="日ごとの件数(線)" breakdownTitle="内訳" /></div>;}

Sparkline

線と最後の点だけを描く。値は隣の数字が伝える。Stat の中でも使われる。

Show code
tsx
import { Sparkline } from "knowidea-ui";​function Tiny() {  return <Sparkline data={[3, 5, 4, 8, 7, 11, 12]} label="直近 7 日の推移" />;}

States

ローディングと空の表示を切り替えて確認できる。

10 月 13 日35,701

01万2万3万4万10/710/810/910/1010/1110/1210/13

10 月 13 日の内訳

  • A17,851
  • B10,710
  • C7,140
Show code
tsx
import { useState } from "react";import { Chart, Button, type ChartPoint } from "knowidea-ui";​const days = Array.from({ length: 30 }, (_, i) => {  const d = new Date(2026, 8, 14 + i);  const v = i === 16 ? null : 18000 + ((i * 7919) % 9000) + i * 450;  return {    key: `d${i}`,    label: `${d.getMonth() + 1}/${d.getDate()}`,    detail: `${d.getMonth() + 1} 月 ${d.getDate()} 日`,    value: v,    breakdown: v == null ? undefined : [{ label: "A", value: Math.round(v * 0.5) }, { label: "B", value: Math.round(v * 0.3) }, { label: "C", value: Math.round(v * 0.2) }],  } satisfies ChartPoint;});​function Toggle() {  const [kind, setKind] = useState<"ready" | "loading" | "empty">("ready");  return (    <div style={{ width: "100%", display: "grid", gap: "var(--space-3)" }}>      <div style={{ display: "flex", gap: "var(--space-2)", flexWrap: "wrap" }}>        {(["ready", "loading", "empty"] as const).map((k) => <Button key={k} variant={kind === k ? "primary" : "secondary"} onClick={() => setKind(k)}>{k}</Button>)}      </div>      <Chart data={days.slice(-7)} state={kind} ariaLabel="状態の切り替え" />    </div>  );}

States

すべてのコンポーネントが、Empty、Loading、Error、Disabled、Focus の 5 つの状態を備える。Hover と Active は、確認用に固定して表示している。そのコンポーネントにあてはまらない状態は「対象外」とし、理由を添える。

StateAppearance
Empty
記録なし
Loading
読み込み中
Error対象外。データを取得できなかったときは、グラフを描かず、近くの Alert で理由を示す
Disabled対象外。グラフは無効状態を持たない。値のない点は「記録なし」と表示する(上のデモの 9/30)
Focus

10 月 13 日35,701

01万2万3万4万10/710/810/910/1010/1110/1210/13

10 月 13 日の内訳

  • A17,851
  • B10,710
  • C7,140

棒に Tab で移り、矢印キーで選択を移動する。Home と End で先頭と末尾に移動する

API

NameTypeDefaultDescription
dataChartPoint[]-{ key, label, detail?, value: number | null, breakdown? }。null は値のない点
type"bar" | "line""bar"棒グラフか折れ線グラフか
ariaLabelstring-グラフの名前(スクリーンリーダー向け)。必須
unitstring-単位
heightnumber200軸の高さ(px)
reference{ value, label }-基準線。直接ラベルを付ける
selectedKey / defaultSelectedKey / onSelectstring / string / (key) => void-選択中の点(制御と非制御)
state"ready" | "loading" | "empty""ready"状態
emptyText / loadingText / breakdownTitlestring"記録なし" / "読み込み中" / "内訳"表示する文言
prevLabel / nextLabelstring"前の点" / "次の点"前後の点に移動するボタンの名前

CSS

Classes and data attributes

NameDescription
.ki-chart本体。data-state: loading | empty
.ki-chart__readout、__plot、__svg、__col、__bar、__dot、__line、__ref、__break内部の要素。__col[data-selected] が選択中の点

CSS variables

コンポーネントが参照するのは、役割を表す名前の変数だけで、素の値は参照しない。オーバーライドの方法は Overriding を参照。

VariableUsage
--color-line-strong、--color-primary、--color-primary-hover棒、選択中の棒、選択中かつホバー時の棒
--color-line、--color-text-muted目盛りの線と文字
--color-warn基準線
--font-mono数値と目盛りのフォント

Accessibility

KNOW IDEA UIv0.18.0

GitHub

ページと見出しを探す。/ か Ctrl K でどのページからも開く。

Code