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
const commonConfig = { | |
env: process.env.NODE_ENV || 'development', | |
port: parseInt(process.env.PORT, 10) || 5000, | |
corsDomain: process.env.CORS_DOMAIN || '*' | |
}; | |
export default commonConfig; |
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
// HTTP SERVER | |
import express from 'express'; | |
import cors from 'cors'; | |
const app = express(); | |
function setPort(port = 5000) { | |
app.set('port', parseInt(port, 10)); | |
} |
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
import server from './server'; | |
server.listen(); | |
export default server; |
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
function brush_endEvent() { | |
const s = d3.event.selection; | |
if (!s && lastSelection !== null) { | |
// Re-scale axis for the last transformation | |
let zx = lastTransform.rescaleX(x); | |
let zy = lastTransform.rescaleY(y); | |
// Calc distance on Axis-X to use in scale | |
let totalX = Math.abs(lastSelection.x2 - lastSelection.x1); |
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
const selection = svgChart.select(".selection"); | |
const posValue = Math.abs(distance); | |
selection.attr('width', posValue * scale).attr('height', posValue); | |
if (xPosition < brushStartPoint.x) { | |
selection.attr('x', xPosition); | |
} | |
if (yPosition < brushStartPoint.y) { | |
selection.attr('y', yPosition); |
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
let xPosition = brushStartPoint.x + distance * scale * xCorMulti; | |
const oldDistance = distance; | |
if (xPosition > width) { | |
distance = (width - brushStartPoint.x) / scale; | |
xPosition = width; | |
} else if (xPosition < 0) { | |
distance = brushStartPoint.x / scale; | |
xPosition = 0; | |
} |
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
if (yPosition > height) { | |
distance = height - brushStartPoint.y; | |
yPosition = height; | |
} else if (yPosition < 0) { | |
distance = -brushStartPoint.y; | |
yPosition = 0; | |
} |
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
function brush_brushEvent() { | |
if (brushStartPoint !== null) { | |
const scale = width / height; | |
const sourceEvent = d3.event.sourceEvent; | |
const mouse = { | |
x: sourceEvent.screenX, | |
y: sourceEvent.screenY | |
}; | |
if (mouse.x < 0) { mouse.x = 0; } | |
if (mouse.y < 0) { mouse.y = 0; } |
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
let brushStartPoint = null; | |
function brush_startEvent() { | |
const sourceEvent = d3.event.sourceEvent; | |
const selection = d3.event.selection; | |
if (sourceEvent.type === 'mousedown') { | |
brushStartPoint = { | |
mouse: { | |
x: sourceEvent.screenX, | |
y: sourceEvent.screenY |
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
const brush = d3.brush().extent([[0, 0], [width, height]]) | |
.on("start", () => { brush_startEvent(); }) | |
.on("brush", () => { brush_brushEvent(); }) | |
.on("end", () => { brush_endEvent(); }) | |
.on("start.nokey", function() { | |
d3.select(window).on("keydown.brush keyup.brush", null); | |
}); | |
const brushSvg = svgChart | |
.append("g") |