@@ -12,8 +12,13 @@ import { parseNodeIconConfig } from './util/NodeUtils';
1212import { GraphChartVisualizationProps , layouts } from './GraphChartVisualization' ;
1313import { handleExpand } from './util/ExplorationUtils' ;
1414import { categoricalColorSchemes } from '../../config/ColorConfig' ;
15+ import { IconButton , Tooltip } from '@material-ui/core' ;
16+ import SaveAltIcon from '@material-ui/icons/SaveAlt' ;
17+ import { RenderSubValue } from '../../report/ReportRecordProcessing' ;
18+ import { downloadCSV } from '../ChartUtils' ;
1519import { GraphChartContextMenu } from './component/GraphChartContextMenu' ;
1620import { getSettings } from '../SettingsUtils' ;
21+ import { generateSafeColumnKey } from '../table/TableChart' ;
1722
1823/**
1924 * Draws graph data using a force-directed-graph visualization.
@@ -33,7 +38,6 @@ const NeoGraphChart = (props: ChartProps) => {
3338
3439 const setNodePositions = ( positions ) =>
3540 props . updateReportSetting && props . updateReportSetting ( 'nodePositions' , positions ) ;
36-
3741 const handleEntityClick = ( item ) => {
3842 setSelectedEntity ( item ) ;
3943 setContextMenuOpen ( false ) ;
@@ -213,6 +217,27 @@ const NeoGraphChart = (props: ChartProps) => {
213217 { settings . drilldownLink ? < NeoGraphChartDeepLinkButton { ...chartProps } /> : < > </ > }
214218 < NeoGraphChartVisualization2D { ...chartProps } />
215219 < NeoGraphChartInspectModal { ...chartProps } > </ NeoGraphChartInspectModal >
220+ { settings . allowDownload && props . records && props . records . length > 0 ? (
221+ < Tooltip title = 'Download CSV' aria-label = '' >
222+ < IconButton
223+ onClick = { ( ) => {
224+ const rows = props . records . map ( ( record , rownumber ) => {
225+ return Object . assign (
226+ { id : rownumber } ,
227+ ...record . _fields . map ( ( field , i ) => ( { [ generateSafeColumnKey ( record . keys [ i ] ) ] : field } ) )
228+ ) ;
229+ } ) ;
230+ downloadCSV ( rows ) ;
231+ } }
232+ aria-label = 'download csv'
233+ style = { { bottom : '9px' , left : '3px' , position : 'absolute' } }
234+ >
235+ < SaveAltIcon style = { { fontSize : '1.3rem' , zIndex : 5 } } fontSize = 'small' > </ SaveAltIcon >
236+ </ IconButton >
237+ </ Tooltip >
238+ ) : (
239+ < > </ >
240+ ) }
216241 </ NeoGraphChartCanvas >
217242 </ div >
218243 ) ;
0 commit comments