Update VisitorGraph to use new navigation function

This commit is contained in:
birjolaxew 2020-11-11 11:31:42 +01:00
parent 8e9349e1d8
commit 3524a89fb3

View File

@ -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'
@ -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,
}
)
}
}