From 4c2b31db0b42ef9a1182d1b7ddc394911f4bdc34 Mon Sep 17 00:00:00 2001
From: greghutch <4603341+greghutch@users.noreply.github.com>
Date: Tue, 6 Sep 2022 15:44:18 -0700
Subject: [PATCH] feat: compute averages, add london and paris
Changes:
* Add a computation of the average value to the charts.
* Add london and paris as demo cities
---
package.json | 1 -
src/App.js | 3 +++
src/RouteCharts.js | 9 +++++----
src/dataModel/algoFns.js | 4 ++++
src/dataModel/data.js | 28 ++++++++++++++++++++++++++++
src/logo.svg | 8 +++++++-
6 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/package.json b/package.json
index a559d12..952abcd 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,6 @@
"format": "eslint . --fix",
"docs": "echo NOT IMPLEMENTED"
},
- "proxy": "http://localhost:4040",
"eslintConfig": {
"extends": [
"react-app",
diff --git a/src/App.js b/src/App.js
index a4688d6..df582bd 100644
--- a/src/App.js
+++ b/src/App.js
@@ -187,8 +187,11 @@ class App extends React.Component {
regenData: false,
chartData: {
latencyData: chartData.latencyData,
+ latencyMean: chartData.latencyMean,
distanceData: chartData.distanceData,
+ distanceMean: chartData.distanceMean,
durationData: chartData.durationData,
+ durationMean: chartData.durationMean,
},
});
};
diff --git a/src/RouteCharts.js b/src/RouteCharts.js
index 6625486..be101b0 100644
--- a/src/RouteCharts.js
+++ b/src/RouteCharts.js
@@ -35,6 +35,7 @@ class RouteCharts extends React.Component {
if (this.props.chartData.durationData.length === 1) {
return
No data -- routing method not supported in this region?
;
}
+ console.log("gots chartData", this.props.chartData);
return (
Loading Chart
}
data={this.props.chartData.durationData}
options={{
- title: "Route Duration (seconds)",
+ title: `Route Duration (seconds)\nmean: ${this.props.chartData.durationMean}`,
legend: { position: "none" },
histogram: {
minValue: 0,
@@ -60,7 +61,7 @@ class RouteCharts extends React.Component {
loader={Loading Chart
}
data={this.props.chartData.distanceData}
options={{
- title: "Route Length (meters)",
+ title: `Route Length (meters)\nmean: ${this.props.chartData.distanceMean}`,
legend: { position: "none" },
histogram: {
minValue: 0,
@@ -76,11 +77,11 @@ class RouteCharts extends React.Component {
loader={Loading Chart
}
data={this.props.chartData.latencyData}
options={{
- title: "Request Latency (milliseconds)",
+ title: `Request Latency (milliseconds)\nmean: ${this.props.chartData.latencyMean}`,
legend: { position: "none" },
histogram: {
minValue: 0,
- maxValue: 3000,
+ maxValue: 1000,
maxNumBuckets: 100,
bucketSize: 30,
lastBucketPercentile: 5,
diff --git a/src/dataModel/algoFns.js b/src/dataModel/algoFns.js
index c63dd6b..8e40ca4 100644
--- a/src/dataModel/algoFns.js
+++ b/src/dataModel/algoFns.js
@@ -19,6 +19,7 @@ import { getOriginDestinationPairs } from "./data";
import { RouteData } from "./routeData";
import { computeRoutesDirectionsJsSDK } from "../apis/directionsJsSDK";
import { computeRoutesPreferred } from "../apis/routesPreferred";
+import { meanBy } from "lodash";
function getCacheKey(metro, algoDefinition) {
return `${metro}_${JSON.stringify(algoDefinition)}_route`;
@@ -118,8 +119,11 @@ async function GetChartData(map, metro, algoDefinition) {
return {
latencyData: latencyData,
+ latencyMean: meanBy(latencyData.slice(1), (x) => x[1]),
durationData: durationData,
+ durationMean: meanBy(durationData.slice(1), (x) => x[1]),
distanceData: distanceData,
+ distanceMean: meanBy(distanceData.slice(1), (x) => x[1]),
};
}
diff --git a/src/dataModel/data.js b/src/dataModel/data.js
index 9990eeb..982b8a3 100644
--- a/src/dataModel/data.js
+++ b/src/dataModel/data.js
@@ -148,6 +148,34 @@ const metroOptions = [
],
],
},
+ {
+ enabled: true,
+ value: "London",
+ label: "London",
+ paths: [
+ [
+ { lat: 51.693530127447346, lng: -0.4382735734477635 },
+ { lat: 51.665747477216556, lng: 0.18181011008356804 },
+ { lat: 51.26379448345281, lng: 0.22477593375394456 },
+ { lat: 51.242558083640944, lng: -0.7667434474520355 },
+ { lat: 51.74693568962239, lng: -0.7143923202850315 },
+ ],
+ ],
+ },
+ {
+ enabled: true,
+ value: "Paris",
+ label: "Paris",
+ paths: [
+ [
+ { lat: 48.93738979343349, lng: 2.1614455980745033 },
+ { lat: 48.93182654593182, lng: 2.4967512089499837 },
+ { lat: 48.784546112317805, lng: 2.4830713508641318 },
+ { lat: 48.777682210161544, lng: 2.166613008063558 },
+ { lat: 48.93898041799014, lng: 2.1717599219308883 },
+ ],
+ ],
+ },
];
function getMetroPolygon(map, metro, showMetroPolygon) {
diff --git a/src/logo.svg b/src/logo.svg
index 9dfc1c0..46627d1 100644
--- a/src/logo.svg
+++ b/src/logo.svg
@@ -1 +1,7 @@
-
\ No newline at end of file
+;