Skip to content
Snippets Groups Projects
config.js 1.25 KiB
Newer Older
tlansey's avatar
tlansey committed
import moment from 'moment'
//Load in data
import ConnectionData from '../../Data/Connections.csv';

//Process Data
var dates = [];
var totalConnectionsPerMonth = [];
function csvJSON(csvInput){
  let csvToJson = require('convert-csv-to-json');
  csvToJson.fieldDelimiter(',');
  return csvToJson.getJsonFromCsv(csvInput);
let connections = csvJSON(ConnectionData);

connections.forEach(function(connection) {
    let stri = (connection.FirstName).split(' ');
tlansey's avatar
tlansey committed

    if (stri[0] in totalConnectionsPerMonth)
tlansey's avatar
tlansey committed
    {
        totalConnectionsPerMonth[stri[0]] += 1;
tlansey's avatar
tlansey committed
    }
    else
    {
        totalConnectionsPerMonth[stri[0]] = 1;
tlansey's avatar
tlansey committed
    }
    
});
console.log(totalConnectionsPerMonth);
dates = Object.keys(totalConnectionsPerMonth);
var totalConnections = Object.values(totalConnectionsPerMonth);
tlansey's avatar
tlansey committed

dates.reverse();
totalConnections.reverse();
tlansey's avatar
tlansey committed

const data = {
    labels: dates,
    datasets: [
      {
        label: '# of Connections',
tlansey's avatar
tlansey committed
        lineTension: 0.1,
        backgroundColor: 'rgba(252,48,120,0.2)',
        borderColor: 'rgba(252,48,120,1)',
        borderCapStyle: 'butt',
        borderDash: [],
        borderDashOffset: 0.0,
        borderJoinStyle: 'miter',
        pointHitRadius: 10,
        data: totalConnections,
tlansey's avatar
tlansey committed
      }
    ],
  };
  
  export { data };