GraphicRenderer
GraphicRendererは、Graphic Walkerの仕様から事前設定されたチャートをレンダリングします。完全な編集インターフェースなしでチャートを表示し、ユーザーはチャートの閲覧とインタラクションはできますが、フィールドエンコーディングの変更はできません。
import { GraphicRenderer } from '@kanaries/graphic-walker';使い分け
| コンポーネント | 使用する場面 |
|---|---|
GraphicWalker | 完全なドラッグ&ドロップ探索インターフェースが必要な場合 |
GraphicRenderer | ツールバーコントロールを表示した状態で保存済みチャートを表示したい場合 |
PureRenderer | UIクロムなしの最小限の読み取り専用チャートが必要な場合 |
プロパティ
GraphicRendererはGraphicWalkerと同じすべてのプロパティに加え、以下を受け付けます:
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
containerClassName | string | undefined | チャートコンテナのCSSクラス。 |
containerStyle | React.CSSProperties | undefined | チャートコンテナのインラインスタイル。 |
overrideSize | { mode: 'auto' | 'fixed' | 'full'; width: number; height: number } | undefined | 仕様からのチャートサイズをオーバーライド。 |
GraphicWalkerのすべてのデータ、外観、i18n、refプロパティもここで適用されます。
使用例
import { GraphicRenderer } from '@kanaries/graphic-walker';
import type { IChart } from '@kanaries/graphic-walker';
const savedCharts: IChart[] = [
{
visId: 'chart-1',
name: 'Monthly Revenue',
encodings: {
dimensions: [],
measures: [],
rows: [{ fid: 'revenue', name: 'Revenue', analyticType: 'measure', semanticType: 'quantitative' }],
columns: [{ fid: 'month', name: 'Month', analyticType: 'dimension', semanticType: 'temporal' }],
color: [],
opacity: [],
size: [],
shape: [],
theta: [],
radius: [],
longitude: [],
latitude: [],
geoId: [],
details: [],
filters: [],
text: [],
},
config: {
defaultAggregated: true,
geoms: ['line'],
coordSystem: 'generic',
limit: -1,
},
layout: {
showTableSummary: false,
stack: 'none',
showActions: false,
interactiveScale: true,
zeroScale: true,
size: { mode: 'auto', width: 800, height: 400 },
format: {},
resolve: {},
},
},
];
function Dashboard() {
return (
<GraphicRenderer
data={data}
fields={fields}
chart={savedCharts}
appearance="media"
/>
);
}固定サイズ
<GraphicRenderer
data={data}
fields={fields}
chart={savedCharts}
overrideSize={{ mode: 'fixed', width: 600, height: 400 }}
/>