You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

import { Options } from '../models/options';
import { Series } from '../models/series';
import { PanelOptions } from '../types';
2 years ago
import { ChartwerkGaugePod } from '@chartwerk/gauge-pod';
import { PanelProps } from '@grafana/data';
import React, { useRef } from 'react';
import { css } from 'emotion';
import * as _ from 'lodash';
2 years ago
interface Props extends PanelProps<PanelOptions> {}
export function Panel({ options, data, width, height, timeZone, timeRange, onChangeTimeRange }: Props) {
console.log('options', options);
const series = new Series(data, timeRange, options.gauge.value).getChartwerkSeries();
console.log('series', series);
const chartwerkOptions = new Options(options).getChartwerkOptions();
2 years ago
let chartContainer = useRef(null);
2 years ago
// we request animation frame here because at the moment we need an existing DOM-element at the moment we render the pod
window.requestAnimationFrame(() => {
// TODO: switch / case pod type
const pod = new ChartwerkGaugePod(
(chartContainer as any).current,
series,
chartwerkOptions
);
2 years ago
pod.render();
});
return (
<div
ref={chartContainer}
className={css`
2 years ago
width: ${width}px;
height: ${height}px;
`}
></div>
);
}