> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Line

export const GraphPreview = ({config, aspectRatio = '10 / 6'}) => {
  const getThemeId = () => {
    return document.documentElement.classList.contains('dark') ? 'dark' : 'light';
  };
  const [themeId, setThemeId] = useState(getThemeId);
  const [isLoaded, setIsLoaded] = useState(false);
  config.appearance = {
    ...config.appearance,
    border: {
      style: 'none',
      color: 'transparent',
      width: 0
    },
    hasRoundedBorders: false
  };
  const baseUrl = window.location.hostname === 'localhost' ? 'https://app.graphy.top:8080' : 'https://visualize.graphy.app';
  const url = new URL('view/graph', baseUrl);
  url.searchParams.set('config', JSON.stringify(config));
  url.searchParams.set('themeId', themeId);
  useEffect(() => {
    const observer = new MutationObserver(function (mutations) {
      setThemeId(getThemeId());
    });
    observer.observe(document.documentElement, {
      attributes: true,
      attributeOldValue: true,
      attributeFilter: ['class']
    });
    return () => observer.disconnect();
  }, []);
  return <div className="graph-preview" style={{
    aspectRatio,
    opacity: isLoaded ? 1 : 0
  }}>
      <iframe src={url.toString()} loading="lazy" onLoad={() => setIsLoaded(true)} allowfullscreen="true" />
    </div>;
};

Line charts display data as a series of points connected by straight or curved lines. They're ideal for showing trends and changes over time.

## When to use

* **Time series data** - Track changes over time periods
* **Trends** - Show upward or downward patterns
* **Continuous measurements** - Display data with no gaps
* **Multiple series comparison** - Compare several trends on the same chart

## Basic example

<GraphPreview
  config={{
type: 'line',
data: {
  columns: [
    { key: 'month', label: 'Month' },
    { key: 'revenue', label: 'Revenue' },
  ],
  rows: [
    { month: 'Jan', revenue: 12000 },
    { month: 'Feb', revenue: 15000 },
    { month: 'Mar', revenue: 18000 },
    { month: 'Apr', revenue: 17000 },
    { month: 'May', revenue: 21000 },
  ],
},
}}
/>

```tsx theme={null}
const config: GraphConfig = {
  type: 'line',
  data: {
    columns: [
      { key: 'month', label: 'Month' },
      { key: 'revenue', label: 'Revenue' },
    ],
    rows: [
      { month: 'Jan', revenue: 12000 },
      { month: 'Feb', revenue: 15000 },
      { month: 'Mar', revenue: 18000 },
      { month: 'Apr', revenue: 17000 },
      { month: 'May', revenue: 21000 },
    ],
  },
};
```

## Multiple series

<GraphPreview
  config={{
type: 'line',
data: {
  columns: [
    { key: 'month', label: 'Month' },
    { key: 'revenue', label: 'Revenue' },
    { key: 'profit', label: 'Profit' },
  ],
  rows: [
    { month: 'Jan', revenue: 12000, profit: 3000 },
    { month: 'Feb', revenue: 15000, profit: 4500 },
    { month: 'Mar', revenue: 18000, profit: 5400 },
  ],
},
}}
/>

```tsx theme={null}
const config: GraphConfig = {
  type: 'line',
  data: {
    columns: [
      { key: 'month', label: 'Month' },
      { key: 'revenue', label: 'Revenue' },
      { key: 'profit', label: 'Profit' },
    ],
    rows: [
      { month: 'Jan', revenue: 12000, profit: 3000 },
      { month: 'Feb', revenue: 15000, profit: 4500 },
      { month: 'Mar', revenue: 18000, profit: 5400 },
    ],
  },
};
```

## Related

* [Type options](/sdk/config/type-options) - All line chart options
* [Axes](/sdk/config/axes) - Customize axes
* [Reference lines](/sdk/config/reference-lines) - Add trendlines and goal lines
