summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pages/projects/graphs/show/index.js
blob: 71f629fbc1372c5028ef1e40ccb2b66a928867a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import $ from 'jquery';
import flash from '~/flash';
import { __ } from '~/locale';
import axios from '~/lib/utils/axios_utils';
import ContributorsStatGraph from './stat_graph_contributors';

document.addEventListener('DOMContentLoaded', () => {
  const url = document.querySelector('.js-graphs-show').dataset.projectGraphPath;

  axios.get(url)
    .then(({ data }) => {
      const graph = new ContributorsStatGraph();
      graph.init(data);

      $('#brush_change').change(() => {
        graph.change_date_header();
        graph.redraw_authors();
      });

      $('.stat-graph').fadeIn();
      $('.loading-graph').hide();
    })
    .catch(() => flash(__('Error fetching contributors data.')));
});