Skip to content

Documentation / @ripl/charts / createTrendChart

Function: createTrendChart() ​

createTrendChart<TData>(target, options): TrendChart<TData>

Defined in: charts/src/charts/trend.ts:451

Factory function that creates a new TrendChart instance.

Type Parameters ​

Type ParameterDefault type
TDataunknown

Parameters ​

ParameterType
targetstring | HTMLElement | Context<Element, Record<string, unknown>>
optionsTrendChartOptions<TData>

Returns ​

TrendChart<TData>

Example ​

ts
createTrendChart(target, {
    data: [
        { month: 'Jan', revenue: 120, profit: 40, target: 100 },
        { month: 'Feb', revenue: 150, profit: 55, target: 130 },
    ],
    key: 'month',
    series: [
        { id: 'revenue', type: 'area', label: 'Revenue', value: 'revenue' },
        { id: 'profit', type: 'bar', label: 'Profit', value: 'profit' },
        { id: 'target', type: 'line', label: 'Target', value: 'target' },
    ],
    overview: true,
});