how to implement export graph data to csv file

i have created a xygraph refering to the vtk example(c++)
https://kitware.github.io/vtk-examples/site/Cxx/Plotting/ScatterPlot/
i want this graph to be exported as a csv file

can anyone help me with this