diff --git a/src/short-urls/ShortUrlVisits.js b/src/short-urls/ShortUrlVisits.js index 4ce6ad8f..e3a952ea 100644 --- a/src/short-urls/ShortUrlVisits.js +++ b/src/short-urls/ShortUrlVisits.js @@ -20,11 +20,27 @@ export class ShortUrlsVisits extends React.Component { const { match: { params }, selectedServer, visitsParser, shortUrlVisits: { visits, loading, error } } = this.props; const serverUrl = selectedServer ? selectedServer.url : ''; const shortUrl = `${serverUrl}/${params.shortCode}`; - const generateGraphData = stats => ({ + const generateGraphData = (stats, label, isBarChart) => ({ labels: Object.keys(stats), - data: Object.values(stats) + datasets: [ + { + label, + data: Object.values(stats), + backgroundColor: isBarChart ? 'rgba(200, 26, 80, 0.2)' : [], + borderColor: isBarChart ? 'rgba(200, 26, 80, 1)' : [], + } + ] }); - + const renderGraphCard = (title, stats, isBarChart = true) => +
+ + {title} + + {!isBarChart && } + {isBarChart && } + + +
; const renderContent = () => { if (loading) { return ( @@ -48,38 +64,10 @@ export class ShortUrlsVisits extends React.Component { return (
-
- - Operating systems - - - - -
-
- - Browsers - - - - -
-
- - Countries - - - - -
-
- - Referrers - - - - -
+ {renderGraphCard('Operating systems', visitsParser.processOsStats(visits), false)} + {renderGraphCard('Browsers', visitsParser.processBrowserStats(visits), false)} + {renderGraphCard('Countries', visitsParser.processCountriesStats(visits))} + {renderGraphCard('Referrers', visitsParser.processReferrersStats(visits))}
); };