|
|
|
@ -26,7 +26,6 @@ export function Panel({ options, data, width, height, timeRange, onChangeTimeRan
|
|
|
|
|
|
|
|
|
|
// we request animation frame here because we need an existing DOM-element at the moment we render the pod
|
|
|
|
|
window.requestAnimationFrame(() => { |
|
|
|
|
console.log('pod', options.visualizationType); |
|
|
|
|
let pod; |
|
|
|
|
switch (options.visualizationType) { |
|
|
|
|
case Pod.GAUGE: |
|
|
|
@ -37,7 +36,6 @@ export function Panel({ options, data, width, height, timeRange, onChangeTimeRan
|
|
|
|
|
case Pod.BAR: |
|
|
|
|
const barSeries = new BarSeries(grafanaSeriesList).getChartwerkSeries(); |
|
|
|
|
const chartwerkBarOptions = new BarOptions(grafanaSeriesList, onChangeTimeRange).getChartwerkOptions(); |
|
|
|
|
console.log('data', barSeries, chartwerkBarOptions); |
|
|
|
|
pod = new ChartwerkBarPod((chartContainer as any).current, barSeries, chartwerkBarOptions); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
@ -54,26 +52,28 @@ export function Panel({ options, data, width, height, timeRange, onChangeTimeRan
|
|
|
|
|
} |
|
|
|
|
window.open(options.gauge.link, '_self'); |
|
|
|
|
}; |
|
|
|
|
const legendItems = [ |
|
|
|
|
{ label: 'metric1', yAxis: 100, color: 'red' }, |
|
|
|
|
{ label: 'metric2', yAxis: 200, color: 'green' }, |
|
|
|
|
]; |
|
|
|
|
const legendItems = _.map(grafanaSeriesList, (serie) => { |
|
|
|
|
return { |
|
|
|
|
label: serie.alias, |
|
|
|
|
color: serie.color, |
|
|
|
|
yAxis: 1, |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
const chartHeight = options.visualizationType !== Pod.GAUGE ? height - 20 : height; |
|
|
|
|
return ( |
|
|
|
|
<div> |
|
|
|
|
<div |
|
|
|
|
ref={chartContainer} |
|
|
|
|
className={css` |
|
|
|
|
width: ${width}px; |
|
|
|
|
height: ${height- 20}px; |
|
|
|
|
height: ${chartHeight}px; |
|
|
|
|
cursor: ${isLinkActive ? 'pointer' : 'default'}; |
|
|
|
|
`}
|
|
|
|
|
onClick={chartClickHandler} |
|
|
|
|
></div> |
|
|
|
|
<VizLegend |
|
|
|
|
placement={'bottom'} |
|
|
|
|
items={legendItems} |
|
|
|
|
displayMode={LegendDisplayMode.List} |
|
|
|
|
/> |
|
|
|
|
{options.visualizationType !== Pod.GAUGE && ( |
|
|
|
|
<VizLegend placement={'bottom'} items={legendItems} displayMode={LegendDisplayMode.List} /> |
|
|
|
|
)} |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|