shadimage
gpt-vis
uicolumnsource: ok · refreshed

GPT-Vis Column Chart

A vertical column chart component for @antv/gpt-vis. Compare categorical data with optional grouping and stacking.

npx shadcn add "https://gpt-vis.antv.vision/r/column.json"
free

No selection tags yet — empty means no evidence, not lack of support.

Dependencies

Bundle weight · light
@antv/gpt-visclsxtailwind-merge

Files2 · source cached 10/8/2026, 10:49:05 AM

cn/block/gpt-vis/gpt-vis.tsx
'use client';

import { GPTVis as GPTVisCore, type VisualizationOptions } from '@antv/gpt-vis';
import { clsx, type ClassValue } from 'clsx';
import { useEffect, useRef, useState } from 'react';
import { twMerge } from 'tailwind-merge';

function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}

export interface GPTVisProps extends Omit<VisualizationOptions, 'container'> {
  content: string | Record<string, unknown>;
  className?: string;
  containerStyle?: React.CSSProperties;
}

export function GPTVis({
  content,
  width,
  height,
  theme,
  wrapper,
  locale,
  className,
  containerStyle,
}: GPTVisProps) {
  const containerRef = useRef<HTMLDivElement>(null);
  const [instance, setInstance] = useState<GPTVisCore | null>(null);

  useEffect(() => {
    if (!containerRef.current) return;
    const inst = new GPTVisCore({
      container: containerRef.current,
      width,
      height,
      theme,
      wrapper,
      locale,
    });
    setInstance(inst);
    return () => {
      inst.destroy();
      setInstance(null);
    };
  }, [width, height, theme, wrapper, locale]);

  const contentDeps = typeof content === 'string' ? content : JSON.stringify(content);

  useEffect(() => {
    instance?.render(content);
  }, [instance, contentDeps]);

  return (
    <div
      ref={containerRef}
      className={cn('w-full min-h-[300px]', className)}
      style={containerStyle}
    />
  );
}
cn/block/gpt-vis/column.tsx
'use client';

import type { ColumnConfig } from '@antv/gpt-vis';
import { GPTVis, type GPTVisProps } from './gpt-vis';

export interface ColumnProps extends Omit<GPTVisProps, 'content'> {
  config: Omit<ColumnConfig, 'type'>;
}

export function Column({ config, ...props }: ColumnProps) {
  return <GPTVis content={{ type: 'column', ...config }} {...props} />;
}

More from gpt-vis

Browse all components in this library →