Skip to content
Snippets Groups Projects
Commit 761f246b authored by tlansey's avatar tlansey
Browse files

Components for LinkedIn

parent 789b64e4
No related branches found
No related tags found
No related merge requests found
import React, { Component } from 'react';
import { Line } from 'react-chartjs-2';
import { data, options } from './config';
export default class TotalSongsByDayLine extends Component {
render() {
return <Line data={data} height={90} />;
}
}
\ No newline at end of file
import moment from 'moment'
//Load in data
import ConnectionData from '../../Data/Connections.csv';
//Process Data
var dates = [];
var totalConnectionsPerMonth = [];
function csvJSON(csv){
var lines=csv.split("\n");
var result = [];
// NOTE: If your columns contain commas in their values, you'll need
// to deal with those before doing the next step
// (you might convert them to &&& or something, then covert them back later)
// jsfiddle showing the issue https://jsfiddle.net/
var headers=lines[0].split(",");
for(var i=1;i<lines.length;i++){
var obj = {};
var currentline=lines[i].split(",");
for(var j=0;j<headers.length;j++){
obj[headers[j]] = currentline[j];
}
result.push(obj);
}
//return result; //JavaScript object
return JSON.stringify(result); //JSON
}
csvJSON(ConnectionData).forEach(function(connection) {
let stri = (connection.endTime).split(' ');
if (stri[0] in totalSongsPerDay)
{
totalSongsPerDay[stri[0]] += 1;
}
else
{
totalSongsPerDay[stri[0]] = 1;
}
});
console.log(totalSongsPerDay);
dates = Object.keys(totalSongsPerDay);
var totalSongs = Object.values(totalSongsPerDay);
dates.reverse();
totalSongs.reverse();
const data = {
labels: dates,
datasets: [
{
label: '# of Songs',
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: totalSongs,
}
],
};
export { data };
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment