Skip to content

Commit

Permalink
Perf improvements
Browse files Browse the repository at this point in the history
Added support for fast url formatting used in focus stem. Also added support for vis tiles beign the same color as their lane and removed all text from vis rects
  • Loading branch information
atruskie committed Dec 24, 2015
1 parent 52a84aa commit a0c7ef5
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 59 deletions.
18 changes: 9 additions & 9 deletions src/app/d3Bindings/eventDistribution/_eventDistribution.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $Paired: (
rgb(251, 154, 153),
rgb(227, 26, 28),
);
$mini-backgrounds: join($Paired, $Set3);
$mini-backgrounds: join(join($Paired, $Set3), join($Paired, $Set3));

$font-size: $font-size-small + 1px;
$smaller-font-size: $font-size-small - 2px;
Expand Down Expand Up @@ -196,7 +196,7 @@ event-distribution-visualisation, event-distribution-visualisation-multi-scale {

//border-left: deeppink solid 1px;
//border-right: blue solid 1px;
fill: $tile-background-color;
//fill: $tile-background-color;

//stroke: rgba(0, 0, 0, 0.5);
//stroke-width: 1px;
Expand All @@ -206,13 +206,13 @@ event-distribution-visualisation, event-distribution-visualisation-multi-scale {
//fill: rgba(0, 0, 255, 0.2);
}

.tile text {
font-size: 8pt;
color: $generating-tile-color;
font-weight: bold;
padding: 0 1px;

}
//.tile text {
// font-size: 8pt;
// color: $generating-tile-color;
// font-weight: bold;
// padding: 0 1px;
//
//}

}

Expand Down
34 changes: 8 additions & 26 deletions src/app/d3Bindings/eventDistribution/distributionVisualisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ angular
self.items = data.items;
itemsTree = data.itemsTree;

self.lanes = new Map();
(data.lanes || []).forEach((item, index) => self.lanes.set(item, index));

self.maximum = data.maximum;
self.minimum = data.minimum;
self.visualizationYMax = data.visualizationYMax;
Expand Down Expand Up @@ -294,25 +297,9 @@ angular
//.data(visibleTiles, tileKey)
//.enter();
failedOrUnknownTileElements.append("rect")
.attr(imageAttrs);

failedOrUnknownTileElements.append("text")
.text(getOffsetDate)
.attr({
y: tilesHeight / 2.0,
x: tileSizePixels / 2.0,
width: tilesWidth,
"text-anchor": "middle",
dy: "0em"
});
failedOrUnknownTileElements.append("text")
.text(getOffsetTime)
.attr({
y: tilesHeight / 2.0,
x: tileSizePixels / 2.0,
width: tileSizePixels,
"text-anchor": "middle",
dy: "1em"
.attr(imageAttrs)
.attr("class", tileDatum => {
return "miniItem" + getCategoryIndex(tileDatum.source);
});

// but always add the image element
Expand Down Expand Up @@ -359,14 +346,9 @@ angular
return self.visualizationTileHeight || 0;
}

function getOffsetDate(d) {
return d.offset.toLocaleDateString();
function getCategoryIndex(d) {
return self.lanes.get(dataFunctions.getCategory(d));
}

function getOffsetTime(d) {
return d.offset.toLocaleTimeString();
}

};
}
]
Expand Down
15 changes: 10 additions & 5 deletions src/app/visualize/visualize.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,16 @@ angular
}

// intentionally not specifying an end offset - let the listen page decide
return $url.formatUri(paths.site.ngRoutes.listen,
{
recordingId: id,
start: startOffsetSeconds
});
/*return $url.formatUri(paths.site.ngRoutes.listen,
{
recordingId: id,
start: startOffsetSeconds
});*/
return $url.formatUriFast(
paths.site.ngRoutes.listenWithStartFast,
id,
startOffsetSeconds
);
},
extentUpdated(newExtent) {
//console.debug(...newExtent);
Expand Down
51 changes: 36 additions & 15 deletions src/baw.paths.nobuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ module.exports = function (environment) {
"ngRoutes": {
"recentRecordings": "/listen",
"listen": "/listen/{recordingId}",
"listenWithStartFast": ["/listen/", "?start="],
"library": "/library",
"libraryItem": "/library/{recordingId}/audio_events/{audioEventId}",
"visualize": "/visualize",
Expand Down Expand Up @@ -153,39 +154,59 @@ module.exports = function (environment) {
return fragments[0];
}
else {
var path = fragments[0];
var firstFragment = fragments[0];

if (path.slice(-1) === "/") {
path = path.slice(0, -1);
if (firstFragment.slice(-1) === "/") {
firstFragment = firstFragment.slice(0, -1);
}

for (var i = 1; i < fragments.length; i++) {
var f = fragments[i];
var path = [firstFragment],
wasAnyArray = false;

if ((typeof f) !== "string") {
throw "joinPathFragments: Path fragment " + f + " is not a string";
function processFragment(stringFragment, isLast) {
if ((typeof stringFragment) !== "string") {
throw "joinPathFragments: Path fragment " + stringFragment + " is not a string";
}

var hasFirst = f[0] === "/";
var hasLast = (f.slice(-1))[0] === "/";
var hasFirst = stringFragment[0] === "/";
var hasLast = (stringFragment.slice(-1))[0] === "/";

if (!hasFirst) {
f = "/" + f;
stringFragment = "/" + stringFragment;
}

if (hasLast && i !== (fragments.length - 1)) {
f = f.slice(0, -1);
if (hasLast && !isLast) {
stringFragment = stringFragment.slice(0, -1);
}

path += f;
return stringFragment;
}

for (var i = 1; i < fragments.length; i++) {
var f = fragments[i];

var isArray = f instanceof Array;
if (isArray) {
wasAnyArray = true;
f.forEach(function(item, index) {
path.push(processFragment(item, i === (fragments.length - 1)));
});
}
else {
path.push(processFragment(f, i === (fragments.length - 1)));
}
}

if (wasAnyArray) {
return path;
}

return path;
return path.join("");
}
}

function isObject(x) {
return typeof x === "object" && x !== null;
return typeof x === "object" && x !== null && !(x instanceof Array);
}

// add helper paths
Expand Down
20 changes: 16 additions & 4 deletions src/components/services/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,23 @@ angular
}
}

function formatUriFast(urlFragments, ...urlValues) {
let length = urlFragments.length;

let url = "";
for(let i = 0; i < length; i++) {
url += urlFragments[i] + urlValues[i];
}

return url;
}

var exported = {
fixedEncodeURIComponent: fixedEncodeURIComponent,
encodeUriQuery: encodeUriQuery,
toKeyValue: toKeyValue,
formatUri: formatUri
fixedEncodeURIComponent,
encodeUriQuery,
toKeyValue,
formatUri,
formatUriFast
};

this.registerRenamer = function(suffix, renamerFunc) {
Expand Down

0 comments on commit a0c7ef5

Please sign in to comment.