Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add charts for all related offenses for property and violent crime view #1207

Merged
merged 26 commits into from
Aug 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"jszip": "^3.1.3",
"lodash.debounce": "^4.0.8",
"lodash.flatten": "^4.4.0",
"lodash.kebabcase": "^4.1.1",
"lodash.lowercase": "^4.3.0",
"lodash.range": "^3.2.0",
"lodash.snakecase": "^4.1.1",
Expand Down Expand Up @@ -105,7 +106,11 @@
"yaml-loader": "^0.5.0"
},
"babel": {
"presets": ["es2015", "stage-0", "react"]
"presets": [
"es2015",
"stage-0",
"react"
]
},
"jest": {
"moduleNameMapper": {
Expand Down
3 changes: 3 additions & 0 deletions sass/components/_trend.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.trend-cards .trend-chart-details {
flex-direction: column;
}
1 change: 1 addition & 0 deletions sass/components/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
@import 'progress';
@import 'tables';
@import 'tooltips';
@import 'trend';
@import 'viz';
12 changes: 9 additions & 3 deletions sass/util/_height.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
.mh6 { min-height: $space-6; }
.mh6 {
min-height: $space-6;
}

@media #{$breakpoint-lg} {
.lg-mh-72p { min-height: 72px; }
.lg-mh-88p {
min-height: 88px;
}
}

.maxh5 { max-height: $space-5; }
.maxh5 {
max-height: $space-5;
}
8 changes: 4 additions & 4 deletions src/actions/summary.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import reduceEntries from 'reduce-entries'

import { SUMMARY_FAILED, SUMMARY_FETCHING, SUMMARY_RECEIVED } from './constants'
import api from '../util/api'
import { calculateRates, reshapeData } from '../util/summary'

export const failedSummary = error => ({
type: SUMMARY_FAILED,
Expand All @@ -22,7 +21,8 @@ export const fetchSummaries = params => dispatch => {
const requests = api.getSummaryRequests(params)

return Promise.all(requests)
.then(data => data.reduce(reduceEntries('results'), {}))
.then(summaries => dispatch(receivedSummary(summaries)))
.then(data => reshapeData(data))
.then(d => calculateRates(d))
.then(summaries => dispatch(receivedSummary(summaries, params)))
.catch(error => dispatch(failedSummary(error)))
}
8 changes: 6 additions & 2 deletions src/components/AboutTheData.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class AboutTheData extends React.Component {
<div className="caveats">
{caveats.map((c, i) =>
<div key={i}>
<div className="mb-tiny bold caps">{c.heading}</div>
<div className="mb-tiny bold caps">
{c.heading}
</div>
{/* eslint react/no-danger: 0 */}
<div
className="mb3"
Expand All @@ -68,7 +70,9 @@ class AboutTheData extends React.Component {
<ul className="m0 p0 fs-14 left-bars">
{links.map((l, i) =>
<li key={i} className="mb1">
<a className="white" href={l.url}>{l.text}</a>
<a className="white" href={l.url}>
{l.text}
</a>
</li>,
)}
</ul>
Expand Down
3 changes: 1 addition & 2 deletions src/components/BetaBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const BetaBanner = ({ onFeedbackClick }) =>
<div className="lg-absolute lg-col-7 top-0 right-0 fs-10 md-fs-14">
<div className="lg-mr2 p1 lg-py2 lg-pl3 lg-inline-block lg-rounded-bottom bg-red white">
This site is under development and will be updated periodically. Feedback
is welcome and will help us provide a better service.
{' '}
is welcome and will help us provide a better service.{' '}
<button
className="btn p0 line-height-1 underline"
onClick={onFeedbackClick}
Expand Down
4 changes: 3 additions & 1 deletion src/components/CrimeTypeFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const CrimeTypeFilter = ({ ariaControls, onChange, selected }) =>
{crimes.map((c, i) =>
<div className="mb2 rounded overflow-hidden" key={i}>
{c.title &&
<div className="mb1 sm-m0 px2 sm-lh-30 bold">{c.title}</div>}
<div className="mb1 sm-m0 px2 sm-lh-30 bold">
{c.title}
</div>}
<div>
{c.options.map((o, ii) => {
const id = o.id || slugify(o)
Expand Down
3 changes: 1 addition & 2 deletions src/components/ErrorCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class ErrorCard extends React.Component {
<div className="mb2 p2 white bg-blue fs-14 overflow-auto">
<p className="m0">
<strong>Uh-oh!</strong> An error occurred during the request. Please
try
again soon.
try again soon.
</p>
<button
className="bg-transparent border-none cursor-pointer fs-12 px0 mt2 white"
Expand Down
89 changes: 0 additions & 89 deletions src/components/ExplorerIntroNational.js

This file was deleted.

4 changes: 3 additions & 1 deletion src/components/Glossary.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ class Glossary extends React.Component {
placeholder="e.g. Crime rate"
/>
{error &&
<p className="my1 p1 fs-14 bold bg-red-bright white">{error}</p>}
<p className="my1 p1 fs-14 bold bg-red-bright white">
{error}
</p>}
<div className="glossary__content" id="glossary-result">
<ul className="js-glossary-list" />
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/components/Highlight.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import PropTypes from 'prop-types'
import React from 'react'

const Highlight = ({ text }) => <span className="bold blue">{text}</span>
const Highlight = ({ text }) =>
<span className="bold blue">
{text}
</span>

Highlight.propTypes = {
text: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
Expand Down
12 changes: 10 additions & 2 deletions src/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ import { Link as RouterLink } from 'react-router'
const Link = props => {
const { children, to } = props

let el = <RouterLink {...props}>{children}</RouterLink>
let el = (
<RouterLink {...props}>
{children}
</RouterLink>
)
if (to.includes('http://') || to.includes('https://')) {
el = <a href={to} {...props}>{children}</a>
el = (
<a href={to} {...props}>
{children}
</a>
)
}

return el
Expand Down
2 changes: 1 addition & 1 deletion src/components/LocationFilter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types'
import React from 'react'

import AgencySearch from './AgencySearch'
import AgencySearch from './agency/AgencySearch'
import LocationSelect from './LocationSelect'
import { nationalKey } from '../util/usa'

Expand Down
5 changes: 4 additions & 1 deletion src/components/NoData.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import PropTypes from 'prop-types'
import React from 'react'

const NoData = ({ text }) => <div className="fs-18">{text}</div>
const NoData = ({ text }) =>
<div className="fs-18">
{text}
</div>

NoData.defaultProps = {
text: 'There is no data at this time.',
Expand Down
6 changes: 5 additions & 1 deletion src/components/OnEscape.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ class OnEscape extends React.Component {
}

render() {
return <div>{this.props.children}</div>
return (
<div>
{this.props.children}
</div>
)
}
}

Expand Down
20 changes: 0 additions & 20 deletions src/components/TrendChartHover.js

This file was deleted.

4 changes: 3 additions & 1 deletion src/components/XAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const XAxis = ({ active, tickCt, tickSizeOuter, height, scale, showLine }) => {
className={`tick ${String(v) === String(active) ? 'bold' : ''}`}
>
<line stroke="#000" y2="6" />
<text fill="#000" x="0" y="12" dy=".71em">{format(v)}</text>
<text fill="#000" x="0" y="12" dy=".71em">
{format(v)}
</text>
</g>
)
})
Expand Down
4 changes: 3 additions & 1 deletion src/components/YAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const YAxis = ({ tickCt, scale, width }) => {
return (
<g key={i} transform={`translate(0, ${pos})`} className="tick">
<line x2={width} y2="0" strokeOpacity={i === 0 ? '1' : '.25'} />
<text fill="#000" x="-32" y="0" dy=".32em">{fmt(v)}</text>
<text fill="#000" x="-32" y="0" dy=".32em">
{fmt(v)}
</text>
</g>
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import PropTypes from 'prop-types'
import React from 'react'

import AgencyChartDetails from './AgencyChartDetails'
import XAxis from './XAxis'
import YAxis from './YAxis'
import XAxis from '../XAxis'
import YAxis from '../YAxis'

class AgencyChart extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -92,9 +92,8 @@ class AgencyChart extends React.Component {
}))

// no data (nd) element responsive values
const [ndHeight, ndCircle, ndTextY, ndTextSize] = svgWidth < 500
? [10, 5, 2.5, 8]
: [20, 8, 4, 11]
const [ndHeight, ndCircle, ndTextY, ndTextSize] =
svgWidth < 500 ? [10, 5, 2.5, 8] : [20, 8, 4, 11]

return (
<div>
Expand Down
Loading