Skip to content

Commit

Permalink
udpates!
Browse files Browse the repository at this point in the history
  • Loading branch information
mbforr committed Sep 28, 2018
1 parent c645028 commit 33a567c
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 222 deletions.
192 changes: 8 additions & 184 deletions README.md

Large diffs are not rendered by default.

Binary file added isthmus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions public/dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/dist/bundle.js.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions src/components/layout/Header.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import { Component } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import carto from '@carto/carto.js';
import HeaderToggle from './header/HeaderToggle'
import HeaderLink from './header/HeaderLink'
import Avatar from './Avatar'
Expand Down Expand Up @@ -51,7 +49,6 @@ class Header extends Component {
const mapStateToProps = state => ({
client: state.client,
map: state.map,
filters: state.filters,
layers: state.layers,
viewport: state.viewport,
boundingbox: state.boundingbox
Expand Down
11 changes: 5 additions & 6 deletions src/components/layout/LeftBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class LeftBar extends Component {
...props
}
this.moveMap = this.moveMap.bind(this);

}

state = {
Expand All @@ -33,15 +34,12 @@ class LeftBar extends Component {
}


componentDidMount() {
const z = `as-sidebar as-sidebar--${this.props.size} as-sidebar--left ${this.props.background}`;
this.setState({size: z})
}

render() {

const size = `as-sidebar as-sidebar--${this.props.size} as-sidebar--left ${this.props.background}`;

return (
<aside className={this.state.size} data-name={this.props.name}>
<aside className={size} data-name={this.props.name}>
<div className="as-m--24">
<LinkButton
name='CARTO Website'
Expand Down Expand Up @@ -88,6 +86,7 @@ class LeftBar extends Component {
title='Accident Description'
description='Search text in the accident description field'
id='search'
layer={this.props.layers.railaccidents.source}
placeholder='Search...'
column='narrative'
/>
Expand Down
6 changes: 3 additions & 3 deletions src/components/layout/RightBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class RightBar extends Component {
description='Average total damage in USD for accidents in view'
round={true}
currency={true}
locale='en-US'
currencyType='USD'
layer={this.props.layers.railaccidents.source}
column='total_damage'
operation={carto.operation.AVG}
Expand All @@ -63,16 +65,14 @@ class RightBar extends Component {
name='Export Data'
/>
</div>
<div className="as-p--16">
<Category
heading='State'
title='State'
description='Total damage for each railroad company in USD'
categoryLayer={this.props.layers.railaccidents.source}
column='state'
operation={carto.operation.SUM}
operationColumn='equipment_damage'
/>
</div>
<div className="as-p--16">
<Histogram
title='Hour'
Expand Down
11 changes: 4 additions & 7 deletions src/components/widgets/Category.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import carto from '@carto/carto.js';


class Category extends Component {

static defaultProps = {
Expand Down Expand Up @@ -63,12 +62,10 @@ class Category extends Component {

this.dataView.on('dataChanged', ({ categories }) => this.setState({ categories }));

console.log('CATEGORY ', this.state)
this.props.client.addDataview(this.dataView);
}

_createFilter() {
console.log('_createFilter RAN')
const filter = new carto.filter.Category(this.props.column, { in: this.state.selection });
this.props.categoryLayer.addFilter(filter);
this.setState({ filter });
Expand Down Expand Up @@ -109,18 +106,18 @@ class Category extends Component {


render() {
const { heading, description } = this.props;
const { title, description } = this.props;
const { categories, filter, selection } = this.state;

//console.log()
console.log(title)

const showApplyButton = selection.length > 0 && !filter;

return (
<div>
<div className="as-p--16">
<as-category-widget
ref={node => { this.widget = node; }}
heading={heading}
heading={title}
description={description}
categories={categories}
onSelectedChanged={this.onSelectedChanged}
Expand Down
10 changes: 3 additions & 7 deletions src/components/widgets/TextSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@ class TextSearch extends Component {

createFilter() {
const filter = new carto.filter.Category(this.props.column, { similarTo: this.state.value });
this.props.layers.railaccidents.source.addFilter(filter);
this.props.layer.addFilter(filter);
this.setState({ filter });
}

updateFilter() {
const { filter } = this.state;
this.props.layers.railaccidents.source.removeFilter(filter);
this.props.layer.removeFilter(filter);
this.createFilter()
}

setUpFilter() {
const { filter, value } = this.state;
console.log(value)
!filter
? this.createFilter()
: this.updateFilter();
Expand All @@ -73,14 +72,11 @@ class TextSearch extends Component {
const mapStateToProps = state => ({
client: state.client,
map: state.map,
filters: state.filters,
layers: state.layers,
viewport: state.viewport,
boundingbox: state.boundingbox
});

const mapDispatchToProps = dispatch => ({
setNeighbourhoods: selected => dispatch(setNeighbourhoods(selected)),
});
const mapDispatchToProps = dispatch => ({ });

export default connect(mapStateToProps, mapDispatchToProps)(TextSearch);
2 changes: 2 additions & 0 deletions src/data/layers/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import railaccidents from './railaccidents';
// import usstates from './usstates';

// import neighbourhoods from './neighbourhoods';

// Export order will be the layer order
Expand Down
25 changes: 25 additions & 0 deletions src/data/layers/usstates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export default {
name: 'US States',

visible: true,

cartocss: `
#layer {
polygon-fill: #6ba2dc;
polygon-opacity: 1;
}
#layer::outline {
line-width: 1;
line-color: #FFFFFF;
line-opacity: 0.5;
}
`,

query: `
SELECT * FROM us_states
`,

options: {
featureClickColumns: []
}
};

0 comments on commit 33a567c

Please sign in to comment.