-
-
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.
- Loading branch information
Showing
8 changed files
with
147 additions
and
105 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 |
---|---|---|
@@ -1 +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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import React from 'react'; | ||
import Enzyme, {shallow, mount} from 'enzyme'; | ||
import Enzyme, { shallow, mount } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
Enzyme.configure({adapter: new Adapter()}); | ||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
describe('Tree map legend component test suite', () => { | ||
test('Ensure jest is working', () => { | ||
expect(true).toEqual(true); | ||
}); | ||
|
||
// test('renders', () => { | ||
// const wrapper = shallow(<Legend />); | ||
// expect(wrapper.exists()).toBe(true); | ||
// }); | ||
test('renders', () => { | ||
const wrapper = shallow(<Legend />); | ||
expect(wrapper.exists()).toBe(true); | ||
}); | ||
}); |
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
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', | ||
|