DataHoverRow.tsx 635 B

12345678910111213141516171819202122232425262728
  1. import { FeatureLike } from 'ol/Feature';
  2. import React from 'react';
  3. import { ArrayDataFrame, DataFrame } from '@grafana/data';
  4. import { DataHoverView } from './DataHoverView';
  5. type Props = {
  6. feature?: FeatureLike;
  7. };
  8. export const DataHoverRow = ({ feature }: Props) => {
  9. let data: DataFrame;
  10. let rowIndex = 0;
  11. if (!feature) {
  12. return null;
  13. }
  14. data = feature.get('frame');
  15. if (data) {
  16. rowIndex = feature.get('rowIndex');
  17. } else {
  18. const { geometry, ...properties } = feature.getProperties();
  19. data = new ArrayDataFrame([properties]);
  20. }
  21. return <DataHoverView data={data} rowIndex={rowIndex} />;
  22. };