@deephaven/chart 0.6.1 → 0.6.3-beta.9
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.js +2 -2
- package/dist/ChartModelFactory.d.ts +4 -2
- package/dist/ChartModelFactory.d.ts.map +1 -1
- package/dist/ChartModelFactory.js +9 -2
- package/dist/ChartModelFactory.js.map +1 -1
- package/dist/ChartUtils.d.ts +14 -22
- package/dist/ChartUtils.d.ts.map +1 -1
- package/dist/ChartUtils.js +54 -27
- package/dist/ChartUtils.js.map +1 -1
- package/dist/FigureChartModel.d.ts +3 -18
- package/dist/FigureChartModel.d.ts.map +1 -1
- package/dist/FigureChartModel.js +5 -3
- package/dist/FigureChartModel.js.map +1 -1
- package/dist/MockChartModel.d.ts +3 -51
- 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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plotly/Plot.js +5 -2
- package/dist/plotly/Plot.js.map +1 -1
- package/dist/plotly/Plotly.js +7 -2
- package/dist/plotly/Plotly.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
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) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
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
|
|
|
@@ -195,7 +195,7 @@ export class Chart extends Component {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
handleDownsampleClick() {
|
|
198
|
-
this.setState(
|
|
198
|
+
this.setState(_ref => {
|
|
199
199
|
var {
|
|
200
200
|
isDownsamplingDisabled
|
|
201
201
|
} = _ref;
|
|
@@ -11,6 +11,7 @@ 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
|
|
14
15
|
* @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure
|
|
15
16
|
*/
|
|
16
17
|
static makeModelFromSettings(settings: {
|
|
@@ -20,7 +21,7 @@ declare class ChartModelFactory {
|
|
|
20
21
|
type: string;
|
|
21
22
|
xAxis: string;
|
|
22
23
|
hiddenSeries: string[];
|
|
23
|
-
}, table: any): Promise<FigureChartModel>;
|
|
24
|
+
}, table: any, theme?: Object): Promise<FigureChartModel>;
|
|
24
25
|
/**
|
|
25
26
|
* Creates a model from the settings provided.
|
|
26
27
|
* Tries to create a Figure in the API with it.
|
|
@@ -32,6 +33,7 @@ declare class ChartModelFactory {
|
|
|
32
33
|
* @param {string} settings.xAxis The column name to use for the x-axis
|
|
33
34
|
* @param {string[]} settings.hiddenSeries Array of hidden series names
|
|
34
35
|
* @param {dh.Figure} figure The figure to build the model for
|
|
36
|
+
* @param {Object} theme The theme for the figure. Defaults to ChartTheme
|
|
35
37
|
* @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure
|
|
36
38
|
*/
|
|
37
39
|
static makeModel(settings: {
|
|
@@ -41,7 +43,7 @@ declare class ChartModelFactory {
|
|
|
41
43
|
type: string;
|
|
42
44
|
xAxis: string;
|
|
43
45
|
hiddenSeries: string[];
|
|
44
|
-
}, figure: any): Promise<FigureChartModel>;
|
|
46
|
+
}, figure: any, theme?: Object): Promise<FigureChartModel>;
|
|
45
47
|
}
|
|
46
48
|
import FigureChartModel from "./FigureChartModel";
|
|
47
49
|
//# 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":";AAKA;IACE;;;;;;;;;;;;;OAaG;IACH;QAV6B,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;2BAER,MAAM,GACJ,QAAQ,gBAAgB,CAAC,CAgBrC;IAED;;;;;;;;;;;;;OAaG;IACH;QAV6B,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;4BAER,MAAM,GACJ,QAAQ,gBAAgB,CAAC,CAIrC;CACF"}
|
|
@@ -5,6 +5,7 @@ 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";
|
|
8
9
|
|
|
9
10
|
class ChartModelFactory {
|
|
10
11
|
/**
|
|
@@ -18,10 +19,13 @@ class ChartModelFactory {
|
|
|
18
19
|
* @param {string} settings.xAxis The column name to use for the x-axis
|
|
19
20
|
* @param {string[]} settings.hiddenSeries Array of hidden series names
|
|
20
21
|
* @param {dh.Table} table The table to build the model for
|
|
22
|
+
* @param {Object} theme The theme for the figure. Defaults to ChartTheme
|
|
21
23
|
* @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure
|
|
22
24
|
*/
|
|
23
25
|
static makeModelFromSettings(settings, table) {
|
|
26
|
+
var _arguments = arguments;
|
|
24
27
|
return _asyncToGenerator(function* () {
|
|
28
|
+
var theme = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : ChartTheme;
|
|
25
29
|
// Copy the table first and then re-apply the filters from the original table
|
|
26
30
|
// When we add table linking we'll want to listen to the original table and update
|
|
27
31
|
// the copied table with any changes that occur.
|
|
@@ -30,7 +34,7 @@ class ChartModelFactory {
|
|
|
30
34
|
tableCopy.applyCustomColumns(table.customColumns);
|
|
31
35
|
tableCopy.applyFilter(table.filter);
|
|
32
36
|
tableCopy.applySort(table.sort);
|
|
33
|
-
return dh.plot.Figure.create(ChartUtils.makeFigureSettings(settings, tableCopy)).then(figure => new FigureChartModel(figure, settings));
|
|
37
|
+
return dh.plot.Figure.create(ChartUtils.makeFigureSettings(settings, tableCopy)).then(figure => new FigureChartModel(figure, settings, theme));
|
|
34
38
|
});
|
|
35
39
|
})();
|
|
36
40
|
}
|
|
@@ -45,13 +49,16 @@ class ChartModelFactory {
|
|
|
45
49
|
* @param {string} settings.xAxis The column name to use for the x-axis
|
|
46
50
|
* @param {string[]} settings.hiddenSeries Array of hidden series names
|
|
47
51
|
* @param {dh.Figure} figure The figure to build the model for
|
|
52
|
+
* @param {Object} theme The theme for the figure. Defaults to ChartTheme
|
|
48
53
|
* @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure
|
|
49
54
|
*/
|
|
50
55
|
|
|
51
56
|
|
|
52
57
|
static makeModel(settings, figure) {
|
|
58
|
+
var _arguments2 = arguments;
|
|
53
59
|
return _asyncToGenerator(function* () {
|
|
54
|
-
|
|
60
|
+
var theme = _arguments2.length > 2 && _arguments2[2] !== undefined ? _arguments2[2] : ChartTheme;
|
|
61
|
+
return new FigureChartModel(figure, settings, theme);
|
|
55
62
|
})();
|
|
56
63
|
}
|
|
57
64
|
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"sources":["../src/ChartModelFactory.js"],"names":["dh","ChartUtils","FigureChartModel","ChartTheme","ChartModelFactory","makeModelFromSettings","settings","table","theme","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;OACAC,U;;AAEP,MAAMC,iBAAN,CAAwB;AACtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACoC,SAArBC,qBAAqB,CAACC,QAAD,EAAWC,KAAX,EAAsC;AAAA;AAAA;AAAA,UAApBC,KAAoB,0EAAZL,UAAY;AACtE;AACA;AACA;AACA;AACA,aAAOI,KAAK,CAACE,IAAN,GAAaC,IAAb,CAAkBC,SAAS,IAAI;AACpCA,QAAAA,SAAS,CAACC,kBAAV,CAA6BL,KAAK,CAACM,aAAnC;AACAF,QAAAA,SAAS,CAACG,WAAV,CAAsBP,KAAK,CAACQ,MAA5B;AACAJ,QAAAA,SAAS,CAACK,SAAV,CAAoBT,KAAK,CAACU,IAA1B;AAEA,eAAOjB,EAAE,CAACkB,IAAH,CAAQC,MAAR,CAAeC,MAAf,CACLnB,UAAU,CAACoB,kBAAX,CAA8Bf,QAA9B,EAAwCK,SAAxC,CADK,EAELD,IAFK,CAEAY,MAAM,IAAI,IAAIpB,gBAAJ,CAAqBoB,MAArB,EAA6BhB,QAA7B,EAAuCE,KAAvC,CAFV,CAAP;AAGD,OARM,CAAP;AALsE;AAcvE;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACwB,SAATe,SAAS,CAACjB,QAAD,EAAWgB,MAAX,EAAuC;AAAA;AAAA;AAAA,UAApBd,KAAoB,6EAAZL,UAAY;AAC3D,aAAO,IAAID,gBAAJ,CAAqBoB,MAArB,EAA6BhB,QAA7B,EAAuCE,KAAvC,CAAP;AAD2D;AAE5D;;AA/CqB;;AAkDxB,eAAeJ,iBAAf","sourcesContent":["import dh from '@deephaven/jsapi-shim';\nimport ChartUtils from './ChartUtils';\nimport FigureChartModel from './FigureChartModel';\nimport ChartTheme from './ChartTheme';\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 * @param {Object} theme The theme for the figure. Defaults to ChartTheme\n * @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure\n */\n static async makeModelFromSettings(settings, table, theme = ChartTheme) {\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, theme));\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 * @param {Object} theme The theme for the figure. Defaults to ChartTheme\n * @returns {Promise<FigureChartModel>} The FigureChartModel representing the figure\n */\n static async makeModel(settings, figure, theme = ChartTheme) {\n return new FigureChartModel(figure, settings, theme);\n }\n}\n\nexport default ChartModelFactory;\n"],"file":"ChartModelFactory.js"}
|
package/dist/ChartUtils.d.ts
CHANGED
|
@@ -106,11 +106,12 @@ 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
|
|
109
110
|
* @returns {Object} The series data (trace) object for use with plotly.
|
|
110
111
|
*/
|
|
111
|
-
static makeSeriesDataFromSeries(series: any, axisTypeMap: Map<any, any[]>, seriesVisibility: boolean | string): Object;
|
|
112
|
+
static makeSeriesDataFromSeries(series: any, axisTypeMap: Map<any, any[]>, seriesVisibility: boolean | string, theme: Object): Object;
|
|
112
113
|
static addSourcesToSeriesData(seriesDataParam: any, plotStyle: any, sources: any, axisTypeMap: any): void;
|
|
113
|
-
static addStylingToSeriesData(seriesDataParam: any, plotStyle: any, lineColor?: any, shapeColor?: any, seriesVisibility?: any): void;
|
|
114
|
+
static addStylingToSeriesData(seriesDataParam: any, plotStyle: any, theme?: {}, lineColor?: any, shapeColor?: any, seriesVisibility?: any): void;
|
|
114
115
|
/**
|
|
115
116
|
* Retrieve the axis formats from the provided figure.
|
|
116
117
|
* Currently defaults to just the x/y axes.
|
|
@@ -153,7 +154,7 @@ declare class ChartUtils {
|
|
|
153
154
|
* @param {number} plotHeight The height of the plot to calculate the axis sizes for
|
|
154
155
|
* @param {func} getRangeParser A function to retrieve the range parser for a given axis
|
|
155
156
|
*/
|
|
156
|
-
static updateLayoutAxes(layoutParam: object, axes: any[], plotWidth?: number, plotHeight?: number, getRangeParser?: any): void;
|
|
157
|
+
static updateLayoutAxes(layoutParam: object, axes: any[], plotWidth?: number, plotHeight?: number, getRangeParser?: any, theme?: {}): void;
|
|
157
158
|
static getAxisLayoutProperty(axisProperty: any, axisIndex: any): string;
|
|
158
159
|
/**
|
|
159
160
|
* Updates the layout axis object in place
|
|
@@ -239,7 +240,7 @@ declare class ChartUtils {
|
|
|
239
240
|
* @param {dh.i18n.TimeZone} timeZone The time zone if applicable
|
|
240
241
|
*/
|
|
241
242
|
static wrapValue(value: any, columnType: string, timeZone?: any): any;
|
|
242
|
-
static makeLayoutAxis(type: any): {
|
|
243
|
+
static makeLayoutAxis(type: any, theme?: {}): {
|
|
243
244
|
automargin: boolean;
|
|
244
245
|
gridcolor: any;
|
|
245
246
|
linecolor: any;
|
|
@@ -258,9 +259,16 @@ declare class ChartUtils {
|
|
|
258
259
|
};
|
|
259
260
|
};
|
|
260
261
|
};
|
|
261
|
-
|
|
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?: {}): {
|
|
262
270
|
autosize: boolean;
|
|
263
|
-
colorway:
|
|
271
|
+
colorway: string[];
|
|
264
272
|
font: {
|
|
265
273
|
family: string;
|
|
266
274
|
};
|
|
@@ -273,7 +281,6 @@ declare class ChartUtils {
|
|
|
273
281
|
t: number;
|
|
274
282
|
};
|
|
275
283
|
y: number;
|
|
276
|
-
text: string;
|
|
277
284
|
};
|
|
278
285
|
legend: {
|
|
279
286
|
font: {
|
|
@@ -325,21 +332,6 @@ declare class ChartUtils {
|
|
|
325
332
|
};
|
|
326
333
|
};
|
|
327
334
|
};
|
|
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;
|
|
343
335
|
};
|
|
344
336
|
/**
|
|
345
337
|
* 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":";AAcA;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;;;;;;;OAOG;IACH,0DALW,SAAsB,KAAc,CAAC,oBACrC,OAAO,GAAC,MAAM,SACd,MAAM,GACJ,MAAM,CAkClB;IAED,0GAyBC;IAED,iJA0DC;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;;;;;;;;;;OAUG;IACH,qCANW,MAAM,QACN,KAAc,cACd,MAAM,eACN,MAAM,0CA6HhB;IAED,wEAGC;IAED;;;;;;;;OAQG;IACH,yCAPW,MAAM,wBAEN,MAAM,mBACN,aAAuC,0CAEvC,MAAM,QAkEhB;IAED;;;;OAIG;IACH,+CAGC;IAED;;;;;;;OAOG;IACH,wDA6BC;IAED;;;;;;OAMG;IACH,iHA2BC;IAED;;;;;;OAMG;IACH,2FAMC;IAED;;;;;;;OAOG;IACH;;;QAoCC;IAED;;;;;;OAMG;IACH,yCAJW,MAAM,sDAuBhB;IAED;;;;;OAKG;IACH,yBAJW,MAAM,EAAE,YACR,MAAM,GACJ,IAAI,MAAM,EAAE,MAAM,CAAC,CAU/B;IAED;;OAEG;IACH,4BAAwB;IAExB;;;OAGG;IACH,oDAgBC;IAED;;;;;OAKG;IACH,wBAJW,GAAG,cACH,MAAM,uBAqChB;IAED;;;;;;;;;;;;;;;;;;MA+BC;IAED;;;;;OAKG;IACH,yCAFa,MAAM,EAAE,CAepB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2BC;IAED;;;OAGG;IACH,mCAFW,MAAM;;MAOhB;IAED;;;OAGG;IACH,iCAFW,MAAM;;MAOhB;IAED,6CAQC;IAED;;;;;;;;;;;OAWG;IACH;QAL4B,KAAK,EAAtB,MAAM;QACW,KAAK,EAAtB,MAAM;QACa,MAAM,EAAzB,MAAM,EAAE;QAC0B,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;MA2ChD;CACF"}
|
package/dist/ChartUtils.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
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; }
|
|
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
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
7
|
import Log from '@deephaven/log';
|
|
8
|
-
import
|
|
8
|
+
import TableUtils from '@deephaven/iris-grid/dist/TableUtils.js';
|
|
9
9
|
import dh from '@deephaven/jsapi-shim';
|
|
10
|
-
import ChartTheme from "./ChartTheme.js";
|
|
11
10
|
var log = Log.module('ChartUtils');
|
|
12
11
|
var DAYS = Object.freeze(dh.calendar.DayOfWeek.values());
|
|
13
12
|
var BUSINESS_COLUMN_TYPE = 'io.deephaven.db.tables.utils.DBDateTime';
|
|
@@ -394,11 +393,12 @@ class ChartUtils {
|
|
|
394
393
|
* @param {dh.plot.Series} series The series to create the series data with
|
|
395
394
|
* @param {Map<dh.plot.AxisType, dh.plot.Axis[]>} axisTypeMap The map of axes grouped by type
|
|
396
395
|
* @param {boolean|string} seriesVisibility Visibility setting for the series
|
|
396
|
+
* @param {Object} theme The theme properties for the plot. See ChartTheme.js for an example
|
|
397
397
|
* @returns {Object} The series data (trace) object for use with plotly.
|
|
398
398
|
*/
|
|
399
399
|
|
|
400
400
|
|
|
401
|
-
static makeSeriesDataFromSeries(series, axisTypeMap, seriesVisibility) {
|
|
401
|
+
static makeSeriesDataFromSeries(series, axisTypeMap, seriesVisibility, theme) {
|
|
402
402
|
var {
|
|
403
403
|
name,
|
|
404
404
|
plotStyle,
|
|
@@ -412,7 +412,7 @@ class ChartUtils {
|
|
|
412
412
|
var orientation = ChartUtils.getPlotlySeriesOrientation(series);
|
|
413
413
|
var seriesData = ChartUtils.makeSeriesData(type, mode, name, orientation);
|
|
414
414
|
ChartUtils.addSourcesToSeriesData(seriesData, plotStyle, sources, axisTypeMap);
|
|
415
|
-
ChartUtils.addStylingToSeriesData(seriesData, plotStyle, lineColor, shapeColor, seriesVisibility);
|
|
415
|
+
ChartUtils.addStylingToSeriesData(seriesData, plotStyle, theme, lineColor, shapeColor, seriesVisibility);
|
|
416
416
|
return seriesData;
|
|
417
417
|
}
|
|
418
418
|
|
|
@@ -439,9 +439,10 @@ class ChartUtils {
|
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
static addStylingToSeriesData(seriesDataParam, plotStyle) {
|
|
442
|
-
var
|
|
443
|
-
var
|
|
444
|
-
var
|
|
442
|
+
var theme = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
443
|
+
var lineColor = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
444
|
+
var shapeColor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
445
|
+
var seriesVisibility = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
|
|
445
446
|
var seriesData = seriesDataParam; // Add some empty objects so we can fill them in later with details without checking for existence
|
|
446
447
|
|
|
447
448
|
seriesData.marker = {
|
|
@@ -464,24 +465,24 @@ class ChartUtils {
|
|
|
464
465
|
// Since it's converted to bar, just set the widths of each bar
|
|
465
466
|
seriesData.width = [];
|
|
466
467
|
Object.assign(seriesData.marker.line, {
|
|
467
|
-
color:
|
|
468
|
+
color: theme.paper_bgcolor,
|
|
468
469
|
width: 1
|
|
469
470
|
});
|
|
470
471
|
} else if (plotStyle === dh.plot.SeriesPlotStyle.OHLC) {
|
|
471
472
|
seriesData.increasing = {
|
|
472
473
|
line: {
|
|
473
|
-
color:
|
|
474
|
+
color: theme.ohlc_increasing
|
|
474
475
|
}
|
|
475
476
|
};
|
|
476
477
|
seriesData.decreasing = {
|
|
477
478
|
line: {
|
|
478
|
-
color:
|
|
479
|
+
color: theme.ohlc_decreasing
|
|
479
480
|
}
|
|
480
481
|
};
|
|
481
482
|
} else if (plotStyle === dh.plot.SeriesPlotStyle.PIE) {
|
|
482
483
|
seriesData.textinfo = 'label+percent';
|
|
483
484
|
seriesData.outsidetextfont = {
|
|
484
|
-
color:
|
|
485
|
+
color: theme.title_color
|
|
485
486
|
};
|
|
486
487
|
}
|
|
487
488
|
|
|
@@ -723,6 +724,7 @@ class ChartUtils {
|
|
|
723
724
|
var plotWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
724
725
|
var plotHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
725
726
|
var getRangeParser = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
727
|
+
var theme = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
726
728
|
var xAxisSize = plotWidth > 0 ? Math.max(ChartUtils.MIN_AXIS_SIZE, Math.min(ChartUtils.AXIS_SIZE_PX / plotHeight, ChartUtils.MAX_AXIS_SIZE)) : ChartUtils.DEFAULT_AXIS_SIZE;
|
|
727
729
|
var yAxisSize = plotHeight > 0 ? Math.max(ChartUtils.MIN_AXIS_SIZE, Math.min(ChartUtils.AXIS_SIZE_PX / plotWidth, ChartUtils.MAX_AXIS_SIZE)) : ChartUtils.DEFAULT_AXIS_SIZE; // Adjust the bounds based on where the legend is
|
|
728
730
|
// For now, always assume the legend is shown on the right
|
|
@@ -764,7 +766,7 @@ class ChartUtils {
|
|
|
764
766
|
var _axisLayoutProperty = ChartUtils.getAxisLayoutProperty(axisProperty, axisIndex);
|
|
765
767
|
|
|
766
768
|
if (layout[_axisLayoutProperty] == null) {
|
|
767
|
-
layout[_axisLayoutProperty] = ChartUtils.makeLayoutAxis(axisType);
|
|
769
|
+
layout[_axisLayoutProperty] = ChartUtils.makeLayoutAxis(axisType, theme);
|
|
768
770
|
}
|
|
769
771
|
|
|
770
772
|
var layoutAxis = layout[_axisLayoutProperty];
|
|
@@ -1079,24 +1081,25 @@ class ChartUtils {
|
|
|
1079
1081
|
}
|
|
1080
1082
|
|
|
1081
1083
|
static makeLayoutAxis(type) {
|
|
1084
|
+
var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1082
1085
|
var axis = {
|
|
1083
1086
|
automargin: true,
|
|
1084
|
-
gridcolor:
|
|
1085
|
-
linecolor:
|
|
1087
|
+
gridcolor: theme.gridcolor,
|
|
1088
|
+
linecolor: theme.linecolor,
|
|
1086
1089
|
rangeslider: {
|
|
1087
1090
|
visible: false
|
|
1088
1091
|
},
|
|
1089
1092
|
showline: true,
|
|
1090
1093
|
ticklen: 5,
|
|
1091
1094
|
// act as padding, can't find a tick padding
|
|
1092
|
-
tickcolor:
|
|
1095
|
+
tickcolor: theme.paper_bgcolor,
|
|
1093
1096
|
// hide ticks as padding
|
|
1094
1097
|
tickfont: {
|
|
1095
|
-
color:
|
|
1098
|
+
color: theme.zerolinecolor
|
|
1096
1099
|
},
|
|
1097
1100
|
title: {
|
|
1098
1101
|
font: {
|
|
1099
|
-
color:
|
|
1102
|
+
color: theme.title_color
|
|
1100
1103
|
}
|
|
1101
1104
|
}
|
|
1102
1105
|
};
|
|
@@ -1107,38 +1110,62 @@ class ChartUtils {
|
|
|
1107
1110
|
});
|
|
1108
1111
|
} else if (type === dh.plot.AxisType.Y) {
|
|
1109
1112
|
Object.assign(axis, {
|
|
1110
|
-
zerolinecolor:
|
|
1113
|
+
zerolinecolor: theme.zerolinecolor,
|
|
1111
1114
|
zerolinewidth: 2
|
|
1112
1115
|
});
|
|
1113
1116
|
}
|
|
1114
1117
|
|
|
1115
1118
|
return axis;
|
|
1116
1119
|
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Parses the colorway property of a theme and returns an array of colors
|
|
1122
|
+
* Theme could have a single string with space separated colors or an array of strings representing the colorway
|
|
1123
|
+
* @param {ChartTheme} theme The theme to get colorway from
|
|
1124
|
+
* @returns {string[]} Colorway array for the theme
|
|
1125
|
+
*/
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
static getColorwayFromTheme(theme) {
|
|
1129
|
+
var colorway = [];
|
|
1130
|
+
|
|
1131
|
+
if (theme.colorway) {
|
|
1132
|
+
if (Array.isArray(theme.colorway)) {
|
|
1133
|
+
colorway = theme.colorway;
|
|
1134
|
+
} else if (typeof theme.colorway === 'string') {
|
|
1135
|
+
colorway = theme.colorway.split(' ');
|
|
1136
|
+
} else {
|
|
1137
|
+
log.warn("Unable to handle colorway property: ".concat(theme.colorway));
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
return colorway;
|
|
1142
|
+
}
|
|
1117
1143
|
|
|
1118
1144
|
static makeDefaultLayout() {
|
|
1119
|
-
var
|
|
1145
|
+
var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1146
|
+
|
|
1147
|
+
var layout = _objectSpread(_objectSpread({}, theme), {}, {
|
|
1120
1148
|
autosize: true,
|
|
1121
|
-
colorway:
|
|
1149
|
+
colorway: ChartUtils.getColorwayFromTheme(theme),
|
|
1122
1150
|
font: {
|
|
1123
1151
|
family: "'Fira Sans', sans-serif"
|
|
1124
1152
|
},
|
|
1125
1153
|
title: {
|
|
1126
1154
|
font: {
|
|
1127
|
-
color:
|
|
1155
|
+
color: theme.title_color
|
|
1128
1156
|
},
|
|
1129
1157
|
yanchor: 'top',
|
|
1130
1158
|
pad: _objectSpread({}, ChartUtils.DEFAULT_TITLE_PADDING),
|
|
1131
|
-
y: 1
|
|
1132
|
-
text: 'Untitled'
|
|
1159
|
+
y: 1
|
|
1133
1160
|
},
|
|
1134
1161
|
legend: {
|
|
1135
1162
|
font: {
|
|
1136
|
-
color:
|
|
1163
|
+
color: theme.title_color
|
|
1137
1164
|
}
|
|
1138
1165
|
},
|
|
1139
1166
|
margin: _objectSpread({}, ChartUtils.DEFAULT_MARGIN),
|
|
1140
|
-
xaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.X),
|
|
1141
|
-
yaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.Y)
|
|
1167
|
+
xaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.X, theme),
|
|
1168
|
+
yaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.Y, theme)
|
|
1142
1169
|
});
|
|
1143
1170
|
|
|
1144
1171
|
layout.datarevision = 0;
|