Skip to content

Commit

Permalink
Update VisitorGraph to use new navigation function
Browse files Browse the repository at this point in the history
  • Loading branch information
birjj committed Nov 11, 2020
1 parent 8e9349e commit 3524a89
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions assets/js/dashboard/stats/visitor-graph.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { withRouter } from 'react-router-dom'
import Chart from 'chart.js'
import { eventName } from '../query'
import { eventName, navigateToQuery } from '../query'
import numberFormatter, {durationFormatter} from '../number-formatter'
import * as api from '../api'

Expand Down Expand Up @@ -192,17 +192,26 @@ class LineGraph extends React.Component {
}

onClick(e) {
const query = new URLSearchParams(window.location.search)
const element = this.chart.getElementsAtEventForMode(e, 'index', {intersect: false})[0]
const date = element._chart.config.data.labels[element._index]
if (this.props.graphData.interval === 'month') {
query.set('period', 'month')
query.set('date', date)
this.props.history.push({search: query.toString()})
navigateToQuery(
this.props.history,
this.props.query,
{
period: 'month',
date,
}
)
} else if (this.props.graphData.interval === 'date') {
query.set('period', 'day')
query.set('date', date)
this.props.history.push({search: query.toString()})
navigateToQuery(
this.props.history,
this.props.query,
{
period: 'day',
date,
}
)
}
}

Expand Down

0 comments on commit 3524a89

Please sign in to comment.