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

Commit

Permalink
Bookmark reconstruction (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai Budiu authored Aug 13, 2020
1 parent 91d1565 commit aeedd83
Show file tree
Hide file tree
Showing 31 changed files with 404 additions and 270 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__
*.ear

target/
bookmark/*.json

# Idea files
# see https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems
Expand Down
1 change: 1 addition & 0 deletions bookmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory will contain views which are bookmarked when running on the local machine.
3 changes: 2 additions & 1 deletion uiconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"localDbMenu": true,
"showTestMenu": true,
"enableManagement": true,
"privateIsCsv": true
"privateIsCsv": true,
"hideSuggestions": true
}
36 changes: 23 additions & 13 deletions web/src/main/webapp/dataViews/axisData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
RowValue
} from "../javaBridge";
import {
assert,
assert, assertNever,
binarySearch,
Converters,
formatDate,
Expand Down Expand Up @@ -157,15 +157,16 @@ export class AxisDescription {
}

// This value indicates that some data does not fall within a bucket.
export const NoBucketIndex: number = null;
export const NoBucketIndex: number | null = null;

/**
* Contains all information required to build an axis and a d3 scale associated to it.
*/
export class AxisData {
public scale: AnyScale;
public axis: AxisDescription;
public displayRange: BucketsInfo; // the range used to draw the data; may be adjusted from this.dataRange
// The following are set only when the resolution is set.
public scale: AnyScale | null;
public axis: AxisDescription | null;
public displayRange: BucketsInfo | null; // the range used to draw the data; may be adjusted from this.dataRange

public constructor(public description: IColumnDescription | null, // may be null for e.g., the Y col in a histogram
// dataRange is the original range of the data
Expand All @@ -174,10 +175,10 @@ export class AxisData {
this.displayRange = dataRange;
const kind = description == null ? null : description.kind;
if (dataRange != null) {
if (kindIsString(kind)) {
if (kindIsString(kind!)) {
this.displayRange = {
min: -.5,
max: dataRange.stringQuantiles.length - .5,
max: dataRange.stringQuantiles!.length - .5,
presentCount: dataRange.presentCount,
missingCount: dataRange.missingCount,
allStringsKnown: dataRange.allStringsKnown,
Expand All @@ -186,8 +187,8 @@ export class AxisData {
};
} else if (kind === "Integer") {
this.displayRange = {
min: dataRange.min - .5,
max: dataRange.max + .5,
min: dataRange.min! - .5,
max: dataRange.max! + .5,
presentCount: dataRange.presentCount,
missingCount: dataRange.missingCount
};
Expand All @@ -198,7 +199,9 @@ export class AxisData {
this.axis = null;
}

public getDisplayNameString(schema: SchemaClass): string {
public getDisplayNameString(schema: SchemaClass): string | null {
if (this.description == null)
return null;
return schema.displayName(this.description.name).displayName;
}

Expand Down Expand Up @@ -333,10 +336,12 @@ export class AxisData {
this.axis = new AxisDescription(axisCreator(this.scale), 1, false, null);
break;
}
default: {
console.log("Unexpected data kind for axis" + this.description.kind);
case "Duration": {
// TODO
break;
}
default:
assertNever(this.description.kind);
}
}

Expand Down Expand Up @@ -461,13 +466,18 @@ export class AxisData {
case "Double":
case "Date":
case "Time":
case "Duration":
case "LocalDate":
return new BucketBoundaries(
new BucketBoundary(start, valueKind, true),
new BucketBoundary(end, valueKind, inclusive)
);
case "String":
case "Json":
// handled above
return null;
default:
assert(false, "Unhandled data type " + valueKind);
assertNever(valueKind);
}
}

Expand Down
31 changes: 16 additions & 15 deletions web/src/main/webapp/dataViews/chartView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {event as d3event, mouse as d3mouse} from "d3-selection";
import {AxisData} from "./axisData";
import {Dialog} from "../ui/dialog";
import {NextKReceiver, TableView} from "../modules";
import { assert } from "../util";

/**
* A ChartView is a common base class for many views that
Expand All @@ -45,20 +46,20 @@ export abstract class ChartView<D> extends BigTableView {
/**
* Coordinates of mouse within canvas.
*/
protected selectionOrigin: Point;
protected selectionOrigin: Point | null;
/**
* Rectangle in canvas used to display the current selection.
*/
protected selectionRectangle: D3SvgElement;
/**
* Describes the data currently pointed by the mouse.
*/
protected pointDescription: TextOverlay;
protected pointDescription: TextOverlay | null;
/**
* The main surface on top of which the image is drawn.
* There may exist other surfaces as well besides this one.
*/
protected surface: PlottingSurface;
protected surface: PlottingSurface | null;
/**
* Top-level menu.
*/
Expand Down Expand Up @@ -97,7 +98,7 @@ export abstract class ChartView<D> extends BigTableView {

const order = new RecordOrder(
columns.map(c => { return { columnDescription: c, isAscending: true }}));
const rr = table.createNextKRequest(order, null, Resolution.tableRowsOnScreen);
const rr = table.createNextKRequest(order, null, Resolution.tableRowsOnScreen, null, null);
rr.invoke(new NextKReceiver(newPage, table, rr, false, order, null));
}

Expand All @@ -109,7 +110,7 @@ export abstract class ChartView<D> extends BigTableView {
.on("drag", () => this.dragMove())
.on("end", () => this.dragEnd());

const canvas = this.surface.getCanvas();
const canvas = this.surface!.getCanvas();
canvas.call(drag)
.on("mousemove", () => this.onMouseMove())
.on("mouseenter", () => this.onMouseEnter())
Expand Down Expand Up @@ -149,7 +150,7 @@ export abstract class ChartView<D> extends BigTableView {
* Converts a point coordinate in canvas to a point coordinate in the chart surface.
*/
public canvasToChart(point: Point): Point {
return { x: point.x - this.surface.leftMargin, y: point.y - this.surface.topMargin };
return { x: point.x - this.surface!.leftMargin, y: point.y - this.surface!.topMargin };
}

protected abstract onMouseMove(): void;
Expand All @@ -162,7 +163,7 @@ export abstract class ChartView<D> extends BigTableView {
protected dragStartRectangle(): void {
this.dragging = true;
this.moved = false;
const position = d3mouse(this.surface.getCanvas().node());
const position = d3mouse(this.surface!.getCanvas().node());
this.selectionOrigin = {
x: position[0],
y: position[1] };
Expand Down Expand Up @@ -250,9 +251,9 @@ export abstract class ChartView<D> extends BigTableView {
return false;
}
this.moved = true;
let ox = this.selectionOrigin.x;
let oy = this.selectionOrigin.y;
const position = d3mouse(this.surface.getCanvas().node());
let ox = this.selectionOrigin!.x;
let oy = this.selectionOrigin!.y;
const position = d3mouse(this.surface!.getCanvas().node());
const x = position[0];
const y = position[1];
let width = x - ox;
Expand Down Expand Up @@ -308,16 +309,16 @@ export abstract class ChartView<D> extends BigTableView {
*/
protected filterSelectionRectangle(xl: number, xr: number, yl: number, yr: number,
xAxisData: AxisData, yAxisData: AxisData):
RangeFilterArrayDescription {
RangeFilterArrayDescription | null{
if (xAxisData.axis == null ||
yAxisData.axis == null) {
return null;
}

xl -= this.surface.leftMargin;
xr -= this.surface.leftMargin;
yl -= this.surface.topMargin;
yr -= this.surface.topMargin;
xl -= this.surface!.leftMargin;
xr -= this.surface!.leftMargin;
yl -= this.surface!.topMargin;
yr -= this.surface!.topMargin;
const xRange = xAxisData.getFilter(xl, xr);
const yRange = yAxisData.getFilter(yl, yr);
return {
Expand Down
Loading

0 comments on commit aeedd83

Please sign in to comment.