@deephaven/chart 0.6.3-alpha.5 → 0.6.3-bard.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.d.ts +8 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/Chart.js +20 -6
- package/dist/Chart.js.map +1 -1
- package/dist/ChartModelFactory.d.ts +2 -4
- package/dist/ChartModelFactory.d.ts.map +1 -1
- package/dist/ChartModelFactory.js +2 -9
- package/dist/ChartModelFactory.js.map +1 -1
- package/dist/ChartUtils.d.ts +22 -14
- package/dist/ChartUtils.d.ts.map +1 -1
- package/dist/ChartUtils.js +27 -54
- package/dist/ChartUtils.js.map +1 -1
- package/dist/FigureChartModel.d.ts +18 -3
- package/dist/FigureChartModel.d.ts.map +1 -1
- package/dist/FigureChartModel.js +3 -5
- package/dist/FigureChartModel.js.map +1 -1
- package/dist/MockChartModel.d.ts +51 -3
- package/dist/MockChartModel.d.ts.map +1 -1
- package/dist/MockChartModel.js +1 -1
- package/dist/MockChartModel.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/plotly/Plot.js +2 -5
- package/dist/plotly/Plot.js.map +1 -1
- package/dist/plotly/Plotly.js +2 -7
- package/dist/plotly/Plotly.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
package/dist/Chart.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export class Chart extends React.Component<any, any, any> {
|
|
|
22
22
|
plotWrapper: React.RefObject<any>;
|
|
23
23
|
columnFormats: any[];
|
|
24
24
|
dateTimeFormatterOptions: {};
|
|
25
|
+
decimalFormatOptions: {};
|
|
26
|
+
integerFormatOptions: {};
|
|
25
27
|
rect: any;
|
|
26
28
|
ranges: object | null;
|
|
27
29
|
isSubscribed: boolean;
|
|
@@ -68,6 +70,12 @@ export namespace Chart {
|
|
|
68
70
|
showTimeZone: PropTypes.Validator<boolean>;
|
|
69
71
|
showTSeparator: PropTypes.Validator<boolean>;
|
|
70
72
|
formatter: PropTypes.Validator<(PropTypes.InferProps<{}> | null | undefined)[]>;
|
|
73
|
+
decimalFormatOptions: PropTypes.Requireable<PropTypes.InferProps<{
|
|
74
|
+
defaultFormatString: PropTypes.Requireable<string>;
|
|
75
|
+
}>>;
|
|
76
|
+
integerFormatOptions: PropTypes.Requireable<PropTypes.InferProps<{
|
|
77
|
+
defaultFormatString: PropTypes.Requireable<string>;
|
|
78
|
+
}>>;
|
|
71
79
|
}>>;
|
|
72
80
|
const isActive: PropTypes.Requireable<boolean>;
|
|
73
81
|
const onDisconnect: PropTypes.Requireable<(...args: any[]) => any>;
|
package/dist/Chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../src/Chart.jsx"],"names":[],"mappings":"AAiBA;IACE;;;OAGG;IACH;;;;;;MAWC;IAED,4FAQC;IAED,
|
|
1
|
+
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../src/Chart.jsx"],"names":[],"mappings":"AAiBA;IACE;;;OAGG;IACH;;;;;;MAWC;IAED,4FAQC;IAED,wBAgCC;IA8HD,wBAIC;IAED,8BAcC;IAED,mCAsEC;IAED,oCAcC;IAED,mCAWC;IAED,0DAYC;IA3RC,2BAA6B;IAC7B,kCAAoC;IACpC,qBAAuB;IACvB,6BAAkC;IAClC,yBAA8B;IAC9B,yBAA8B;IAC9B,UAAgB;IAChB,sBAAkB;IAClB,sBAAyB;IACzB,uBAA0B;IA8C5B;;;;;;;;;;;;;;MAmDE;IAEF,mBAEC;IAED,iBAUC;IAED,kBAYC;IAED,oBAQC;IA2ID;;;;;;;OAOG;IACH,8BAFW,OAAO,QAwBjB;IAED,sBAGC;IAED,6CAmBC;IAED,wBAUC;IAED,yBAcC;CAuCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAmCe,uCAAQ;;QACT,sCAAQ;;QACX,mCAAQ;;QACT,kCAAQ;;QACE,4CAAQ"}
|
package/dist/Chart.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2
2
|
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
4
|
|
|
@@ -88,6 +88,8 @@ export class Chart extends Component {
|
|
|
88
88
|
this.plotWrapper = /*#__PURE__*/React.createRef();
|
|
89
89
|
this.columnFormats = [];
|
|
90
90
|
this.dateTimeFormatterOptions = {};
|
|
91
|
+
this.decimalFormatOptions = {};
|
|
92
|
+
this.integerFormatOptions = {};
|
|
91
93
|
this.rect = null;
|
|
92
94
|
this.ranges = null;
|
|
93
95
|
this.isSubscribed = false;
|
|
@@ -195,7 +197,7 @@ export class Chart extends Component {
|
|
|
195
197
|
}
|
|
196
198
|
|
|
197
199
|
handleDownsampleClick() {
|
|
198
|
-
this.setState(_ref => {
|
|
200
|
+
this.setState((_ref) => {
|
|
199
201
|
var {
|
|
200
202
|
isDownsamplingDisabled
|
|
201
203
|
} = _ref;
|
|
@@ -424,16 +426,22 @@ export class Chart extends Component {
|
|
|
424
426
|
updateFormatterSettings(settings) {
|
|
425
427
|
var columnFormats = FormatterUtils.getColumnFormats(settings);
|
|
426
428
|
var dateTimeFormatterOptions = FormatterUtils.getDateTimeFormatterOptions(settings);
|
|
429
|
+
var {
|
|
430
|
+
decimalFormatOptions = {},
|
|
431
|
+
integerFormatOptions = {}
|
|
432
|
+
} = settings;
|
|
427
433
|
|
|
428
|
-
if (!deepEqual(this.columnFormats, columnFormats) || !deepEqual(this.dateTimeFormatterOptions, dateTimeFormatterOptions)) {
|
|
434
|
+
if (!deepEqual(this.columnFormats, columnFormats) || !deepEqual(this.dateTimeFormatterOptions, dateTimeFormatterOptions) || !deepEqual(this.decimalFormatOptions, decimalFormatOptions) || !deepEqual(this.integerFormatOptions, integerFormatOptions)) {
|
|
429
435
|
this.columnFormats = FormatterUtils.getColumnFormats(settings);
|
|
430
|
-
this.dateTimeFormatterOptions =
|
|
436
|
+
this.dateTimeFormatterOptions = dateTimeFormatterOptions;
|
|
437
|
+
this.decimalFormatOptions = decimalFormatOptions;
|
|
438
|
+
this.integerFormatOptions = integerFormatOptions;
|
|
431
439
|
this.updateFormatter();
|
|
432
440
|
}
|
|
433
441
|
}
|
|
434
442
|
|
|
435
443
|
updateFormatter() {
|
|
436
|
-
var formatter = new Formatter(this.columnFormats, this.dateTimeFormatterOptions);
|
|
444
|
+
var formatter = new Formatter(this.columnFormats, this.dateTimeFormatterOptions, this.decimalFormatOptions, this.integerFormatOptions);
|
|
437
445
|
var {
|
|
438
446
|
model
|
|
439
447
|
} = this.props;
|
|
@@ -496,7 +504,13 @@ Chart.propTypes = {
|
|
|
496
504
|
defaultDateTimeFormat: PropTypes.string.isRequired,
|
|
497
505
|
showTimeZone: PropTypes.bool.isRequired,
|
|
498
506
|
showTSeparator: PropTypes.bool.isRequired,
|
|
499
|
-
formatter: PropTypes.arrayOf(PropTypes.shape({})).isRequired
|
|
507
|
+
formatter: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
|
508
|
+
decimalFormatOptions: PropTypes.shape({
|
|
509
|
+
defaultFormatString: PropTypes.string
|
|
510
|
+
}),
|
|
511
|
+
integerFormatOptions: PropTypes.shape({
|
|
512
|
+
defaultFormatString: PropTypes.string
|
|
513
|
+
})
|
|
500
514
|
}),
|
|
501
515
|
isActive: PropTypes.bool,
|
|
502
516
|
onDisconnect: PropTypes.func,
|
package/dist/Chart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Chart.jsx"],"names":["React","Component","PropTypes","deepEqual","memoize","vsLoading","dhGraphLineDown","dhWarningFilled","Formatter","FormatterUtils","DateUtils","Log","Plotly","Plot","ChartModel","ChartUtils","ChartConstants","log","module","Chart","convertIcon","faIcon","width","path","icon","ascent","descent","transform","downsampleButtonTitle","isDownsampleInProgress","isDownsamplingDisabled","constructor","props","downsamplingError","isDownsampleFinished","customButtons","push","name","click","handleDownsampleClick","displaylogo","displayModeBar","modeBarButtons","handleAfterPlot","bind","handleModelEvent","handlePlotUpdate","handleRelayout","handleRestyle","plot","createRef","plotWrapper","columnFormats","dateTimeFormatterOptions","rect","ranges","isSubscribed","isLoadedFired","state","data","layout","datarevision","revision","componentDidMount","updateDimensions","updateModelDimensions","initData","initFormatter","isActive","subscribe","componentDidUpdate","prevProps","settings","updateFormatterSettings","unsubscribe","componentWillUnmount","getPlotRect","current","getBoundingClientRect","model","setState","getData","getLayout","height","debug2","setDownsamplingDisabled","event","type","detail","EVENT_UPDATED","currentSeries","onUpdate","isLoading","EVENT_LOADFINISHED","EVENT_DISCONNECT","onDisconnect","EVENT_RECONNECT","onReconnect","EVENT_DOWNSAMPLESTARTED","EVENT_DOWNSAMPLEFINISHED","EVENT_DOWNSAMPLENEEDED","EVENT_DOWNSAMPLEFAILED","message","onError","Error","debug","figure","getLayoutRanges","isRangesChanged","changes","Object","keys","includes","onSettingsChanged","hiddenSeries","hiddenlabels","seriesIndexes","reduce","acc","visible","force","warn","isRectChanged","setDimensions","getColumnFormats","getDateTimeFormatterOptions","updateFormatter","formatter","setFormatter","relayout","el","autosize","catch","e","render","config","getCachedConfig","isPlotShown","propTypes","instanceOf","isRequired","shape","timeZone","string","defaultDateTimeFormat","showTimeZone","bool","showTSeparator","arrayOf","func","defaultProps","FULL_DATE_FORMAT"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,OAAP,MAAoB,aAApB;AACA,SAASC,SAAT,EAAoBC,eAApB,EAAqCC,eAArC,QAA4D,kBAA5D;AACA,SAASC,SAAT,EAAoBC,cAApB,EAAoCC,SAApC,QAAqD,sBAArD;AACA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,M;OACAC,I;OAEAC,U;OACAC,U;OACAC,c;;AAGP,IAAMC,GAAG,GAAGN,GAAG,CAACO,MAAJ,CAAW,OAAX,CAAZ;AAEA,OAAO,MAAMC,KAAN,SAAoBlB,SAApB,CAA8B;AACnC;AACF;AACA;AACA;AACoB,SAAXmB,WAAW,CAACC,MAAD,EAAS;AACzB,QAAM,CAACC,KAAD,KAAcC,IAAd,IAAsBF,MAAM,CAACG,IAAnC,CADyB,CAEzB;AACA;;AACA,WAAO;AACLF,MAAAA,KADK;AAELC,MAAAA,IAFK;AAGLE,MAAAA,MAAM,EAAEH,KAHH;AAILI,MAAAA,OAAO,EAAE,CAJJ;AAKLC,MAAAA,SAAS;AALJ,KAAP;AAOD;;AAE2B,SAArBC,qBAAqB,CAACC,sBAAD,EAAyBC,sBAAzB,EAAiD;AAC3E,QAAID,sBAAJ,EAA4B;AAC1B,aAAOb,cAAc,CAAC,gCAAD,CAArB;AACD;;AAED,WAAOc,sBAAsB,GACzBd,cAAc,CAAC,6BAAD,CADW,GAEzBA,cAAc,CAAC,4BAAD,CAFlB;AAGD;;AAEDe,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,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WnBN,EAAAA,QAAQ,EAAE,MAAM,CAAE,CAXC;AAYnBY,EAAAA,OAAO,EAAE,MAAM,CAAE,CAZE;AAanBU,EAAAA,iBAAiB,EAAE,MAAM,CAAE;AAbR,CAArB;AAgBA,eAAe9F,KAAf","sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport deepEqual from 'deep-equal';\nimport memoize from 'memoize-one';\nimport { vsLoading, dhGraphLineDown, dhWarningFilled } from '@deephaven/icons';\nimport { Formatter, FormatterUtils, DateUtils } from '@deephaven/iris-grid';\nimport Log from '@deephaven/log';\nimport Plotly from './plotly/Plotly';\nimport Plot from './plotly/Plot';\n\nimport ChartModel from './ChartModel';\nimport ChartUtils from './ChartUtils';\nimport ChartConstants from './Chart.module.scss';\nimport './Chart.scss';\n\nconst log = Log.module('Chart');\n\nexport class Chart extends Component {\n /**\n * Convert a font awesome icon definition to a plotly icon definition\n * @param {FontAwesome.IconDefinition} faIcon The icon to convert\n */\n static convertIcon(faIcon) {\n const [width, , , , path] = faIcon.icon;\n // By default the icons are flipped upside down, so we need to add our own transform\n // https://github.com/plotly/plotly.js/issues/1335\n return {\n width,\n path,\n ascent: width,\n descent: 0,\n transform: `matrix(1, 0, 0, 1, 0, 0)`,\n };\n }\n\n static downsampleButtonTitle(isDownsampleInProgress, isDownsamplingDisabled) {\n if (isDownsampleInProgress) {\n return ChartConstants['title-downsampling-in-progress'];\n }\n\n return isDownsamplingDisabled\n ? ChartConstants['title-downsampling-disabled']\n : ChartConstants['title-downsampling-enabled'];\n }\n\n constructor(props) {\n super(props);\n\n this.handleAfterPlot = this.handleAfterPlot.bind(this);\n this.handleDownsampleClick = this.handleDownsampleClick.bind(this);\n this.handleModelEvent = this.handleModelEvent.bind(this);\n this.handlePlotUpdate = this.handlePlotUpdate.bind(this);\n this.handleRelayout = this.handleRelayout.bind(this);\n this.handleRestyle = this.handleRestyle.bind(this);\n\n this.plot = React.createRef();\n this.plotWrapper = React.createRef();\n this.columnFormats = [];\n this.dateTimeFormatterOptions = {};\n this.rect = null;\n this.ranges = null;\n this.isSubscribed = false;\n this.isLoadedFired = false;\n\n this.state = {\n data: null,\n downsamplingError: null,\n isDownsampleFinished: false,\n isDownsampleInProgress: false,\n isDownsamplingDisabled: false,\n layout: {\n datarevision: 0,\n },\n revision: 0,\n };\n }\n\n componentDidMount() {\n // Need to make sure the model dimensions are up to date before initializing the data\n this.updateDimensions();\n this.updateModelDimensions();\n\n this.initData();\n this.initFormatter();\n\n const { isActive } = this.props;\n if (isActive) {\n this.subscribe();\n }\n }\n\n componentDidUpdate(prevProps) {\n const { isActive, settings } = this.props;\n this.updateFormatterSettings(settings);\n\n if (isActive !== prevProps.isActive) {\n if (isActive) {\n this.subscribe();\n } else {\n this.unsubscribe();\n }\n }\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n getCachedConfig = memoize(\n (\n downsamplingError,\n isDownsampleFinished,\n isDownsampleInProgress,\n isDownsamplingDisabled\n ) => {\n const customButtons = [];\n if (downsamplingError) {\n customButtons.push({\n name: `${ChartConstants['title-downsampling-failed']}: ${downsamplingError}`,\n click: () => {},\n icon: Chart.convertIcon(dhWarningFilled),\n });\n }\n\n if (\n isDownsampleFinished ||\n isDownsampleInProgress ||\n isDownsamplingDisabled ||\n downsamplingError\n ) {\n const name = Chart.downsampleButtonTitle(\n isDownsampleInProgress,\n isDownsamplingDisabled\n );\n const icon = isDownsampleInProgress ? vsLoading : dhGraphLineDown;\n customButtons.push({\n name,\n icon: Chart.convertIcon(icon),\n click: this.handleDownsampleClick,\n });\n }\n\n return {\n displaylogo: false,\n\n // Display the mode bar if there's an error or downsampling so user can see progress\n // Yes, the value is a boolean or the string 'hover': https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L249\n displayModeBar:\n isDownsampleInProgress || downsamplingError ? true : 'hover',\n\n // Each array gets grouped together in the mode bar\n modeBarButtons: [\n customButtons,\n ['toImage'],\n ['zoom2d', 'pan2d'],\n ['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],\n ],\n };\n }\n );\n\n getPlotRect() {\n return this.plotWrapper.current?.getBoundingClientRect() ?? null;\n }\n\n initData() {\n const { model } = this.props;\n const { layout } = this.state;\n this.setState({\n data: model.getData(),\n layout: {\n ...layout,\n ...model.getLayout(),\n },\n });\n }\n\n subscribe() {\n if (this.isSubscribed) {\n return;\n }\n\n const { model } = this.props;\n if (!this.rect || this.rect.width === 0 || this.rect.height === 0) {\n log.debug2('Delaying subscription until model dimensions are set');\n return;\n }\n model.subscribe(this.handleModelEvent);\n this.isSubscribed = true;\n }\n\n unsubscribe() {\n if (!this.isSubscribed) {\n return;\n }\n\n const { model } = this.props;\n model.unsubscribe(this.handleModelEvent);\n this.isSubscribed = false;\n }\n\n handleAfterPlot() {\n if (this.plot.current) {\n // TODO: Translate whatever Don was doing in plotting.js in the afterplot here so that area graphs show up properly\n }\n }\n\n handleDownsampleClick() {\n this.setState(\n ({ isDownsamplingDisabled }) => ({\n downsamplingError: null,\n isDownsampleInProgress: false,\n isDownsampleFinished: false,\n isDownsamplingDisabled: !isDownsamplingDisabled,\n }),\n () => {\n const { model } = this.props;\n const { isDownsamplingDisabled } = this.state;\n model.setDownsamplingDisabled(isDownsamplingDisabled);\n }\n );\n }\n\n handleModelEvent(event) {\n const { type, detail } = event;\n log.debug2('Received data update', type, detail);\n\n switch (type) {\n case ChartModel.EVENT_UPDATED: {\n this.currentSeries += 1;\n this.setState(state => {\n const { layout, revision } = state;\n layout.datarevision += 1;\n return {\n data: detail,\n layout,\n revision: revision + 1,\n };\n });\n\n const { onUpdate } = this.props;\n onUpdate({ isLoading: !this.isLoadedFired });\n break;\n }\n case ChartModel.EVENT_LOADFINISHED: {\n const { onUpdate } = this.props;\n this.isLoadedFired = true;\n onUpdate({ isLoading: false });\n break;\n }\n case ChartModel.EVENT_DISCONNECT: {\n const { onDisconnect } = this.props;\n onDisconnect();\n break;\n }\n case ChartModel.EVENT_RECONNECT: {\n const { onReconnect } = this.props;\n onReconnect();\n break;\n }\n case ChartModel.EVENT_DOWNSAMPLESTARTED: {\n this.setState({\n isDownsampleFinished: false,\n isDownsampleInProgress: true,\n downsamplingError: null,\n });\n break;\n }\n case ChartModel.EVENT_DOWNSAMPLEFINISHED: {\n this.setState({\n isDownsampleFinished: true,\n isDownsampleInProgress: false,\n downsamplingError: null,\n });\n break;\n }\n case ChartModel.EVENT_DOWNSAMPLENEEDED:\n case ChartModel.EVENT_DOWNSAMPLEFAILED: {\n const downsamplingError = detail.message ? detail.message : detail;\n this.setState({\n isDownsampleFinished: false,\n isDownsampleInProgress: false,\n isDownsamplingDisabled: false,\n downsamplingError,\n });\n\n const { onError } = this.props;\n onError(new Error(downsamplingError));\n break;\n }\n default:\n log.debug('Unknown event type', type, event);\n }\n }\n\n handlePlotUpdate(figure) {\n // User could have modified zoom/pan here, update the model dimensions\n // We don't need to update the datarevision, as we don't have any data changes\n // until an update comes back from the server anyway\n const { layout } = figure;\n const ranges = ChartUtils.getLayoutRanges(layout);\n\n const isRangesChanged = !deepEqual(ranges, this.ranges);\n\n if (isRangesChanged) {\n this.ranges = ranges;\n\n this.updateModelDimensions(true);\n }\n }\n\n handleRelayout(changes) {\n log.debug('handleRelayout', changes);\n if (Object.keys(changes).includes('hiddenlabels')) {\n const { onSettingsChanged } = this.props;\n // Pie charts store series visibility in layout.hiddenlabels and trigger relayout on changes\n // Series visibility for other types of charts is handled in handleRestyle\n const hiddenSeries = [...changes.hiddenlabels];\n onSettingsChanged({ hiddenSeries });\n }\n\n this.updateModelDimensions();\n }\n\n handleRestyle([changes, seriesIndexes]) {\n log.debug('handleRestyle', changes, seriesIndexes);\n if (Object.keys(changes).includes('visible')) {\n const { data } = this.state;\n const { onSettingsChanged } = this.props;\n const hiddenSeries = data.reduce(\n (acc, { name, visible }) =>\n visible === 'legendonly' ? [...acc, name] : acc,\n []\n );\n onSettingsChanged({ hiddenSeries });\n }\n }\n\n /**\n * Update the models dimensions and ranges.\n * Note that this will update it all whether the plot size changes OR the range\n * the user is looking at has changed (eg. panning/zooming).\n * Could update each independently, but doing them at the same time keeps the\n * ChartModel API a bit cleaner.\n * @param {boolean} force Force a change even if the chart dimensions haven't changed (eg. after pan/zoom)\n */\n updateModelDimensions(force = false) {\n const rect = this.getPlotRect();\n if (!rect) {\n log.warn('Unable to get plotting rect');\n return;\n }\n\n const isRectChanged =\n !this.rect ||\n this.rect.width !== rect.width ||\n this.rect.height !== rect.height;\n\n if (isRectChanged || force) {\n this.rect = rect;\n\n const { isActive, model } = this.props;\n model.setDimensions(rect);\n // We may need to resubscribe if dimensions were too small before\n if (isActive) {\n this.subscribe();\n }\n }\n }\n\n initFormatter() {\n const { settings } = this.props;\n this.updateFormatterSettings(settings);\n }\n\n updateFormatterSettings(settings) {\n const columnFormats = FormatterUtils.getColumnFormats(settings);\n const dateTimeFormatterOptions = FormatterUtils.getDateTimeFormatterOptions(\n settings\n );\n\n if (\n !deepEqual(this.columnFormats, columnFormats) ||\n !deepEqual(this.dateTimeFormatterOptions, dateTimeFormatterOptions)\n ) {\n this.columnFormats = FormatterUtils.getColumnFormats(settings);\n this.dateTimeFormatterOptions = FormatterUtils.getDateTimeFormatterOptions(\n settings\n );\n this.updateFormatter();\n }\n }\n\n updateFormatter() {\n const formatter = new Formatter(\n this.columnFormats,\n this.dateTimeFormatterOptions\n );\n\n const { model } = this.props;\n model.setFormatter(formatter);\n }\n\n updateDimensions() {\n const rect = this.getPlotRect();\n if (\n this.plot.current != null &&\n rect != null &&\n rect.width > 0 &&\n rect.height > 0\n ) {\n // Call relayout to resize avoiding the debouncing plotly does\n // https://github.com/plotly/plotly.js/issues/2769#issuecomment-402099552\n Plotly.relayout(this.plot.current.el, { autosize: true }).catch(e => {\n log.debug('Unable to resize, promise rejected', e);\n });\n }\n }\n\n render() {\n const {\n data,\n downsamplingError,\n isDownsampleFinished,\n isDownsampleInProgress,\n isDownsamplingDisabled,\n layout,\n revision,\n } = this.state;\n const config = this.getCachedConfig(\n downsamplingError,\n isDownsampleFinished,\n isDownsampleInProgress,\n isDownsamplingDisabled\n );\n const isPlotShown = data != null;\n return (\n <div className=\"h-100 w-100 chart-wrapper\" ref={this.plotWrapper}>\n {isPlotShown && (\n <Plot\n ref={this.plot}\n data={data}\n layout={layout}\n revision={revision}\n config={config}\n onAfterPlot={this.handleAfterPlot}\n onRelayout={this.handleRelayout}\n onUpdate={this.handlePlotUpdate}\n onRestyle={this.handleRestyle}\n useResizeHandler\n style={{ height: '100%', width: '100%' }}\n />\n )}\n </div>\n );\n }\n}\n\nChart.propTypes = {\n model: PropTypes.instanceOf(ChartModel).isRequired,\n // These settings come from the redux store\n settings: PropTypes.shape({\n timeZone: PropTypes.string.isRequired,\n defaultDateTimeFormat: PropTypes.string.isRequired,\n showTimeZone: PropTypes.bool.isRequired,\n showTSeparator: PropTypes.bool.isRequired,\n formatter: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n }),\n isActive: PropTypes.bool,\n onDisconnect: PropTypes.func,\n onReconnect: PropTypes.func,\n onUpdate: PropTypes.func,\n onError: PropTypes.func,\n onSettingsChanged: PropTypes.func,\n};\n\nChart.defaultProps = {\n isActive: true,\n settings: {\n timeZone: 'America/New_York',\n defaultDateTimeFormat: DateUtils.FULL_DATE_FORMAT,\n showTimeZone: false,\n showTSeparator: true,\n formatter: [],\n },\n onDisconnect: () => {},\n onReconnect: () => {},\n onUpdate: () => {},\n onError: () => {},\n onSettingsChanged: () => {},\n};\n\nexport default Chart;\n"],"file":"Chart.js"}
|
|
1
|
+
{"version":3,"sources":["../src/Chart.jsx"],"names":["React","Component","PropTypes","deepEqual","memoize","vsLoading","dhGraphLineDown","dhWarningFilled","Formatter","FormatterUtils","DateUtils","Log","Plotly","Plot","ChartModel","ChartUtils","ChartConstants","log","module","Chart","convertIcon","faIcon","width","path","icon","ascent","descent","transform","downsampleButtonTitle","isDownsampleInProgress","isDownsamplingDisabled","constructor","props","downsamplingError","isDownsampleFinished","customButtons","push","name","click","handleDownsampleClick","displaylogo","displayModeBar","modeBarButtons","handleAfterPlot","bind","handleModelEvent","handlePlotUpdate","handleRelayout","handleRestyle","plot","createRef","plotWrapper","columnFormats","dateTimeFormatterOptions","decimalFormatOptions","integerFormatOptions","rect","ranges","isSubscribed","isLoadedFired","state","data","layout","datarevision","revision","componentDidMount","updateDimensions","updateModelDimensions","initData","initFormatter","isActive","subscribe","componentDidUpdate","prevProps","settings","updateFormatterSettings","unsubscribe","componentWillUnmount","getPlotRect","current","getBoundingClientRect","model","setState","getData","getLayout","height","debug2","setDownsamplingDisabled","event","type","detail","EVENT_UPDATED","currentSeries","onUpdate","isLoading","EVENT_LOADFINISHED","EVENT_DISCONNECT","onDisconnect","EVENT_RECONNECT","onReconnect","EVENT_DOWNSAMPLESTARTED","EVENT_DOWNSAMPLEFINISHED","EVENT_DOWNSAMPLENEEDED","EVENT_DOWNSAMPLEFAILED","message","onError","Error","debug","figure","getLayoutRanges","isRangesChanged","changes","Object","keys","includes","onSettingsChanged","hiddenSeries","hiddenlabels","seriesIndexes","reduce","acc","visible","force","warn","isRectChanged","setDimensions","getColumnFormats","getDateTimeFormatterOptions","updateFormatter","formatter","setFormatter","relayout","el","autosize","catch","e","render","config","getCachedConfig","isPlotShown","propTypes","instanceOf","isRequired","shape","timeZone","string","defaultDateTimeFormat","showTimeZone","bool","showTSeparator","arrayOf","defaultFormatString","func","defaultProps","FULL_DATE_FORMAT"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,OAAP,MAAoB,aAApB;AACA,SAASC,SAAT,EAAoBC,eAApB,EAAqCC,eAArC,QAA4D,kBAA5D;AACA,SAASC,SAAT,EAAoBC,cAApB,EAAoCC,SAApC,QAAqD,sBAArD;AACA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,M;OACAC,I;OAEAC,U;OACAC,U;OACAC,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GAFS;AASnBhC,EAAAA,YAAY,EAAE,MAAM,CAAE,CATH;AAUnBE,EAAAA,WAAW,EAAE,MAAM,CAAE,CAVF;AAWnBN,EAAAA,QAAQ,EAAE,MAAM,CAAE,CAXC;AAYnBY,EAAAA,OAAO,EAAE,MAAM,CAAE,CAZE;AAanBU,EAAAA,iBAAiB,EAAE,MAAM,CAAE;AAbR,CAArB;AAgBA,eAAehG,KAAf","sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport deepEqual from 'deep-equal';\nimport memoize from 'memoize-one';\nimport { vsLoading, dhGraphLineDown, dhWarningFilled } from '@deephaven/icons';\nimport { Formatter, FormatterUtils, DateUtils } from '@deephaven/iris-grid';\nimport Log from '@deephaven/log';\nimport Plotly from './plotly/Plotly';\nimport Plot from './plotly/Plot';\n\nimport ChartModel from './ChartModel';\nimport ChartUtils from './ChartUtils';\nimport ChartConstants from './Chart.module.scss';\nimport './Chart.scss';\n\nconst log = Log.module('Chart');\n\nexport class Chart extends Component {\n /**\n * Convert a font awesome icon definition to a plotly icon definition\n * @param {FontAwesome.IconDefinition} faIcon The icon to convert\n */\n static convertIcon(faIcon) {\n const [width, , , , path] = faIcon.icon;\n // By default the icons are flipped upside down, so we need to add our own transform\n // https://github.com/plotly/plotly.js/issues/1335\n return {\n width,\n path,\n ascent: width,\n descent: 0,\n transform: `matrix(1, 0, 0, 1, 0, 0)`,\n };\n }\n\n static downsampleButtonTitle(isDownsampleInProgress, isDownsamplingDisabled) {\n if (isDownsampleInProgress) {\n return ChartConstants['title-downsampling-in-progress'];\n }\n\n return isDownsamplingDisabled\n ? ChartConstants['title-downsampling-disabled']\n : ChartConstants['title-downsampling-enabled'];\n }\n\n constructor(props) {\n super(props);\n\n this.handleAfterPlot = this.handleAfterPlot.bind(this);\n this.handleDownsampleClick = this.handleDownsampleClick.bind(this);\n this.handleModelEvent = this.handleModelEvent.bind(this);\n this.handlePlotUpdate = this.handlePlotUpdate.bind(this);\n this.handleRelayout = this.handleRelayout.bind(this);\n this.handleRestyle = this.handleRestyle.bind(this);\n\n this.plot = React.createRef();\n this.plotWrapper = React.createRef();\n this.columnFormats = [];\n this.dateTimeFormatterOptions = {};\n this.decimalFormatOptions = {};\n this.integerFormatOptions = {};\n this.rect = null;\n this.ranges = null;\n this.isSubscribed = false;\n this.isLoadedFired = false;\n\n this.state = {\n data: null,\n downsamplingError: null,\n isDownsampleFinished: false,\n isDownsampleInProgress: false,\n isDownsamplingDisabled: false,\n layout: {\n datarevision: 0,\n },\n revision: 0,\n };\n }\n\n componentDidMount() {\n // Need to make sure the model dimensions are up to date before initializing the data\n this.updateDimensions();\n this.updateModelDimensions();\n\n this.initData();\n this.initFormatter();\n\n const { isActive } = this.props;\n if (isActive) {\n this.subscribe();\n }\n }\n\n componentDidUpdate(prevProps) {\n const { isActive, settings } = this.props;\n this.updateFormatterSettings(settings);\n\n if (isActive !== prevProps.isActive) {\n if (isActive) {\n this.subscribe();\n } else {\n this.unsubscribe();\n }\n }\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n getCachedConfig = memoize(\n (\n downsamplingError,\n isDownsampleFinished,\n isDownsampleInProgress,\n isDownsamplingDisabled\n ) => {\n const customButtons = [];\n if (downsamplingError) {\n customButtons.push({\n name: `${ChartConstants['title-downsampling-failed']}: ${downsamplingError}`,\n click: () => {},\n icon: Chart.convertIcon(dhWarningFilled),\n });\n }\n\n if (\n isDownsampleFinished ||\n isDownsampleInProgress ||\n isDownsamplingDisabled ||\n downsamplingError\n ) {\n const name = Chart.downsampleButtonTitle(\n isDownsampleInProgress,\n isDownsamplingDisabled\n );\n const icon = isDownsampleInProgress ? vsLoading : dhGraphLineDown;\n customButtons.push({\n name,\n icon: Chart.convertIcon(icon),\n click: this.handleDownsampleClick,\n });\n }\n\n return {\n displaylogo: false,\n\n // Display the mode bar if there's an error or downsampling so user can see progress\n // Yes, the value is a boolean or the string 'hover': https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L249\n displayModeBar:\n isDownsampleInProgress || downsamplingError ? true : 'hover',\n\n // Each array gets grouped together in the mode bar\n modeBarButtons: [\n customButtons,\n ['toImage'],\n ['zoom2d', 'pan2d'],\n ['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],\n ],\n };\n }\n );\n\n getPlotRect() {\n return this.plotWrapper.current?.getBoundingClientRect() ?? null;\n }\n\n initData() {\n const { model } = this.props;\n const { layout } = this.state;\n this.setState({\n data: model.getData(),\n layout: {\n ...layout,\n ...model.getLayout(),\n },\n });\n }\n\n subscribe() {\n if (this.isSubscribed) {\n return;\n }\n\n const { model } = this.props;\n if (!this.rect || this.rect.width === 0 || this.rect.height === 0) {\n log.debug2('Delaying subscription until model dimensions are set');\n return;\n }\n model.subscribe(this.handleModelEvent);\n this.isSubscribed = true;\n }\n\n unsubscribe() {\n if (!this.isSubscribed) {\n return;\n }\n\n const { model } = this.props;\n model.unsubscribe(this.handleModelEvent);\n this.isSubscribed = false;\n }\n\n handleAfterPlot() {\n if (this.plot.current) {\n // TODO: Translate whatever Don was doing in plotting.js in the afterplot here so that area graphs show up properly\n }\n }\n\n handleDownsampleClick() {\n this.setState(\n ({ isDownsamplingDisabled }) => ({\n downsamplingError: null,\n isDownsampleInProgress: false,\n isDownsampleFinished: false,\n isDownsamplingDisabled: !isDownsamplingDisabled,\n }),\n () => {\n const { model } = this.props;\n const { isDownsamplingDisabled } = this.state;\n model.setDownsamplingDisabled(isDownsamplingDisabled);\n }\n );\n }\n\n handleModelEvent(event) {\n const { type, detail } = event;\n log.debug2('Received data update', type, detail);\n\n switch (type) {\n case ChartModel.EVENT_UPDATED: {\n this.currentSeries += 1;\n this.setState(state => {\n const { layout, revision } = state;\n layout.datarevision += 1;\n return {\n data: detail,\n layout,\n revision: revision + 1,\n };\n });\n\n const { onUpdate } = this.props;\n onUpdate({ isLoading: !this.isLoadedFired });\n break;\n }\n case ChartModel.EVENT_LOADFINISHED: {\n const { onUpdate } = this.props;\n this.isLoadedFired = true;\n onUpdate({ isLoading: false });\n break;\n }\n case ChartModel.EVENT_DISCONNECT: {\n const { onDisconnect } = this.props;\n onDisconnect();\n break;\n }\n case ChartModel.EVENT_RECONNECT: {\n const { onReconnect } = this.props;\n onReconnect();\n break;\n }\n case ChartModel.EVENT_DOWNSAMPLESTARTED: {\n this.setState({\n isDownsampleFinished: false,\n isDownsampleInProgress: true,\n downsamplingError: null,\n });\n break;\n }\n case ChartModel.EVENT_DOWNSAMPLEFINISHED: {\n this.setState({\n isDownsampleFinished: true,\n isDownsampleInProgress: false,\n downsamplingError: null,\n });\n break;\n }\n case ChartModel.EVENT_DOWNSAMPLENEEDED:\n case ChartModel.EVENT_DOWNSAMPLEFAILED: {\n const downsamplingError = detail.message ? detail.message : detail;\n this.setState({\n isDownsampleFinished: false,\n isDownsampleInProgress: false,\n isDownsamplingDisabled: false,\n downsamplingError,\n });\n\n const { onError } = this.props;\n onError(new Error(downsamplingError));\n break;\n }\n default:\n log.debug('Unknown event type', type, event);\n }\n }\n\n handlePlotUpdate(figure) {\n // User could have modified zoom/pan here, update the model dimensions\n // We don't need to update the datarevision, as we don't have any data changes\n // until an update comes back from the server anyway\n const { layout } = figure;\n const ranges = ChartUtils.getLayoutRanges(layout);\n\n const isRangesChanged = !deepEqual(ranges, this.ranges);\n\n if (isRangesChanged) {\n this.ranges = ranges;\n\n this.updateModelDimensions(true);\n }\n }\n\n handleRelayout(changes) {\n log.debug('handleRelayout', changes);\n if (Object.keys(changes).includes('hiddenlabels')) {\n const { onSettingsChanged } = this.props;\n // Pie charts store series visibility in layout.hiddenlabels and trigger relayout on changes\n // Series visibility for other types of charts is handled in handleRestyle\n const hiddenSeries = [...changes.hiddenlabels];\n onSettingsChanged({ hiddenSeries });\n }\n\n this.updateModelDimensions();\n }\n\n handleRestyle([changes, seriesIndexes]) {\n log.debug('handleRestyle', changes, seriesIndexes);\n if (Object.keys(changes).includes('visible')) {\n const { data } = this.state;\n const { onSettingsChanged } = this.props;\n const hiddenSeries = data.reduce(\n (acc, { name, visible }) =>\n visible === 'legendonly' ? [...acc, name] : acc,\n []\n );\n onSettingsChanged({ hiddenSeries });\n }\n }\n\n /**\n * Update the models dimensions and ranges.\n * Note that this will update it all whether the plot size changes OR the range\n * the user is looking at has changed (eg. panning/zooming).\n * Could update each independently, but doing them at the same time keeps the\n * ChartModel API a bit cleaner.\n * @param {boolean} force Force a change even if the chart dimensions haven't changed (eg. after pan/zoom)\n */\n updateModelDimensions(force = false) {\n const rect = this.getPlotRect();\n if (!rect) {\n log.warn('Unable to get plotting rect');\n return;\n }\n\n const isRectChanged =\n !this.rect ||\n this.rect.width !== rect.width ||\n this.rect.height !== rect.height;\n\n if (isRectChanged || force) {\n this.rect = rect;\n\n const { isActive, model } = this.props;\n model.setDimensions(rect);\n // We may need to resubscribe if dimensions were too small before\n if (isActive) {\n this.subscribe();\n }\n }\n }\n\n initFormatter() {\n const { settings } = this.props;\n this.updateFormatterSettings(settings);\n }\n\n updateFormatterSettings(settings) {\n const columnFormats = FormatterUtils.getColumnFormats(settings);\n const dateTimeFormatterOptions = FormatterUtils.getDateTimeFormatterOptions(\n settings\n );\n const { decimalFormatOptions = {}, integerFormatOptions = {} } = settings;\n\n if (\n !deepEqual(this.columnFormats, columnFormats) ||\n !deepEqual(this.dateTimeFormatterOptions, dateTimeFormatterOptions) ||\n !deepEqual(this.decimalFormatOptions, decimalFormatOptions) ||\n !deepEqual(this.integerFormatOptions, integerFormatOptions)\n ) {\n this.columnFormats = FormatterUtils.getColumnFormats(settings);\n this.dateTimeFormatterOptions = dateTimeFormatterOptions;\n this.decimalFormatOptions = decimalFormatOptions;\n this.integerFormatOptions = integerFormatOptions;\n this.updateFormatter();\n }\n }\n\n updateFormatter() {\n const formatter = new Formatter(\n this.columnFormats,\n this.dateTimeFormatterOptions,\n this.decimalFormatOptions,\n this.integerFormatOptions\n );\n\n const { model } = this.props;\n model.setFormatter(formatter);\n }\n\n updateDimensions() {\n const rect = this.getPlotRect();\n if (\n this.plot.current != null &&\n rect != null &&\n rect.width > 0 &&\n rect.height > 0\n ) {\n // Call relayout to resize avoiding the debouncing plotly does\n // https://github.com/plotly/plotly.js/issues/2769#issuecomment-402099552\n Plotly.relayout(this.plot.current.el, { autosize: true }).catch(e => {\n log.debug('Unable to resize, promise rejected', e);\n });\n }\n }\n\n render() {\n const {\n data,\n downsamplingError,\n isDownsampleFinished,\n isDownsampleInProgress,\n isDownsamplingDisabled,\n layout,\n revision,\n } = this.state;\n const config = this.getCachedConfig(\n downsamplingError,\n isDownsampleFinished,\n isDownsampleInProgress,\n isDownsamplingDisabled\n );\n const isPlotShown = data != null;\n return (\n <div className=\"h-100 w-100 chart-wrapper\" ref={this.plotWrapper}>\n {isPlotShown && (\n <Plot\n ref={this.plot}\n data={data}\n layout={layout}\n revision={revision}\n config={config}\n onAfterPlot={this.handleAfterPlot}\n onRelayout={this.handleRelayout}\n onUpdate={this.handlePlotUpdate}\n onRestyle={this.handleRestyle}\n useResizeHandler\n style={{ height: '100%', width: '100%' }}\n />\n )}\n </div>\n );\n }\n}\n\nChart.propTypes = {\n model: PropTypes.instanceOf(ChartModel).isRequired,\n // These settings come from the redux store\n settings: PropTypes.shape({\n timeZone: PropTypes.string.isRequired,\n defaultDateTimeFormat: PropTypes.string.isRequired,\n showTimeZone: PropTypes.bool.isRequired,\n showTSeparator: PropTypes.bool.isRequired,\n formatter: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n decimalFormatOptions: PropTypes.shape({\n defaultFormatString: PropTypes.string,\n }),\n integerFormatOptions: PropTypes.shape({\n defaultFormatString: PropTypes.string,\n }),\n }),\n isActive: PropTypes.bool,\n onDisconnect: PropTypes.func,\n onReconnect: PropTypes.func,\n onUpdate: PropTypes.func,\n onError: PropTypes.func,\n onSettingsChanged: PropTypes.func,\n};\n\nChart.defaultProps = {\n isActive: true,\n settings: {\n timeZone: 'America/New_York',\n defaultDateTimeFormat: DateUtils.FULL_DATE_FORMAT,\n showTimeZone: false,\n showTSeparator: true,\n formatter: [],\n },\n onDisconnect: () => {},\n onReconnect: () => {},\n onUpdate: () => {},\n onError: () => {},\n onSettingsChanged: () => {},\n};\n\nexport default Chart;\n"],"file":"Chart.js"}
|
|
@@ -11,7 +11,6 @@ declare class ChartModelFactory {
|
|
|
11
11
|
* @param {string} settings.xAxis The column name to use for the x-axis
|
|
12
12
|
* @param {string[]} settings.hiddenSeries Array of hidden series names
|
|
13
13
|
* @param {dh.Table} table The table to build the model for
|
|
14
|
-
* @param {Object} theme The theme for the figure. Defaults to ChartTheme
|
|
15
14
|
* @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure
|
|
16
15
|
*/
|
|
17
16
|
static makeModelFromSettings(settings: {
|
|
@@ -21,7 +20,7 @@ declare class ChartModelFactory {
|
|
|
21
20
|
type: string;
|
|
22
21
|
xAxis: string;
|
|
23
22
|
hiddenSeries: string[];
|
|
24
|
-
}, table: any
|
|
23
|
+
}, table: any): Promise<FigureChartModel>;
|
|
25
24
|
/**
|
|
26
25
|
* Creates a model from the settings provided.
|
|
27
26
|
* Tries to create a Figure in the API with it.
|
|
@@ -33,7 +32,6 @@ declare class ChartModelFactory {
|
|
|
33
32
|
* @param {string} settings.xAxis The column name to use for the x-axis
|
|
34
33
|
* @param {string[]} settings.hiddenSeries Array of hidden series names
|
|
35
34
|
* @param {dh.Figure} figure The figure to build the model for
|
|
36
|
-
* @param {Object} theme The theme for the figure. Defaults to ChartTheme
|
|
37
35
|
* @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure
|
|
38
36
|
*/
|
|
39
37
|
static makeModel(settings: {
|
|
@@ -43,7 +41,7 @@ declare class ChartModelFactory {
|
|
|
43
41
|
type: string;
|
|
44
42
|
xAxis: string;
|
|
45
43
|
hiddenSeries: string[];
|
|
46
|
-
}, figure: any
|
|
44
|
+
}, figure: any): Promise<FigureChartModel>;
|
|
47
45
|
}
|
|
48
46
|
import FigureChartModel from "./FigureChartModel";
|
|
49
47
|
//# sourceMappingURL=ChartModelFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartModelFactory.d.ts","sourceRoot":"","sources":["../src/ChartModelFactory.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ChartModelFactory.d.ts","sourceRoot":"","sources":["../src/ChartModelFactory.js"],"names":[],"mappings":";AAIA;IACE;;;;;;;;;;;;OAYG;IACH;QAT6B,QAAQ,EAA1B,OAAO;QACY,MAAM,EAAzB,MAAM,EAAE;QACS,aAAa,EAA9B,MAAM;QACW,IAAI,EAArB,MAAM;QACW,KAAK,EAAtB,MAAM;QACa,YAAY,EAA/B,MAAM,EAAE;oBAEN,QAAQ,gBAAgB,CAAC,CAgBrC;IAED;;;;;;;;;;;;OAYG;IACH;QAT6B,QAAQ,EAA1B,OAAO;QACY,MAAM,EAAzB,MAAM,EAAE;QACS,aAAa,EAA9B,MAAM;QACW,IAAI,EAArB,MAAM;QACW,KAAK,EAAtB,MAAM;QACa,YAAY,EAA/B,MAAM,EAAE;qBAEN,QAAQ,gBAAgB,CAAC,CAIrC;CACF"}
|
|
@@ -5,7 +5,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
5
5
|
import dh from '@deephaven/jsapi-shim';
|
|
6
6
|
import ChartUtils from "./ChartUtils.js";
|
|
7
7
|
import FigureChartModel from "./FigureChartModel.js";
|
|
8
|
-
import ChartTheme from "./ChartTheme.js";
|
|
9
8
|
|
|
10
9
|
class ChartModelFactory {
|
|
11
10
|
/**
|
|
@@ -19,13 +18,10 @@ class ChartModelFactory {
|
|
|
19
18
|
* @param {string} settings.xAxis The column name to use for the x-axis
|
|
20
19
|
* @param {string[]} settings.hiddenSeries Array of hidden series names
|
|
21
20
|
* @param {dh.Table} table The table to build the model for
|
|
22
|
-
* @param {Object} theme The theme for the figure. Defaults to ChartTheme
|
|
23
21
|
* @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure
|
|
24
22
|
*/
|
|
25
23
|
static makeModelFromSettings(settings, table) {
|
|
26
|
-
var _arguments = arguments;
|
|
27
24
|
return _asyncToGenerator(function* () {
|
|
28
|
-
var theme = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : ChartTheme;
|
|
29
25
|
// Copy the table first and then re-apply the filters from the original table
|
|
30
26
|
// When we add table linking we'll want to listen to the original table and update
|
|
31
27
|
// the copied table with any changes that occur.
|
|
@@ -34,7 +30,7 @@ class ChartModelFactory {
|
|
|
34
30
|
tableCopy.applyCustomColumns(table.customColumns);
|
|
35
31
|
tableCopy.applyFilter(table.filter);
|
|
36
32
|
tableCopy.applySort(table.sort);
|
|
37
|
-
return dh.plot.Figure.create(ChartUtils.makeFigureSettings(settings, tableCopy)).then(figure => new FigureChartModel(figure, settings
|
|
33
|
+
return dh.plot.Figure.create(ChartUtils.makeFigureSettings(settings, tableCopy)).then(figure => new FigureChartModel(figure, settings));
|
|
38
34
|
});
|
|
39
35
|
})();
|
|
40
36
|
}
|
|
@@ -49,16 +45,13 @@ class ChartModelFactory {
|
|
|
49
45
|
* @param {string} settings.xAxis The column name to use for the x-axis
|
|
50
46
|
* @param {string[]} settings.hiddenSeries Array of hidden series names
|
|
51
47
|
* @param {dh.Figure} figure The figure to build the model for
|
|
52
|
-
* @param {Object} theme The theme for the figure. Defaults to ChartTheme
|
|
53
48
|
* @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure
|
|
54
49
|
*/
|
|
55
50
|
|
|
56
51
|
|
|
57
52
|
static makeModel(settings, figure) {
|
|
58
|
-
var _arguments2 = arguments;
|
|
59
53
|
return _asyncToGenerator(function* () {
|
|
60
|
-
|
|
61
|
-
return new FigureChartModel(figure, settings, theme);
|
|
54
|
+
return new FigureChartModel(figure, settings);
|
|
62
55
|
})();
|
|
63
56
|
}
|
|
64
57
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ChartModelFactory.js"],"names":["dh","ChartUtils","FigureChartModel","
|
|
1
|
+
{"version":3,"sources":["../src/ChartModelFactory.js"],"names":["dh","ChartUtils","FigureChartModel","ChartModelFactory","makeModelFromSettings","settings","table","copy","then","tableCopy","applyCustomColumns","customColumns","applyFilter","filter","applySort","sort","plot","Figure","create","makeFigureSettings","figure","makeModel"],"mappings":";;;;AAAA,OAAOA,EAAP,MAAe,uBAAf;OACOC,U;OACAC,gB;;AAEP,MAAMC,iBAAN,CAAwB;AACtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACoC,SAArBC,qBAAqB,CAACC,QAAD,EAAWC,KAAX,EAAkB;AAAA;AAClD;AACA;AACA;AACA;AACA,aAAOA,KAAK,CAACC,IAAN,GAAaC,IAAb,CAAkBC,SAAS,IAAI;AACpCA,QAAAA,SAAS,CAACC,kBAAV,CAA6BJ,KAAK,CAACK,aAAnC;AACAF,QAAAA,SAAS,CAACG,WAAV,CAAsBN,KAAK,CAACO,MAA5B;AACAJ,QAAAA,SAAS,CAACK,SAAV,CAAoBR,KAAK,CAACS,IAA1B;AAEA,eAAOf,EAAE,CAACgB,IAAH,CAAQC,MAAR,CAAeC,MAAf,CACLjB,UAAU,CAACkB,kBAAX,CAA8Bd,QAA9B,EAAwCI,SAAxC,CADK,EAELD,IAFK,CAEAY,MAAM,IAAI,IAAIlB,gBAAJ,CAAqBkB,MAArB,EAA6Bf,QAA7B,CAFV,CAAP;AAGD,OARM,CAAP;AALkD;AAcnD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACwB,SAATgB,SAAS,CAAChB,QAAD,EAAWe,MAAX,EAAmB;AAAA;AACvC,aAAO,IAAIlB,gBAAJ,CAAqBkB,MAArB,EAA6Bf,QAA7B,CAAP;AADuC;AAExC;;AA7CqB;;AAgDxB,eAAeF,iBAAf","sourcesContent":["import dh from '@deephaven/jsapi-shim';\nimport ChartUtils from './ChartUtils';\nimport FigureChartModel from './FigureChartModel';\n\nclass ChartModelFactory {\n /**\n * Creates a model from the settings provided.\n * Tries to create a Figure in the API with it.\n * @param {Object} settings The chart builder settings\n * @param {boolean} settings.isLinked Whether the newly created chart should stay linked with the original table, update when filters are updated\n * @param {string[]} settings.series The column names to use for creating the series of this chart\n * @param {string} settings.sourcePanelId The panel ID the chart was created from\n * @param {string} settings.type Chart builder type, from ChartBuilder.types\n * @param {string} settings.xAxis The column name to use for the x-axis\n * @param {string[]} settings.hiddenSeries Array of hidden series names\n * @param {dh.Table} table The table to build the model for\n * @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure\n */\n static async makeModelFromSettings(settings, table) {\n // Copy the table first and then re-apply the filters from the original table\n // When we add table linking we'll want to listen to the original table and update\n // the copied table with any changes that occur.\n // The table gets owned by the Figure that gets created, which closes the table\n return table.copy().then(tableCopy => {\n tableCopy.applyCustomColumns(table.customColumns);\n tableCopy.applyFilter(table.filter);\n tableCopy.applySort(table.sort);\n\n return dh.plot.Figure.create(\n ChartUtils.makeFigureSettings(settings, tableCopy)\n ).then(figure => new FigureChartModel(figure, settings));\n });\n }\n\n /**\n * Creates a model from the settings provided.\n * Tries to create a Figure in the API with it.\n * @param {Object} settings The chart builder settings\n * @param {boolean} settings.isLinked Whether the newly created chart should stay linked with the original table, update when filters are updated\n * @param {string[]} settings.series The column names to use for creating the series of this chart\n * @param {string} settings.sourcePanelId The panel ID the chart was created from\n * @param {string} settings.type Chart builder type, from ChartBuilder.types\n * @param {string} settings.xAxis The column name to use for the x-axis\n * @param {string[]} settings.hiddenSeries Array of hidden series names\n * @param {dh.Figure} figure The figure to build the model for\n * @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure\n */\n static async makeModel(settings, figure) {\n return new FigureChartModel(figure, settings);\n }\n}\n\nexport default ChartModelFactory;\n"],"file":"ChartModelFactory.js"}
|
package/dist/ChartUtils.d.ts
CHANGED
|
@@ -106,12 +106,11 @@ declare class ChartUtils {
|
|
|
106
106
|
* @param {dh.plot.Series} series The series to create the series data with
|
|
107
107
|
* @param {Map<dh.plot.AxisType, dh.plot.Axis[]>} axisTypeMap The map of axes grouped by type
|
|
108
108
|
* @param {boolean|string} seriesVisibility Visibility setting for the series
|
|
109
|
-
* @param {Object} theme The theme properties for the plot. See ChartTheme.js for an example
|
|
110
109
|
* @returns {Object} The series data (trace) object for use with plotly.
|
|
111
110
|
*/
|
|
112
|
-
static makeSeriesDataFromSeries(series: any, axisTypeMap: Map<any, any[]>, seriesVisibility: boolean | string
|
|
111
|
+
static makeSeriesDataFromSeries(series: any, axisTypeMap: Map<any, any[]>, seriesVisibility: boolean | string): Object;
|
|
113
112
|
static addSourcesToSeriesData(seriesDataParam: any, plotStyle: any, sources: any, axisTypeMap: any): void;
|
|
114
|
-
static addStylingToSeriesData(seriesDataParam: any, plotStyle: any,
|
|
113
|
+
static addStylingToSeriesData(seriesDataParam: any, plotStyle: any, lineColor?: any, shapeColor?: any, seriesVisibility?: any): void;
|
|
115
114
|
/**
|
|
116
115
|
* Retrieve the axis formats from the provided figure.
|
|
117
116
|
* Currently defaults to just the x/y axes.
|
|
@@ -154,7 +153,7 @@ declare class ChartUtils {
|
|
|
154
153
|
* @param {number} plotHeight The height of the plot to calculate the axis sizes for
|
|
155
154
|
* @param {func} getRangeParser A function to retrieve the range parser for a given axis
|
|
156
155
|
*/
|
|
157
|
-
static updateLayoutAxes(layoutParam: object, axes: any[], plotWidth?: number, plotHeight?: number, getRangeParser?: any
|
|
156
|
+
static updateLayoutAxes(layoutParam: object, axes: any[], plotWidth?: number, plotHeight?: number, getRangeParser?: any): void;
|
|
158
157
|
static getAxisLayoutProperty(axisProperty: any, axisIndex: any): string;
|
|
159
158
|
/**
|
|
160
159
|
* Updates the layout axis object in place
|
|
@@ -240,7 +239,7 @@ declare class ChartUtils {
|
|
|
240
239
|
* @param {dh.i18n.TimeZone} timeZone The time zone if applicable
|
|
241
240
|
*/
|
|
242
241
|
static wrapValue(value: any, columnType: string, timeZone?: any): any;
|
|
243
|
-
static makeLayoutAxis(type: any
|
|
242
|
+
static makeLayoutAxis(type: any): {
|
|
244
243
|
automargin: boolean;
|
|
245
244
|
gridcolor: any;
|
|
246
245
|
linecolor: any;
|
|
@@ -259,16 +258,9 @@ declare class ChartUtils {
|
|
|
259
258
|
};
|
|
260
259
|
};
|
|
261
260
|
};
|
|
262
|
-
|
|
263
|
-
* Parses the colorway property of a theme and returns an array of colors
|
|
264
|
-
* Theme could have a single string with space separated colors or an array of strings representing the colorway
|
|
265
|
-
* @param {ChartTheme} theme The theme to get colorway from
|
|
266
|
-
* @returns {string[]} Colorway array for the theme
|
|
267
|
-
*/
|
|
268
|
-
static getColorwayFromTheme(theme: any): string[];
|
|
269
|
-
static makeDefaultLayout(theme?: {}): {
|
|
261
|
+
static makeDefaultLayout(): {
|
|
270
262
|
autosize: boolean;
|
|
271
|
-
colorway:
|
|
263
|
+
colorway: any;
|
|
272
264
|
font: {
|
|
273
265
|
family: string;
|
|
274
266
|
};
|
|
@@ -281,6 +273,7 @@ declare class ChartUtils {
|
|
|
281
273
|
t: number;
|
|
282
274
|
};
|
|
283
275
|
y: number;
|
|
276
|
+
text: string;
|
|
284
277
|
};
|
|
285
278
|
legend: {
|
|
286
279
|
font: {
|
|
@@ -332,6 +325,21 @@ declare class ChartUtils {
|
|
|
332
325
|
};
|
|
333
326
|
};
|
|
334
327
|
};
|
|
328
|
+
paper_bgcolor: any;
|
|
329
|
+
plot_bgcolor: any;
|
|
330
|
+
title_color: any;
|
|
331
|
+
gridcolor: any;
|
|
332
|
+
linecolor: any;
|
|
333
|
+
zerolinecolor: any;
|
|
334
|
+
activecolor: any;
|
|
335
|
+
rangebgcolor: any;
|
|
336
|
+
area_color: any;
|
|
337
|
+
trend_color: any;
|
|
338
|
+
line_color: any;
|
|
339
|
+
error_band_line_color: any;
|
|
340
|
+
error_band_fill_color: any;
|
|
341
|
+
ohlc_increasing: any;
|
|
342
|
+
ohlc_decreasing: any;
|
|
335
343
|
};
|
|
336
344
|
/**
|
|
337
345
|
* Dehydrate settings so they can be JSONified
|
package/dist/ChartUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartUtils.d.ts","sourceRoot":"","sources":["../src/ChartUtils.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ChartUtils.d.ts","sourceRoot":"","sources":["../src/ChartUtils.js"],"names":[],"mappings":";AAeA;IACE,iCAAgC;IAEhC,6BAA6B;IAE7B,6BAA2B;IAE3B,4BAAyB;IAEzB,+BAA4B;IAE5B,+BAA8B;IAE9B;;;OAGG;IAEH,2BAAkD;IAElD;;;;;;OAA8E;IAE9E;;OAAuD;IAEvD,oCAAiC;IAEjC;;;;OAIG;IACH,6DAFW,OAAO,yEA4BjB;IAED;;;OAGG;IACH,yEASC;IAED;;;;OAIG;IACH,2NA4DC;IAED,uDAOC;IAED;;;;;;;;OAQG;IACH,6BANW,aAAa,QACb,aAAa,SACb,aAAa,GAEX,MAAM,CAWlB;IAED;;;;MA4CC;IAED,6CAEC;IAED;;;;;aA2CC;IAED;;;;OAIG;IACH,wEA8BC;IAED;;;;;;OAMG;IACH,kCAJW,MAAM,QACN,MAAM,cACN,OAAO,UAqBjB;IAED;;;;;OAKG;IACH,oDAYC;IAED;;;;;OAKG;IACH,iCAJW,MAAM,YACN,MAAM,GACJ,OAAO,GAAC,MAAM,CAO1B;IAED;;;;OAIG;IACH,iCAHW,MAAM,GACJ,MAAM,EAAE,CAOpB;IAED;;;OAGG;IACH,8EAFa,MAAM,CASlB;IAED;;;;;;OAMG;IACH,0DAJW,SAAsB,KAAc,CAAC,oBACrC,OAAO,GAAC,MAAM,GACZ,MAAM,CA4BlB;IAED,0GAyBC;IAED,qIAyDC;IAED;;;;;;OAMG;IACH,oDAFa,IAAI,MAAM,EAAE,MAAM,CAAC,CAkG/B;IAED,gIASC;IAED;;;OAGG;IACH,4DASC;IAED;;;OAGG;IACH,kFAaC;IAED;;;;OAIG;IACH,wDAaC;IAED;;;;OAIG;IACH,+BAHW,MAAM,GACJ,MAAM,CAclB;IAED;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