Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #66 from sharmalab/feature_state_share
Browse files Browse the repository at this point in the history
updated sharable url and added geochoropleth state code
  • Loading branch information
lastlegion authored Jan 30, 2018
2 parents 535d346 + 694236a commit b69b213
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions public/javascripts/src/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ var NavBar = React.createClass({
{self.state.showSharedUrl ?
<div id="shareurldiv">
<Modal.Dialog>
<Modal.Header>
<Modal.Title>Sharable URL</Modal.Title>
</Modal.Header>
<Modal.Body>
URL copied to clipboard!
<FormControl value={shareurl} type="text" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ var GeoChoroplethMap = React.createClass({
var group = {
all: function () {
return self.props.currData[attributeName].values;
},
order: function () {

},
top: function () {
return self.props.currData[attributeName].values;
Expand Down Expand Up @@ -97,14 +94,24 @@ var GeoChoroplethMap = React.createClass({
.title(function (d) {
return attributeName + ": " + d.key + "\nNo: " + (d.value ? d.value : 0);
});

geo.filterHandler(function(dimension, filters){
if(filters)
dimension.filter(filters);
else
dimension.filter(null);
return filters;
});
/*
var filter = JSON.parse(self.getUrlParam("filter"));
console.log(filter);
console.log("geo");
console.log(filter["Origin_State"]);
if(filter["Origin_State"]){
console.log("geo filter");
geo.filter(filter);
}
*/


dc.renderAll();
self.setState({chart: geo, dimension: dim, group: group});
Expand All @@ -117,6 +124,11 @@ var GeoChoroplethMap = React.createClass({
this.state.chart.filterAll();
this.changeFilterState(false);
},
getUrlParam: function (name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)){
return decodeURIComponent(name[1]);
}
},
render: function () {
/* the color domain needs to be assigned with every render in case the data changed */
if (this.state.group) {
Expand All @@ -140,6 +152,7 @@ var GeoChoroplethMap = React.createClass({
if (queryFilter[attributeName]) {
queryString = queryFilter[attributeName].toString();
}
console.log(queryString);

return(
<div id="geo">
Expand Down

0 comments on commit b69b213

Please sign in to comment.