ingred-ui 33.13.0 → 33.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  export { default as BarChart } from "./BarChart";
2
- export type { BarChartLayout, BarChartProps } from "./types";
2
+ export type { BarChartLayout, BarChartProps, BarChartValueScale, } from "./types";
3
3
  export type { ChartSeries } from "../types";
@@ -1,5 +1,6 @@
1
1
  import { BarChartOrientation, ChartSeries } from "../types";
2
2
  export type BarChartLayout = "single" | "grouped" | "stacked";
3
+ export type BarChartValueScale = "absolute" | "percent";
3
4
  export type BarChartProps = {
4
5
  /** X 軸のカテゴリラベル(horizontal 時は Y 軸) */
5
6
  categories: string[];
@@ -11,6 +12,11 @@ export type BarChartProps = {
11
12
  * - stacked: 系列を積み上げて構成比を比較
12
13
  */
13
14
  layout?: BarChartLayout;
15
+ /**
16
+ * stacked 時の値スケール。percent はカテゴリごとに系列を 100% 積み上げ表示する。
17
+ * grouped / single では無視され absolute として描画する。
18
+ */
19
+ valueScale?: BarChartValueScale;
14
20
  /** vertical: 棒が上向き / horizontal: 棒が右向き。デフォルト vertical */
15
21
  orientation?: BarChartOrientation;
16
22
  /**
@@ -18,7 +24,7 @@ export type BarChartProps = {
18
24
  * 未指定時は palette.chart.series(デフォルト)を使う。
19
25
  */
20
26
  colorScheme?: string;
21
- /** 軸・tooltip の数値表示。未指定時は toLocaleString() */
27
+ /** 軸・tooltip の数値表示。未指定時は absolute なら toLocaleString()、percent なら `12.3%` 形式 */
22
28
  valueFormatter?: (value: number) => string;
23
29
  /** 系列が 2 本以上のとき凡例を表示。デフォルト true */
24
30
  showLegend?: boolean;
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import { LineChartProps } from "./types";
3
+ declare const LineChart: React.FC<LineChartProps>;
4
+ export default LineChart;
@@ -0,0 +1,2 @@
1
+ export { default as LineChart } from "./LineChart";
2
+ export type { LineChartProps } from "./types";
@@ -0,0 +1,27 @@
1
+ import { ChartSeries } from "../types";
2
+ export type LineChartProps = {
3
+ /** X 軸のカテゴリラベル */
4
+ categories: string[];
5
+ /** 1 本以上のデータ系列(BarChart / LineChart 共通) */
6
+ series: ChartSeries[];
7
+ /**
8
+ * theme.palette.chart.colorSchemes のキー。
9
+ * 未指定時は palette.chart.series(デフォルト)を使う。
10
+ */
11
+ colorScheme?: string;
12
+ /** 軸・tooltip の数値表示。未指定時は toLocaleString() */
13
+ valueFormatter?: (value: number) => string;
14
+ /** 系列が 2 本以上のとき凡例を表示。デフォルト true */
15
+ showLegend?: boolean;
16
+ /** データ点にマーカーを表示。デフォルト true */
17
+ showPoints?: boolean;
18
+ /** 凡例クリックで系列の表示/非表示を切り替え。デフォルト true */
19
+ interactiveLegend?: boolean;
20
+ /** true の間、チャートの代わりにローディング表示 */
21
+ loading?: boolean;
22
+ /** 描画可能なデータがないときのメッセージ。未指定時は「データがありません」 */
23
+ emptyMessage?: string;
24
+ "aria-label": string;
25
+ height?: number;
26
+ className?: string;
27
+ };
@@ -1,8 +1,14 @@
1
1
  export { BarChart } from "./BarChart";
2
- export type { BarChartLayout, BarChartProps } from "./BarChart";
2
+ export type { BarChartLayout, BarChartProps, BarChartValueScale, } from "./BarChart";
3
+ export { LineChart } from "./LineChart";
4
+ export type { LineChartProps } from "./LineChart";
3
5
  export type { BarSegment, BarChartOrientation, ChartHoverState, ChartSeries, ResolvedChartSeries, } from "./types";
6
+ export type { LinePoint, LinePathSegment, LineSeriesGeometry, } from "./internal/getLineSeries";
4
7
  export { computeYTicks, computeMaxStackedTotal } from "./internal/utils";
8
+ export { formatChartPercentValue, normalizeStackedSeriesToPercent, } from "./internal/utils";
5
9
  export { hasChartData } from "./internal/hasChartData";
10
+ export { hasLineChartData } from "./internal/hasLineChartData";
11
+ export { computeLineChartMaxValue, getLinePathSegments, getLineSeriesGeometry, pathFromPoints, } from "./internal/getLineSeries";
6
12
  export { formatDateAsMonthDay, mapTimeSeriesChartData, } from "./internal/mapTimeSeriesChartData";
7
13
  export type { TimeSeriesDataset, TimeSeriesPoint, } from "./internal/mapTimeSeriesChartData";
8
14
  export { CHART_DEFAULT_HEIGHT } from "./internal/getChartLayout";
@@ -0,0 +1,29 @@
1
+ import * as React from "react";
2
+ import { LinePathSegment, LinePoint } from "./getLineSeries";
3
+ type ChartLineSeriesProps = {
4
+ segments: LinePathSegment[];
5
+ points: LinePoint[];
6
+ showPoints: boolean;
7
+ strokeWidth: number;
8
+ pointRadius: number;
9
+ hidden: boolean;
10
+ };
11
+ export declare const ChartLineSeries: React.FC<ChartLineSeriesProps>;
12
+ type ChartCategoryHoverTargetsProps = {
13
+ categoryCount: number;
14
+ paddingLeft: number;
15
+ paddingTop: number;
16
+ slotWidth: number;
17
+ chartHeight: number;
18
+ onPointerMove: (event: React.PointerEvent<SVGRectElement>, categoryIndex: number) => void;
19
+ onPointerLeave: () => void;
20
+ };
21
+ export declare const ChartCategoryHoverTargets: React.FC<ChartCategoryHoverTargetsProps>;
22
+ type ChartCrosshairProps = {
23
+ x: number;
24
+ paddingTop: number;
25
+ chartHeight: number;
26
+ color: string;
27
+ };
28
+ export declare const ChartCrosshair: React.FC<ChartCrosshairProps>;
29
+ export {};
@@ -5,6 +5,6 @@ export type TooltipPosition = {
5
5
  };
6
6
  /**
7
7
  * カーソル追従 tooltip を viewport 内に収める。
8
- * 上方向に十分なスペースがなければ下方向に反転する。
8
+ * 棒グラフの視認性のため左右を優先し、収まらない場合のみ上下に表示する。
9
9
  */
10
10
  export declare function clampTooltipPosition(clientX: number, clientY: number, tooltipWidth: number, tooltipHeight: number, viewportWidth: number, viewportHeight: number, padding?: number, offset?: number): TooltipPosition;
@@ -0,0 +1,28 @@
1
+ import { ResolvedChartSeries } from "../types";
2
+ import { ChartLayout } from "./getChartLayout";
3
+ export type LinePoint = {
4
+ seriesLabel: string;
5
+ color: string;
6
+ value: number;
7
+ x: number;
8
+ y: number;
9
+ categoryIndex: number;
10
+ };
11
+ export type LinePathSegment = {
12
+ seriesLabel: string;
13
+ color: string;
14
+ points: LinePoint[];
15
+ d: string;
16
+ };
17
+ export type LineSeriesGeometry = {
18
+ segments: LinePathSegment[];
19
+ points: LinePoint[];
20
+ };
21
+ /** Y 軸は 0 起点。負の値を含む場合のスケール調整は未対応。 */
22
+ export declare function computeLineChartMaxValue(series: readonly Pick<ResolvedChartSeries, "data">[]): number;
23
+ export declare function getCategoryCenterX(categoryIndex: number, chartLayout: Pick<ChartLayout, "paddingLeft" | "slotWidth">): number;
24
+ export declare function getValueY(value: number, maxValue: number, chartLayout: Pick<ChartLayout, "paddingTop" | "chartHeight">): number;
25
+ export declare function pathFromPoints(points: readonly LinePoint[]): string;
26
+ export declare function getLinePathSegments(item: ResolvedChartSeries, chartLayout: ChartLayout, maxValue: number): LinePathSegment[];
27
+ export declare function getLineSeriesGeometry(item: ResolvedChartSeries, chartLayout: ChartLayout, maxValue: number): LineSeriesGeometry;
28
+ export declare function getLinePoints(item: ResolvedChartSeries, chartLayout: ChartLayout, maxValue: number): LinePoint[];
@@ -0,0 +1,3 @@
1
+ import { ChartSeries } from "../types";
2
+ /** categories / series に null 以外の値が存在するか(0 以下も有効) */
3
+ export declare function hasLineChartData(categories: readonly string[], series: readonly ChartSeries[]): boolean;
@@ -1 +1,2 @@
1
1
  export { computeMaxStackedTotal, computeYTicks } from "./scale";
2
+ export { formatChartPercentValue, getStackedPercentMaxValue, normalizeStackedSeriesToPercent, } from "./normalizeStackedSeries";
@@ -0,0 +1,9 @@
1
+ import { ResolvedChartSeries } from "../../types";
2
+ /** 軸・tooltip 用のパーセント表示。小数第 1 位まで。 */
3
+ export declare function formatChartPercentValue(value: number): string;
4
+ /**
5
+ * stacked 系列をカテゴリごとに 0–100% に正規化する。
6
+ * null は維持し、0 以下は null として扱う(BarChart の棒描画ルールに合わせる)。
7
+ */
8
+ export declare function normalizeStackedSeriesToPercent(series: readonly Pick<ResolvedChartSeries, "label" | "color" | "data">[]): ResolvedChartSeries[];
9
+ export declare function getStackedPercentMaxValue(): number;
@@ -1,8 +1,13 @@
1
1
  export type ChartSeries = {
2
2
  /** 系列ごとに一意のラベル(凡例・表示切替のキー) */
3
3
  label: string;
4
- /** null および 0 以下の値は棒として描画しない */
4
+ /**
5
+ * - BarChart: null および 0 以下は棒として描画しない
6
+ * - LineChart: null で線を途切れさせる。0 は有効(Y 軸は 0 起点、負の値のスケールは未対応)
7
+ */
5
8
  data: (number | null)[];
9
+ /** 未指定時は theme.palette.chart の系列色を使う */
10
+ color?: string;
6
11
  };
7
12
  export type BarChartLayout = "single" | "grouped" | "stacked";
8
13
  /** vertical: カテゴリが X 軸 / horizontal: カテゴリが Y 軸 */