-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3dbb1c
commit fc2d32d
Showing
14 changed files
with
151 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,58 @@ | ||
import React from 'react'; | ||
import React, { Component } from 'react'; | ||
import { PanelProps } from '@grafana/data'; | ||
import { MapOptions } from 'types'; | ||
import { parseData } from 'dataParser'; | ||
import { Canvas } from 'components/Canvas'; | ||
|
||
interface Props extends PanelProps<MapOptions> {} | ||
|
||
export const MapPanel: React.FC<Props> = ({ options, data, width, height, id }) => { | ||
let graphOptions = { | ||
...options, | ||
}; | ||
var colors = { | ||
defaultColor: graphOptions.color, | ||
nodeHighlight: graphOptions.nodeHighlight, | ||
}; | ||
var fields = { | ||
srcField: graphOptions.srcField, | ||
dstField: graphOptions.dstField, | ||
valField: graphOptions.valField, | ||
endpointId: graphOptions.endpointId, | ||
}; | ||
var parsedData = {}; | ||
var mapData; | ||
try { | ||
parsedData = parseData(data, graphOptions.mapjson, colors, fields); | ||
mapData = parsedData[3]; | ||
} catch (error) { | ||
console.error('Parsing error : ', error); | ||
export class MapPanel extends Component<Props> { | ||
//= ({ options, data, width, height, id }) => | ||
constructor(props: Props) { | ||
super(props); | ||
} | ||
|
||
// return <div>Hello World</div>; | ||
updateMapJson = (newData) => { | ||
const { options } = this.props; | ||
let { mapjson } = options; | ||
// const { data } = this.props; | ||
mapjson = JSON.stringify(newData); | ||
this.props.onOptionsChange({ ...options, mapjson }); | ||
}; | ||
|
||
render() { | ||
const { options, data, width, height, id } = this.props; | ||
var colors = { | ||
defaultColor: options.color, | ||
nodeHighlight: options.nodeHighlight, | ||
}; | ||
var fields = { | ||
srcField: options.srcField, | ||
dstField: options.dstField, | ||
valField: options.valField, | ||
endpointId: options.endpointId, | ||
}; | ||
var parsedData = {}; | ||
var mapData; | ||
|
||
return ( | ||
<Canvas height={height} width={width} panelId={id} options={graphOptions} data={parsedData} mapData={mapData} /> | ||
); | ||
}; | ||
try { | ||
parsedData = parseData(data, options.mapjson, colors, fields); | ||
mapData = parsedData[3]; | ||
} catch (error) { | ||
console.error('Parsing error : ', error); | ||
} | ||
return ( | ||
<Canvas | ||
height={height} | ||
width={width} | ||
panelId={id} | ||
options={options} | ||
data={parsedData} | ||
mapData={mapData} | ||
updateMapJson={this.updateMapJson} | ||
// json={json} | ||
// setJson={setJson} | ||
/> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.