-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #235 Enforced a frontend linting step to protect PRs
Actually running linting Addressed all linting errors Removed unused test
- Loading branch information
Showing
9 changed files
with
114 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.json | ||
*.test.js* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,75 @@ | ||
(function(){ | ||
let chartData = []; | ||
|
||
const chart = c3.generate({ | ||
bindto: '#chart', | ||
data: { | ||
type: getChartTypeDisplay(), | ||
columns: [], | ||
}, | ||
axis: { | ||
x: { | ||
show: false, | ||
} | ||
} | ||
}); | ||
|
||
function getChartTypeDisplay() { | ||
return document.querySelector('.chart-type').value; | ||
}; | ||
|
||
function getDatasetsToDisplay() { | ||
return document.querySelectorAll('.data-dropdown'); | ||
}; | ||
|
||
function getRequestType() { | ||
return document.querySelector('.request-dropdown').value; | ||
}; | ||
|
||
function getDisplayTotal() { | ||
return document.querySelector('input[name="total"]').checked; | ||
} | ||
|
||
function getData(year, requestType) { | ||
return fetch(`/soda/${year}/${requestType}`) | ||
.then(res => res.json()) | ||
.then(data => { chartData.push(...data); }) | ||
.catch(err => { console.error('Fetch Error :-S', err); }); | ||
}; | ||
|
||
function getTotal(year, requestType) { | ||
return fetch(`/soda/${year}/${requestType}/total`) | ||
.then(res => res.json()) | ||
.then(data => { chartData.push(data); }) | ||
.catch(err => { console.error('Fetch Error :-S', err); }) | ||
}; | ||
|
||
function buildChart() { | ||
const requestType = getRequestType(); | ||
const chartType = getChartTypeDisplay(); | ||
const displayTotal = getDisplayTotal(); | ||
const datasets = [...getDatasetsToDisplay()] | ||
.map(dataset => { | ||
const { value } = dataset; | ||
if (!displayTotal) return getData(value, requestType); | ||
else return getTotal(value, requestType); | ||
}); | ||
|
||
Promise.all(datasets) | ||
.then(() => { renderChart(chartData, chartType); }) | ||
.catch(err => { console.error('Render Error :-S', err)}); | ||
}; | ||
|
||
function renderChart(columns, type) { | ||
chart.load({ columns, type }); | ||
}; | ||
|
||
document.querySelector('button').onclick = e => { | ||
e.preventDefault(); | ||
chart.unload(); | ||
chartData = []; | ||
buildChart(); | ||
}; | ||
|
||
buildChart(); | ||
})(); | ||
// (function () { | ||
// let chartData = []; | ||
// | ||
// const chart = c3.generate({ | ||
// bindto: '#chart', | ||
// data: { | ||
// type: getChartTypeDisplay(), | ||
// columns: [], | ||
// }, | ||
// axis: { | ||
// x: { | ||
// show: false, | ||
// }, | ||
// }, | ||
// }); | ||
// | ||
// function getChartTypeDisplay() { | ||
// return document.querySelector('.chart-type').value; | ||
// } | ||
// | ||
// function getDatasetsToDisplay() { | ||
// return document.querySelectorAll('.data-dropdown'); | ||
// } | ||
// | ||
// function getRequestType() { | ||
// return document.querySelector('.request-dropdown').value; | ||
// } | ||
// | ||
// function getDisplayTotal() { | ||
// return document.querySelector('input[name="total"]').checked; | ||
// } | ||
// | ||
// function getData(year, requestType) { | ||
// return fetch(`/soda/${year}/${requestType}`) | ||
// .then((res) => res.json()) | ||
// .then((data) => { chartData.push(...data); }) | ||
// .catch((err) => { console.error('Fetch Error :-S', err); }); | ||
// } | ||
// | ||
// function getTotal(year, requestType) { | ||
// return fetch(`/soda/${year}/${requestType}/total`) | ||
// .then((res) => res.json()) | ||
// .then((data) => { chartData.push(data); }) | ||
// .catch((err) => { console.error('Fetch Error :-S', err); }); | ||
// } | ||
// | ||
// function buildChart() { | ||
// const requestType = getRequestType(); | ||
// const chartType = getChartTypeDisplay(); | ||
// const displayTotal = getDisplayTotal(); | ||
// const datasets = [...getDatasetsToDisplay()] | ||
// .map((dataset) => { | ||
// const { value } = dataset; | ||
// if (!displayTotal) return getData(value, requestType); | ||
// return getTotal(value, requestType); | ||
// }); | ||
// | ||
// Promise.all(datasets) | ||
// .then(() => { renderChart(chartData, chartType); }) | ||
// .catch((err) => { console.error('Render Error :-S', err); }); | ||
// } | ||
// | ||
// function renderChart(columns, type) { | ||
// chart.load({ columns, type }); | ||
// } | ||
// | ||
// document.querySelector('button').onclick = (e) => { | ||
// e.preventDefault(); | ||
// chart.unload(); | ||
// chartData = []; | ||
// buildChart(); | ||
// }; | ||
// | ||
// buildChart(); | ||
// }()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import axios from 'axios'; | ||
// import axios from 'axios'; | ||
|
||
const types = { | ||
UPDATE_YEAR: 'UPDATE_YEAR', | ||
|