@neo4j-ndl/react-charts
Version:
React implementation of charts from Neo4j Design System
71 lines (70 loc) • 2.88 kB
TypeScript
/**
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { type EChartsOption, type LineSeriesOption, type RegisteredSeriesOption, type SetOptionOpts } from 'echarts';
import { type CSSProperties } from 'react';
import { type NotificationType } from './ChartTooltip';
import { type LegendProps } from './Legend';
type Condition = 'greater' | 'greaterOrEqual' | 'less' | 'lessOrEqual' | 'equal' | 'notEqual';
type CustomCondition = (lineValue: unknown, thresholdLineValue: unknown) => boolean;
export interface ThresholdLineSeriesOption<T extends NotificationType> extends Omit<LineSeriesOption, 'type'> {
type: 'thresholdLine';
yAxis: number;
xAxis: [number, number];
notificationType: T;
color?: string;
condition?: Condition;
customConditionText?: string;
customCondition?: CustomCondition;
}
export declare const defaultThresholdLineSeriesOption: {
condition: Condition;
};
export type Values<T> = T[keyof T];
export type SeriesOption = Values<RegisteredSeriesOption>;
export type EchartsSeries = SeriesOption | SeriesOption[];
export type NeedleSeries = [
ThresholdLineSeriesOption<'warning'>,
ThresholdLineSeriesOption<'danger'>,
...SeriesOption[]
] | [ThresholdLineSeriesOption<'danger'>, ...SeriesOption[]] | [ThresholdLineSeriesOption<'warning'>, ...SeriesOption[]] | SeriesOption[];
export interface ChartProps {
dataset: EChartsOption['dataset'];
series: NeedleSeries;
xAxis?: EChartsOption['xAxis'];
yAxis?: EChartsOption['yAxis'];
legend?: {
show?: boolean;
wrappingType?: LegendProps['wrappingType'];
};
option?: Omit<EChartsOption, 'series' | 'dataset' | 'legend' | 'xAxis' | 'yAxis'>;
style?: CSSProperties;
settings?: SetOptionOpts;
isLoading?: boolean;
callbacks?: {
onZoom?: (params: {
startValue: number;
endValue: number;
}) => void;
};
dataZoom?: EChartsOption['dataZoom'];
}
export declare function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: propYAxis, series: propsSeries, style, settings, isLoading, legend, callbacks, }: ChartProps): React.JSX.Element;
export {};