Skip to content

Commit

Permalink
1. nginx comment fix
Browse files Browse the repository at this point in the history
2. d3 v6 event fixes for Timeseries brush and zoom / grouped barchart
  • Loading branch information
salivian committed Mar 3, 2021
1 parent a3e28e3 commit 8fb7019
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 33 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ RUN /app/build.sh
WORKDIR /app
ENTRYPOINT ["/app/run.sh"]
CMD ["crime","/data","/data/config.json","/data/crime50k.db"]

#ENTRYPOINT ["/bin/bash"]
5 changes: 3 additions & 2 deletions docker-app/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ http {
server {
listen 80;
proxy_cache mycache;


#nanocubes webpage
location / {
root /www/;
index index.html;
Expand All @@ -25,7 +26,7 @@ http {
proxy_pass http://localhost:54321;
}

#run nanocubes on 54322
#run db rest server on 54322
location ~* /dbrest/(.*)$ {
rewrite ^/dbrest/(.*)$ /$1 break;
proxy_pass http://localhost:54322;
Expand Down
2 changes: 1 addition & 1 deletion web/dist/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!DOCTYPE html><html><head><link rel="stylesheet" href="web.5559dd7d.css"><meta name="viewport" content="initial-scale=1,maximum-scale=1,
user-scalable=no"></head><body> <div id="nc"></div> </body><script src="web.2b93b6b1.js"></script></html>
user-scalable=no"></head><body> <div id="nc"></div> </body><script src="web.2c76e7ee.js"></script></html>
1 change: 0 additions & 1 deletion web/dist/web.2b93b6b1.js.map

This file was deleted.

6 changes: 3 additions & 3 deletions web/dist/web.2b93b6b1.js → web/dist/web.2c76e7ee.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/dist/web.2c76e7ee.js.map

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions web/src/Nanocube/GroupedBarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ function GroupedBarChart(opts, getDataCallback, updateCallback){
this.clearbtn = d3.select(id)
.append('button')
.attr('class','btn')
.on('click',function(){
d3.event.stopPropagation();
.on('click',function(event){
event.stopPropagation();

delete widget.selection.brush; //clear selection
widget.update(); //redraw itself
Expand All @@ -41,8 +41,8 @@ function GroupedBarChart(opts, getDataCallback, updateCallback){
this.sortbtn = d3.select(id)
.append('button')
.attr('class','btn')
.on('click',function(){
d3.event.stopPropagation();
.on('click',function(event){
event.stopPropagation();
widget._opts.alpha_order = !widget._opts.alpha_order;
widget.redraw(widget.lastres);
})
Expand All @@ -52,8 +52,8 @@ function GroupedBarChart(opts, getDataCallback, updateCallback){
this.percentbtn = d3.select(id)
.append('button')
.attr('class','percent-btn')
.on('click',function(){
d3.event.stopPropagation();
.on('click',function(event){
event.stopPropagation();
widget._opts.percent = !widget._opts.percent;
widget.redraw(widget.lastres);
});
Expand Down Expand Up @@ -246,8 +246,8 @@ GroupedBarChart.prototype = {
var newbars = bars.enter()
.append('rect')
.attr('class', 'bar')
.on('click', function(d) {
widget.clickFunc(d); //toggle callback
.on('click', function(event,d) {
widget.clickFunc(event,d); //toggle callback
});

newbars.append('svg:title');
Expand Down Expand Up @@ -283,7 +283,7 @@ GroupedBarChart.prototype = {
});
},

clickFunc:function(d){
clickFunc:function(event,d){
var widget = this;
if(!widget.selection.brush){
widget.selection.brush = [];
Expand All @@ -297,7 +297,7 @@ GroupedBarChart.prototype = {
widget.selection.brush.splice(idx,1);
}
else{
if(d3.event.shiftKey){
if(event.shiftKey){
widget.selection.brush.push({id:d.id, cat:d.cat});
}
else{
Expand Down Expand Up @@ -464,9 +464,9 @@ GroupedBarChart.prototype = {
//enable axis click
var widget = this;
svg.select('.y.axis').selectAll('.tick')
.on('click',function(d){
.on('click',function(event,d){
var obj = data.filter(function(e){return e.cat==d;})[0];
widget.clickFunc(obj);
widget.clickFunc(event,obj);
});

this.totalheight = totalheight;
Expand Down
32 changes: 20 additions & 12 deletions web/src/Nanocube/Timeseries.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function Timeseries(opts,getDataCallback,updateCallback){

//Add percent button
this.percentbtn = d3.select(id).append('button')
.on('click',function(){
d3.event.stopPropagation();
.on('click',function(event){
event.stopPropagation();
widget._opts.percent = !widget._opts.percent;
widget.redraw(widget.lastres);
});
Expand Down Expand Up @@ -126,11 +126,17 @@ function Timeseries(opts,getDataCallback,updateCallback){
.call(widget.yAxis);


//Zoom
//Zoom
widget.zoom=d3.zoom()
.on('zoom', function(){
.on('zoom', function(event){
//ignore mousemove without button down
if(event.sourceEvent.buttons < 1 &&
event.sourceEvent.type=="mousemove"){
return;
}

//rescale
widget.xz = d3.event.transform.rescaleX(widget.x);
widget.xz=event.transform.rescaleX(widget.x);

//redraw
widget.redraw(widget.lastres);
Expand All @@ -142,7 +148,6 @@ function Timeseries(opts,getDataCallback,updateCallback){
widget.brush.selection.map(widget.xz));
}
})

.on('end', function(){
widget.update();
widget.updateCallback(widget._encodeArgs());
Expand All @@ -155,13 +160,13 @@ function Timeseries(opts,getDataCallback,updateCallback){
//Brush
widget.brush = d3.brushX()
.extent([[0, 0], [width, height]])
.on('end', function(){
if(!d3.event.sourceEvent){
.on('end', function(event){
if(!event.sourceEvent){
return;
}

if (d3.event.selection) {
var sel = d3.event.selection;
if (event.selection) {
var sel = event.selection;
//save selection
widget.brush.selection = sel.map(widget.xz.invert);
}
Expand Down Expand Up @@ -351,7 +356,10 @@ Timeseries.prototype={
drawLine:function(data,color){
var m = color.match(/rgba\((.+),(.+),(.+),(.+)\)/);
if(m){
color='#'+ (+m[1]).toString(16)+ (+m[2]).toString(16) + (+m[3]).toString(16);
color='#'+
(+m[1]).toString(16).padStart(2, '0')+
(+m[2]).toString(16).padStart(2, '0')+
(+m[3]).toString(16).padStart(2, '0');
}

var colorid = 'color_'+color.replace('#','');
Expand Down

0 comments on commit 8fb7019

Please sign in to comment.