aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-12-02 13:22:02 -0500
committerbob <bcz@cs.brown.edu>2019-12-02 13:22:02 -0500
commit1ef06e189a352e5472ee267d44d4b3c96042f03c (patch)
treeeefed629be388e83dc71a7b3c574326fc0343f06 /src/client/views/collections/collectionFreeForm
parent1280c005829cf49fd106fd872afcf4ed6593a2f6 (diff)
parent0595f93dde717b7b6990e9a81c5b43a73a3808d5 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/client/views/collections/collectionFreeForm')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
index e1d23ddcb..4a32c1647 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
@@ -1,5 +1,5 @@
import { Doc, Field, FieldResult } from "../../../../new_fields/Doc";
-import { NumCast, StrCast, Cast } from "../../../../new_fields/Types";
+import { NumCast, StrCast, Cast, DateCast } from "../../../../new_fields/Types";
import { ScriptBox } from "../../ScriptBox";
import { CompileScript } from "../../../util/Scripting";
import { ScriptField } from "../../../../new_fields/ScriptField";
@@ -8,6 +8,7 @@ import { emptyFunction } from "../../../../Utils";
import React = require("react");
import { ObservableMap, runInAction } from "mobx";
import { Id } from "../../../../new_fields/FieldSymbols";
+import { DateField } from "../../../../new_fields/DateField";
interface PivotData {
type: string;
@@ -33,6 +34,16 @@ export interface ViewDefResult {
bounds?: ViewDefBounds;
}
+function toLabel(target: FieldResult<Field>) {
+ if (target instanceof DateField) {
+ const date = DateCast(target).date;
+ if (date) {
+ return `${date.toDateString()} ${date.toTimeString()}`;
+ }
+ }
+ return String(target);
+}
+
export function computePivotLayout(poolData: ObservableMap<string, any>, pivotDoc: Doc, childDocs: Doc[], childPairs: { layout: Doc, data?: Doc }[], viewDefsToJSX: (views: any) => ViewDefResult[]) {
const pivotAxisWidth = NumCast(pivotDoc.pivotWidth, 200);
const pivotColumnGroups = new Map<FieldResult<Field>, Doc[]>();
@@ -58,7 +69,7 @@ export function computePivotLayout(poolData: ObservableMap<string, any>, pivotDo
let xCount = 0;
groupNames.push({
type: "text",
- text: String(key),
+ text: toLabel(key),
x,
y: pivotAxisWidth + 50,
width: pivotAxisWidth * expander * numCols,