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.
33 lines
995 B
33 lines
995 B
import { PanelOptions } from '../types'; |
|
|
|
import { ChartwerkGaugePod } from '@chartwerk/gauge-pod'; |
|
|
|
import { PanelProps } from '@grafana/data'; |
|
|
|
import React, { useRef } from 'react'; |
|
import { css } from 'emotion'; |
|
|
|
|
|
interface Props extends PanelProps<PanelOptions> {} |
|
|
|
export function Panel({ options, data, width, height, timeZone, timeRange, onChangeTimeRange }: Props) { |
|
let chartContainer = useRef(null); |
|
|
|
// 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: pass datapoints |
|
// TODO: pass options |
|
// TODO: switch / case pod type |
|
const pod = new ChartwerkGaugePod((chartContainer as any).current, [{ target: 'test', datapoints: [[5, 5], [0, 10], [30, 15], [50, 20], [17, 25]] }]); |
|
pod.render(); |
|
}); |
|
return <div |
|
ref={chartContainer} |
|
className={ |
|
css` |
|
width: ${width}px; |
|
height: ${height}px; |
|
` |
|
} |
|
></div>; |
|
}
|
|
|