diff --git a/packages/builder/src/components/design/settings/controls/FieldContext/ExplanationModal/index.svelte b/packages/builder/src/components/design/settings/controls/FieldContext/ExplanationModal/index.svelte index 133b2a51b4..4c9e54ee31 100644 --- a/packages/builder/src/components/design/settings/controls/FieldContext/ExplanationModal/index.svelte +++ b/packages/builder/src/components/design/settings/controls/FieldContext/ExplanationModal/index.svelte @@ -1,6 +1,6 @@ + + +
+ A Date can be used in place of a numeric value, but it will be parsed as a UNIX epoch timestamp, which is the number of milliseconds since Jan 1st 1970. +
+
diff --git a/packages/builder/src/components/design/settings/controls/FieldContext/ExplanationModal/subjects/index.js b/packages/builder/src/components/design/settings/controls/FieldContext/ExplanationModal/subjects/index.js index 5dd1ed5410..32d04e8b0e 100644 --- a/packages/builder/src/components/design/settings/controls/FieldContext/ExplanationModal/subjects/index.js +++ b/packages/builder/src/components/design/settings/controls/FieldContext/ExplanationModal/subjects/index.js @@ -2,3 +2,4 @@ export { default as Column } from "./Column.svelte" export { default as NotRequired } from "./NotRequired.svelte" export { default as StringsAsNumbers } from "./StringsAsNumbers.svelte" export { default as Support } from "./Support.svelte" +export { default as DatesAsNumbers } from "./DatesAsNumbers.svelte" diff --git a/packages/builder/src/components/design/settings/controls/FieldContext/FieldContext.svelte b/packages/builder/src/components/design/settings/controls/FieldContext/FieldContext.svelte index 51bd717ffa..efa8f86bd0 100644 --- a/packages/builder/src/components/design/settings/controls/FieldContext/FieldContext.svelte +++ b/packages/builder/src/components/design/settings/controls/FieldContext/FieldContext.svelte @@ -1,7 +1,7 @@
{/if} - {#if messages.includes(messageConstants.chartDatetime)} - {/if} diff --git a/packages/builder/src/components/design/settings/controls/FieldContext/columnInfo.js b/packages/builder/src/components/design/settings/controls/FieldContext/columnInfo.js index 0faea209f0..5588e44bbc 100644 --- a/packages/builder/src/components/design/settings/controls/FieldContext/columnInfo.js +++ b/packages/builder/src/components/design/settings/controls/FieldContext/columnInfo.js @@ -3,7 +3,7 @@ import { capitalize } from 'lodash'; export const messages = { jsonPrimitivesOnly: Symbol("column-info-json-primitives-only"), stringAsNumber: Symbol("column-info-string-as-number"), - chartDatetime: Symbol("column-info-chart-datetime"), + dateAsNumber: Symbol("column-info-date-as-number"), notRequired: Symbol("column-info-not-required"), contextError: Symbol("column-info-context-error"), } @@ -55,7 +55,6 @@ const getSupportMessage = (type, columnInfo) => { } export const getColumnInfoMessagesAndSupport = (fieldSchema, columnInfo) => { - try { const columnInfoMessagesAndSupport = { support: getSupport(fieldSchema.type, columnInfo), diff --git a/packages/builder/src/components/design/settings/controls/FieldContext/lines/DateAsNumber.svelte b/packages/builder/src/components/design/settings/controls/FieldContext/lines/DateAsNumber.svelte new file mode 100644 index 0000000000..c2c6ca3bd1 --- /dev/null +++ b/packages/builder/src/components/design/settings/controls/FieldContext/lines/DateAsNumber.svelte @@ -0,0 +1,16 @@ + + + + + setExplanationSubject(subjects.datesAsNumbers)} + on:mouseleave={() => setExplanationSubject(subjects.none)} + text="UNIX epoch timestamp" + /> + + diff --git a/packages/builder/src/components/design/settings/controls/FieldContext/lines/index.js b/packages/builder/src/components/design/settings/controls/FieldContext/lines/index.js index 2b593faa83..da819ee9d7 100644 --- a/packages/builder/src/components/design/settings/controls/FieldContext/lines/index.js +++ b/packages/builder/src/components/design/settings/controls/FieldContext/lines/index.js @@ -3,3 +3,4 @@ export { default as NotRequired } from "./NotRequired.svelte" export { default as StringNumber } from "./StringNumber.svelte" export { default as Support } from "./Support.svelte" export { default as JSONPrimitivesOnly } from "./JSONPrimitivesOnly.svelte" +export { default as DateAsNumber } from "./DateAsNumber.svelte" diff --git a/packages/builder/src/components/design/settings/controls/FieldContext/subjects.js b/packages/builder/src/components/design/settings/controls/FieldContext/subjects.js index a0f6ea912c..bad3c88df2 100644 --- a/packages/builder/src/components/design/settings/controls/FieldContext/subjects.js +++ b/packages/builder/src/components/design/settings/controls/FieldContext/subjects.js @@ -2,6 +2,7 @@ const subjects = { column: Symbol("explanation-modal-column"), support: Symbol("explanation-modal-support"), stringsAsNumbers: Symbol("explanation-modal-strings-as-numbers"), + datesAsNumbers: Symbol("explanation-modal-dates-as-numbers"), notRequired: Symbol("explanation-modal-not-required"), none: Symbol("explanation-modal-none") } diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 1975feab58..128e5fe6a7 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -1639,7 +1639,7 @@ "supported": ["number", "boolean"], "partialSupport": [ { "type": "string", "message": "stringAsNumber" }, - { "type": "datetime", "message": "datetimeChart"} + { "type": "datetime", "message": "dateAsNumber"} ], "unsupported": [ { "type": "json", "message": "jsonPrimitivesOnly" } diff --git a/packages/client/src/components/app/charts/BarChart.svelte b/packages/client/src/components/app/charts/BarChart.svelte index e79b8113de..532ce11306 100644 --- a/packages/client/src/components/app/charts/BarChart.svelte +++ b/packages/client/src/components/app/charts/BarChart.svelte @@ -97,23 +97,23 @@ // Add data let useDates = false if (schema[labelColumn]) { - console.log("in here?"); const labelFieldType = schema[labelColumn].type if (horizontal) { builder = builder.yType(labelFieldType).xUnits(yAxisUnits) } else { builder = builder.xType(labelFieldType).yUnits(yAxisUnits) } - console.log(labelFieldType); useDates = labelFieldType === "datetime" } const series = (valueColumns ?? []).map(column => ({ name: column, data: data.map(row => { if (!useDates) { - const value = get(row, column); - console.log("one"); - console.log(value); + const value = get(row, column); + + if (schema[column].type === 'datetime') { + return Date.parse(value) + } if (Array.isArray(value)) { return null; @@ -125,8 +125,7 @@ return value; } else { - console.log("two"); - console.log([row[labelColumn], row[column]]); + // TODO datetimes as labels are passed in this way, but this only updates on value change, so it's broken until you also change the value return [row[labelColumn], row[column]] } }),