Commit ec065671 by Tonk

add csv export

parent cb2e7f97
......@@ -14,6 +14,7 @@
"react": "^16.8.6",
"react-bootstrap": "^1.0.0-beta.10",
"react-bootstrap-daterangepicker": "^4.1.0",
"react-csv": "^1.1.1",
"react-dom": "^16.8.6",
"react-icons": "^3.7.0",
"react-mapbox-gl": "^4.6.0",
......
import React from 'react';
import { Card, Col, Row } from 'react-bootstrap';
import { Card, Col, Row, Button } from 'react-bootstrap';
import { FaMoneyBillAlt, FaArrowUp, FaArrowDown } from 'react-icons/fa';
import { AreaChart, Area, XAxis, YAxis, ResponsiveContainer } from 'recharts';
import withWindowDimensions from '../utils/withWindowDimensions';
import { CSVLink } from 'react-csv';
const chartdata = [
{
......@@ -38,7 +39,6 @@ const chartdata = [
const SmCard = props => {
const smdata = props.smitem;
const iconStyle = { style: { height: '1.5em', width: '1.5em' } };
// console.log('test', smdata);
return (
<Card style={{ padding: '.7em', color: 'white', backgroundColor: props.backgroundColor }}>
<h6>{smdata.smtitle}</h6>
......@@ -112,6 +112,13 @@ const DataCard = props => {
)
)}
</Row>
<Row style={{ justifyContent: 'flex-end', marginRight: 1 }}>
<CSVLink data={data.detail} filename={data.title}>
<Button variant="light" style={{ marginTop: '.5em' }}>
Export to CSV
</Button>
</CSVLink>
</Row>
</Col>
);
};
......
import React from 'react';
import { Col, Table } from 'react-bootstrap';
import { Col, Table, Row, Button } from 'react-bootstrap';
import { CSVLink } from 'react-csv';
const data = [
{ site: 'Pichaiyat Building', people: 2670.0, revenue: 17.0, timestamp: '07/31/2019 14:23' },
{ site: 'Pichaiyat Building', people: 2670.0, revenue: 17.0, timestamp: '07/31/2019 14:23' },
......@@ -21,7 +22,7 @@ const data = [
const DataTable = () => {
return (
<Col>
<Table striped bordered hover size="sm" style={{ margin: '1em 0' }}>
<Table striped bordered hover size="sm" style={{ margin: '1em 0 0 0' }}>
<thead style={{ backgroundColor: '#49b9ff', color: 'white' }}>
<tr>
<th>Site</th>
......@@ -41,6 +42,13 @@ const DataTable = () => {
))}
</tbody>
</Table>
<Row style={{ justifyContent: 'flex-end', marginRight: 1 }}>
<CSVLink data={data} filename={'data-table'}>
<Button variant="light" style={{ marginTop: '.5em' }}>
Export to CSV
</Button>
</CSVLink>
</Row>
</Col>
);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment