@@ -11,7 +11,10 @@ import {
1111 CartesianGrid ,
1212 Tooltip ,
1313 Legend ,
14+ LineChart ,
15+ Line ,
1416} from 'recharts' ;
17+
1518import { isDate } from 'moment' ;
1619import API from '../../apis/API' ; // library for AJAX functions
1720import Header , { HeaderPadding } from '../Navigation/Header' ;
@@ -46,27 +49,27 @@ function TransactionStats() {
4649 startDate ,
4750 endDate ,
4851 ) ;
49- console . log ( salesInRange ) ;
52+
5053 const incomeByDay = dataUtil . getIncomeByDay ( salesInRange ) ;
51- console . log ( incomeByDay [ 0 ] ) ;
5254
5355 const renderPlot = ( ) => {
5456 if ( loading ) return < ReactLoading color = "#e26d5c" /> ;
55- return (
56- < BarChart
57- width = { 600 }
58- height = { 300 }
59- data = { salesInRange }
60- margin = { { top : 5 , right : 30 , left : 20 , bottom : 5 } }
61- >
62- < CartesianGrid strokeDasharray = "3 3" />
63- < XAxis dataKey = "date" />
64- < YAxis />
65- < Tooltip />
66- < Legend />
67- < Bar dataKey = "price" fill = "#8884d8" />
68- </ BarChart >
69- ) ;
57+ if ( incomeByDay . length > 0 )
58+ return (
59+ < div >
60+ < LineChart width = { 600 } height = { 400 } data = { incomeByDay } >
61+ < CartesianGrid strokeDasharray = "3 3" />
62+ < XAxis label = "Date" dataKey = "date" interval = "preserveEnd" />
63+ < YAxis label = "Income ($)" interval = "preserveEnd" />
64+ < Line
65+ type = "monotone"
66+ dataKey = "income"
67+ stroke = "#8884d8"
68+ activeDot = { { r : 8 } }
69+ />
70+ </ LineChart >
71+ </ div >
72+ ) ;
7073 } ;
7174
7275 const dateInputs = ( ) => {
@@ -96,7 +99,7 @@ function TransactionStats() {
9699 ) ;
97100 } ;
98101
99- const filteredData = ( ) => {
102+ const filteredList = ( ) => {
100103 if ( loading ) return < ReactLoading color = "#e26d5c" /> ;
101104 return (
102105 < >
@@ -116,7 +119,7 @@ function TransactionStats() {
116119 < HeaderPadding />
117120 < div className = "SalesPlot" > { renderPlot ( ) } </ div >
118121 < div className = "DateInputs" > { dateInputs ( ) } </ div >
119- < div className = "FilteredData" > { filteredData ( ) } </ div >
122+ < div className = "FilteredData" > { filteredList ( ) } </ div >
120123 </ div >
121124 ) ;
122125}
0 commit comments