Skip to content
GRAPHIC WALKER
API Reference
GraphicWalker

GraphicWalker

GraphicWalker is the primary component that provides a full interactive data exploration interface with drag-and-drop chart building, field management, and multiple chart tabs.

import { GraphicWalker } from '@kanaries/graphic-walker';

Props

Data Props

PropTypeRequiredDescription
dataRecord<string, any>[]Yes*Array of data records. Used for client-side computation.
fieldsIMutField[]YesField definitions describing each column in your data.
computationIComputationFunctionYes*Server-side computation function. Alternative to data.
computationTimeoutnumberNoTimeout in ms for computation requests.

*Provide either data (client-side) or computation (server-side), not both.

Chart Configuration Props

PropTypeDefaultDescription
chartIChart[]undefinedPre-configured chart specifications to load.
defaultConfig{ config?: Partial<IVisualConfigNew>; layout?: Partial<IVisualLayout> }undefinedDefault config applied to new charts.
defaultRenderer'vega-lite' | 'observable-plot''vega-lite'Default rendering engine for new charts.

Appearance Props

PropTypeDefaultDescription
appearance'media' | 'light' | 'dark''media'Dark mode setting. 'media' follows system preference.
vizThemeConfigIThemeKey | GWGlobalConfigundefinedChart rendering theme. Built-in options: 'vega', 'g2', 'streamlit'.
uiThemeIUIThemeConfigundefinedCustom UI color scheme for light and dark modes.

UI Control Props

PropTypeDefaultDescription
hideChartNavbooleanfalseHide the chart tab navigation, restricting to a single chart.
hideSegmentNavbooleanfalseHide the data/visualization segment navigation.
hideProfilingbooleanfalseHide field profiling (distribution previews).
toolbar{ extra?: ToolbarItemProps[]; exclude?: string[] }undefinedCustomize the toolbar — add extra buttons or exclude built-in ones.

Data Features Props

PropTypeDefaultDescription
scalesIChannelScalesundefinedCustom scale configurations for visual channels.
geographicDataIGeographicData & { key: string }undefinedGeoJSON/TopoJSON data for geographic visualizations.
geoListIGeoDataItem[]undefinedList of geographic datasets available for selection.
experimentalFeatures{ computedField?: boolean }undefinedEnable experimental features like computed fields.

i18n Props

PropTypeDefaultDescription
i18nLangstringundefinedLanguage code (e.g., 'en-US', 'zh-CN', 'ja-JP').
i18nResourcesRecord<string, Record<string, string>>undefinedCustom translation resources.

Ref & State Props

PropTypeDescription
refReact.Ref<IGWHandler>Ref to access the handler API (export charts, navigate tabs, etc.).
storeRefReact.RefObject<CommonStore>Ref to the internal state store.
keepAliveboolean | stringKeep component state alive when unmounted. Pass a string as a unique key for multiple instances.
onMetaChange(fid: string, meta: Partial<IMutField>) => voidCallback when field metadata changes.

Error Handling

PropTypeDescription
onError(err: Error) => voidCallback for error handling.

Styling

PropTypeDescription
classNamestringCSS class applied to the root element.
styleReact.CSSPropertiesInline styles applied to the root element.

Ref Handler (IGWHandler)

Access the handler via a React ref to control the component programmatically:

import { useRef } from 'react';
import { GraphicWalker } from '@kanaries/graphic-walker';
import type { IGWHandler } from '@kanaries/graphic-walker';
 
function App() {
  const gwRef = useRef<IGWHandler>(null);
 
  return <GraphicWalker ref={gwRef} data={data} fields={fields} />;
}

Handler Properties and Methods

MemberTypeDescription
chartCountnumberTotal number of chart tabs.
chartIndexnumberCurrently selected chart tab index.
openChart(index)(index: number) => voidSwitch to a specific chart tab.
renderStatus'computing' | 'rendering' | 'idle' | 'error'Current render status of the active chart.
onRenderStatusChange(cb)(cb: Function) => () => voidListen for render status changes. Returns a dispose function.
exportChart(mode?)(mode?: 'svg' | 'data-url') => Promise<IChartExportResult>Export the current chart. Defaults to 'svg'.
exportChartList(mode?)(mode?: 'svg' | 'data-url') => AsyncGeneratorAsync generator that yields each chart's export data.

Export Example

async function handleExport() {
  if (!gwRef.current) return;
 
  // Export current chart as SVG
  const result = await gwRef.current.exportChart('svg');
  console.log(result.title, result.charts);
 
  // Export all charts
  for await (const item of gwRef.current.exportChartList('data-url')) {
    console.log(`Chart ${item.index + 1}/${item.total}:`, item.data.title);
  }
}

Examples

Basic Explorer

import { GraphicWalker } from '@kanaries/graphic-walker';
 
function Explorer({ data, fields }) {
  return <GraphicWalker data={data} fields={fields} />;
}

With Dark Mode and Theme

<GraphicWalker
  data={data}
  fields={fields}
  appearance="dark"
  vizThemeConfig="streamlit"
/>

With Toolbar Customization

<GraphicWalker
  data={data}
  fields={fields}
  toolbar={{
    exclude: ['export_chart'],
    extra: [
      {
        key: 'custom-save',
        label: 'Save',
        icon: SaveIcon,
        onClick: handleSave,
      },
    ],
  }}
/>

Server-Side Computation

import { GraphicWalker } from '@kanaries/graphic-walker';
import type { IComputationFunction } from '@kanaries/graphic-walker';
 
const computation: IComputationFunction = async (payload) => {
  const response = await fetch('/api/compute', {
    method: 'POST',
    body: JSON.stringify(payload),
    headers: { 'Content-Type': 'application/json' },
  });
  return response.json();
};
 
function App() {
  return (
    <GraphicWalker
      computation={computation}
      fields={fields}
    />
  );
}