@deephaven/chart 0.6.3-alpha.5 → 0.6.3-bard.6

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.
@@ -1,12 +1,13 @@
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 TableUtils from '@deephaven/iris-grid/dist/TableUtils.js';
8
+ import { TableUtils } from '@deephaven/iris-grid';
9
9
  import dh from '@deephaven/jsapi-shim';
10
+ import ChartTheme from "./ChartTheme.js";
10
11
  var log = Log.module('ChartUtils');
11
12
  var DAYS = Object.freeze(dh.calendar.DayOfWeek.values());
12
13
  var BUSINESS_COLUMN_TYPE = 'io.deephaven.db.tables.utils.DBDateTime';
@@ -393,12 +394,11 @@ class ChartUtils {
393
394
  * @param {dh.plot.Series} series The series to create the series data with
394
395
  * @param {Map<dh.plot.AxisType, dh.plot.Axis[]>} axisTypeMap The map of axes grouped by type
395
396
  * @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, theme) {
401
+ static makeSeriesDataFromSeries(series, axisTypeMap, seriesVisibility) {
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, theme, lineColor, shapeColor, seriesVisibility);
415
+ ChartUtils.addStylingToSeriesData(seriesData, plotStyle, lineColor, shapeColor, seriesVisibility);
416
416
  return seriesData;
417
417
  }
418
418
 
@@ -439,10 +439,9 @@ class ChartUtils {
439
439
  }
440
440
 
441
441
  static addStylingToSeriesData(seriesDataParam, plotStyle) {
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;
442
+ var lineColor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
443
+ var shapeColor = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
444
+ var seriesVisibility = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
446
445
  var seriesData = seriesDataParam; // Add some empty objects so we can fill them in later with details without checking for existence
447
446
 
448
447
  seriesData.marker = {
@@ -465,24 +464,24 @@ class ChartUtils {
465
464
  // Since it's converted to bar, just set the widths of each bar
466
465
  seriesData.width = [];
467
466
  Object.assign(seriesData.marker.line, {
468
- color: theme.paper_bgcolor,
467
+ color: ChartTheme.paper_bgcolor,
469
468
  width: 1
470
469
  });
471
470
  } else if (plotStyle === dh.plot.SeriesPlotStyle.OHLC) {
472
471
  seriesData.increasing = {
473
472
  line: {
474
- color: theme.ohlc_increasing
473
+ color: ChartTheme.ohlc_increasing
475
474
  }
476
475
  };
477
476
  seriesData.decreasing = {
478
477
  line: {
479
- color: theme.ohlc_decreasing
478
+ color: ChartTheme.ohlc_decreasing
480
479
  }
481
480
  };
482
481
  } else if (plotStyle === dh.plot.SeriesPlotStyle.PIE) {
483
482
  seriesData.textinfo = 'label+percent';
484
483
  seriesData.outsidetextfont = {
485
- color: theme.title_color
484
+ color: ChartTheme.title_color
486
485
  };
487
486
  }
488
487
 
@@ -724,7 +723,6 @@ class ChartUtils {
724
723
  var plotWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
725
724
  var plotHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
726
725
  var getRangeParser = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
727
- var theme = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
728
726
  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;
729
727
  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
730
728
  // For now, always assume the legend is shown on the right
@@ -766,7 +764,7 @@ class ChartUtils {
766
764
  var _axisLayoutProperty = ChartUtils.getAxisLayoutProperty(axisProperty, axisIndex);
767
765
 
768
766
  if (layout[_axisLayoutProperty] == null) {
769
- layout[_axisLayoutProperty] = ChartUtils.makeLayoutAxis(axisType, theme);
767
+ layout[_axisLayoutProperty] = ChartUtils.makeLayoutAxis(axisType);
770
768
  }
771
769
 
772
770
  var layoutAxis = layout[_axisLayoutProperty];
@@ -1081,25 +1079,24 @@ class ChartUtils {
1081
1079
  }
1082
1080
 
1083
1081
  static makeLayoutAxis(type) {
1084
- var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1085
1082
  var axis = {
1086
1083
  automargin: true,
1087
- gridcolor: theme.gridcolor,
1088
- linecolor: theme.linecolor,
1084
+ gridcolor: ChartTheme.gridcolor,
1085
+ linecolor: ChartTheme.linecolor,
1089
1086
  rangeslider: {
1090
1087
  visible: false
1091
1088
  },
1092
1089
  showline: true,
1093
1090
  ticklen: 5,
1094
1091
  // act as padding, can't find a tick padding
1095
- tickcolor: theme.paper_bgcolor,
1092
+ tickcolor: ChartTheme.paper_bgcolor,
1096
1093
  // hide ticks as padding
1097
1094
  tickfont: {
1098
- color: theme.zerolinecolor
1095
+ color: ChartTheme.zerolinecolor
1099
1096
  },
1100
1097
  title: {
1101
1098
  font: {
1102
- color: theme.title_color
1099
+ color: ChartTheme.title_color
1103
1100
  }
1104
1101
  }
1105
1102
  };
@@ -1110,62 +1107,38 @@ class ChartUtils {
1110
1107
  });
1111
1108
  } else if (type === dh.plot.AxisType.Y) {
1112
1109
  Object.assign(axis, {
1113
- zerolinecolor: theme.zerolinecolor,
1110
+ zerolinecolor: ChartTheme.zerolinecolor,
1114
1111
  zerolinewidth: 2
1115
1112
  });
1116
1113
  }
1117
1114
 
1118
1115
  return axis;
1119
1116
  }
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
- }
1143
1117
 
1144
1118
  static makeDefaultLayout() {
1145
- var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1146
-
1147
- var layout = _objectSpread(_objectSpread({}, theme), {}, {
1119
+ var layout = _objectSpread(_objectSpread({}, ChartTheme), {}, {
1148
1120
  autosize: true,
1149
- colorway: ChartUtils.getColorwayFromTheme(theme),
1121
+ colorway: ChartTheme.colorway ? ChartTheme.colorway.split(' ') : [],
1150
1122
  font: {
1151
1123
  family: "'Fira Sans', sans-serif"
1152
1124
  },
1153
1125
  title: {
1154
1126
  font: {
1155
- color: theme.title_color
1127
+ color: ChartTheme.title_color
1156
1128
  },
1157
1129
  yanchor: 'top',
1158
1130
  pad: _objectSpread({}, ChartUtils.DEFAULT_TITLE_PADDING),
1159
- y: 1
1131
+ y: 1,
1132
+ text: 'Untitled'
1160
1133
  },
1161
1134
  legend: {
1162
1135
  font: {
1163
- color: theme.title_color
1136
+ color: ChartTheme.title_color
1164
1137
  }
1165
1138
  },
1166
1139
  margin: _objectSpread({}, ChartUtils.DEFAULT_MARGIN),
1167
- xaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.X, theme),
1168
- yaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.Y, theme)
1140
+ xaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.X),
1141
+ yaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.Y)
1169
1142
  });
1170
1143
 
1171
1144
  layout.datarevision = 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ChartUtils.js"],"names":["Log","TableUtils","dh","log","module","DAYS","Object","freeze","calendar","DayOfWeek","values","BUSINESS_COLUMN_TYPE","MILLIS_PER_HOUR","NANOS_PER_MILLI","ChartUtils","getPlotlyChartType","plotStyle","isBusinessTime","plot","SeriesPlotStyle","SCATTER","LINE","BAR","STACKED_BAR","PIE","HISTOGRAM","OHLC","getPlotlyChartMode","getPlotlyProperty","sourceType","SourceType","X","Y","TIME","Z","X_LOW","X_HIGH","Y_LOW","Y_HIGH","OPEN","HIGH","LOW","CLOSE","SHAPE","SIZE","LABEL","COLOR","Error","getPlotlySeriesOrientation","series","sources","length","axis","type","AxisType","ORIENTATION","HORIZONTAL","VERTICAL","getPlotlyErrorBars","x","xLow","xHigh","array","map","value","i","arrayminus","symmetric","getPlotlyDateFormat","formatter","columnType","formatPattern","tickformat","replace","ticksuffix","dataFormatter","getColumnTypeFormatter","dhTimeZone","showTimeZone","i18n","DateTimeFormat","format","Date","automargin","convertNumberPrefix","prefix","getPlotlyNumberFormat","subpatterns","split","placeholderDigits","zeroDigits","decimalDigits","optionalDecimalDigits","numberType","percentSign","suffix","match","paddingLength","isCommaSeparated","indexOf","comma","plotlyNumberType","decimalLength","trimOption","tickprefix","getPlotlyAxisFormat","source","axisFormat","isDateType","addTickSpacing","isNumberType","formatType","AxisFormatType","CATEGORY","gapBetweenMajorTicks","updatedFormat","tickSpacing","Math","tickmode","dtick","getSourceForAxis","chart","j","getSeriesVisibility","name","settings","hiddenSeries","includes","getHiddenLabels","makeSeriesData","mode","orientation","makeSeriesDataFromSeries","axisTypeMap","seriesVisibility","theme","lineColor","shapeColor","some","businessCalendar","getChartType","seriesData","addSourcesToSeriesData","addStylingToSeriesData","seriesDataParam","k","dataAttributeName","axisProperty","getAxisPropertyName","axes","get","axisIndex","axisIndexString","marker","line","width","AREA","fill","STACKED_AREA","stackgroup","STEP","shape","assign","color","paper_bgcolor","increasing","ohlc_increasing","decreasing","ohlc_decreasing","textinfo","outsidetextfont","title_color","visible","getAxisFormats","figure","axisFormats","Map","nullFormat","charts","groupArray","axisType","typeAxes","axisLayoutProperty","getAxisLayoutProperty","has","debug","set","rangebreaks","businessPeriods","businessDays","holidays","timeZone","calendarTimeZone","formatterTimeZone","timeZoneDiff","standardOffset","push","createRangeBreakValuesFromHolidays","forEach","period","pattern","bounds","periodToDecimal","close","open","createBoundsFromDays","weekendBounds","size","getAxisSide","axisPosition","AxisPosition","BOTTOM","TOP","LEFT","RIGHT","getChartForSeries","getLayoutRanges","layout","ranges","keys","filter","key","range","autorange","updateLayoutAxes","layoutParam","plotWidth","plotHeight","getRangeParser","xAxisSize","max","MIN_AXIS_SIZE","min","AXIS_SIZE_PX","MAX_AXIS_SIZE","DEFAULT_AXIS_SIZE","yAxisSize","left","bottom","top","right","axisPositionMap","rightAxes","LEGEND_WIDTH_PX","MAX_LEGEND_SIZE","axisTypes","isYAxis","plotSize","makeLayoutAxis","layoutAxis","updateLayoutAxis","rangeParser","rangeStart","rangeEnd","layoutAxisParam","axisSize","title","text","label","side","position","overlaying","positionAxes","sideIndex","anchor","leftAxes","domain","bottomAxes","topAxes","Number","businessDaysInt","day","nonBusinessDaysInt","reopenDays","Set","closed","adjustedDay","add","boundsArray","closedDay","fullHolidays","partialHolidays","holiday","createPartialHoliday","createFullHoliday","adjustDateForTimeZone","date","toString","dateString","closedPeriods","rangeBreaks","startClose","endClose","dvalue","unwrapValue","wrapValue","property","reduce","result","item","group","updateRanges","asDate","DATE_FORMAT","asNumber","substr","parse","tzFormat","estimatedOffset","estimatedDate","offset","gridcolor","linecolor","rangeslider","showline","ticklen","tickcolor","tickfont","zerolinecolor","font","showgrid","zerolinewidth","getColorwayFromTheme","colorway","Array","isArray","warn","makeDefaultLayout","autosize","family","yanchor","pad","DEFAULT_TITLE_PADDING","y","legend","margin","DEFAULT_MARGIN","xaxis","yaxis","datarevision","dehydrateSettings","hydrateSettings","titleFromSettings","xAxis","join","makeFigureSettings","table","settingsAxis","NUMBER","yAxis","chartType","ChartType","XY","dataSources","columnName","l","r","t","b"],"mappings":";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AOkB,E;;gBAPlBA,U,qBASqB,E;;gBATrBA,U,qBAWqB,I;;gBAXrBA,U,iBAaiBR,MAAM,CAACC,MAAP,CAAc;AACjCiD,EAAAA,UAAU,EAAE,GADqB;AAEjCC,EAAAA,QAAQ,EAAE;AAFuB,CAAd,C;;gBAbjB3C,U,iBAkBiB,4B;;gBAlBjBA,U,oBAoBoBR,MAAM,CAACC,MAAP,CAAc;AAAE4V,EAAAA,CAAC,EAAE,EAAL;AAASC,EAAAA,CAAC,EAAE,EAAZ;AAAgBC,EAAAA,CAAC,EAAE,EAAnB;AAAuBC,EAAAA,CAAC,EAAE,EAA1B;AAA8B3B,EAAAA,GAAG,EAAE;AAAnC,CAAd,C;;gBApBpB7T,U,2BAsB2BR,MAAM,CAACC,MAAP,CAAc;AAAE8V,EAAAA,CAAC,EAAE;AAAL,CAAd,C;;gBAtB3BvV,U,0BAwB0B,E;;AA+yChC,eAAeA,UAAf","sourcesContent":["import Log from '@deephaven/log';\nimport TableUtils from '@deephaven/iris-grid/dist/TableUtils.js';\nimport dh from '@deephaven/jsapi-shim';\n\nconst log = Log.module('ChartUtils');\n\nconst DAYS = Object.freeze(dh.calendar.DayOfWeek.values());\n\nconst BUSINESS_COLUMN_TYPE = 'io.deephaven.db.tables.utils.DBDateTime';\n\nconst MILLIS_PER_HOUR = 3600000;\n\nconst NANOS_PER_MILLI = 1000000;\n\nclass ChartUtils {\n static DEFAULT_AXIS_SIZE = 0.15;\n\n static MIN_AXIS_SIZE = 0.025;\n\n static MAX_AXIS_SIZE = 0.2;\n\n static AXIS_SIZE_PX = 75;\n\n static LEGEND_WIDTH_PX = 50;\n\n static MAX_LEGEND_SIZE = 0.25;\n\n static ORIENTATION = Object.freeze({\n HORIZONTAL: 'h',\n VERTICAL: 'v',\n });\n\n static DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss.SSSSSS';\n\n static DEFAULT_MARGIN = Object.freeze({ l: 60, r: 50, t: 30, b: 60, pad: 0 });\n\n static DEFAULT_TITLE_PADDING = Object.freeze({ t: 8 });\n\n static SUBTITLE_LINE_HEIGHT = 25;\n\n /**\n * Converts the Iris plot style into a plotly chart type\n * @param {String} plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle\n * @param {boolean} isBusinessTime If the plot is using business time for an axis\n */\n static getPlotlyChartType(plotStyle, isBusinessTime) {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.SCATTER:\n // scattergl mode is more performant, but doesn't support the rangebreaks we need for businessTime calendars\n return !isBusinessTime ? 'scattergl' : 'scatter';\n case dh.plot.SeriesPlotStyle.LINE:\n // There is also still some artifacting bugs with scattergl: https://github.com/plotly/plotly.js/issues/3522\n // The artifacting only occurs on line plots, which we can draw with fairly decent performance using SVG paths\n // Once the above plotly issue is fixed, scattergl should be used here (when !isBusinessTime)\n return 'scatter';\n case dh.plot.SeriesPlotStyle.BAR:\n case dh.plot.SeriesPlotStyle.STACKED_BAR:\n return 'bar';\n\n case dh.plot.SeriesPlotStyle.PIE:\n return 'pie';\n\n case dh.plot.SeriesPlotStyle.HISTOGRAM:\n return 'histogram';\n\n case dh.plot.SeriesPlotStyle.OHLC:\n return 'ohlc';\n\n default:\n return null;\n }\n }\n\n /**\n * Converts the Iris plot style into a plotly chart mode\n * @param {String} plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle.*\n */\n static getPlotlyChartMode(plotStyle) {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.SCATTER:\n return 'markers';\n case dh.plot.SeriesPlotStyle.LINE:\n return 'lines';\n default:\n return null;\n }\n }\n\n /**\n * Get the property to set on the series data for plotly\n * @param {dh.plot.SeriesPlotStyle} plotStyle The plot style of the series\n * @param {dh.plot.SourceType} sourceType The source type for the series\n */\n static getPlotlyProperty(plotStyle, sourceType) {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.PIE:\n switch (sourceType) {\n case dh.plot.SourceType.X:\n return 'labels';\n case dh.plot.SourceType.Y:\n return 'values';\n default:\n break;\n }\n break;\n case dh.plot.SeriesPlotStyle.OHLC:\n switch (sourceType) {\n case dh.plot.SourceType.TIME:\n return 'x';\n default:\n break;\n }\n break;\n default:\n break;\n }\n\n switch (sourceType) {\n case dh.plot.SourceType.X:\n return 'x';\n case dh.plot.SourceType.Y:\n return 'y';\n case dh.plot.SourceType.Z:\n return 'z';\n case dh.plot.SourceType.X_LOW:\n return 'xLow';\n case dh.plot.SourceType.X_HIGH:\n return 'xHigh';\n case dh.plot.SourceType.Y_LOW:\n return 'yLow';\n case dh.plot.SourceType.Y_HIGH:\n return 'yHigh';\n case dh.plot.SourceType.TIME:\n return 'time';\n case dh.plot.SourceType.OPEN:\n return 'open';\n case dh.plot.SourceType.HIGH:\n return 'high';\n case dh.plot.SourceType.LOW:\n return 'low';\n case dh.plot.SourceType.CLOSE:\n return 'close';\n case dh.plot.SourceType.SHAPE:\n return 'shape';\n case dh.plot.SourceType.SIZE:\n return 'size';\n case dh.plot.SourceType.LABEL:\n return 'label';\n case dh.plot.SourceType.COLOR:\n return 'color';\n default:\n throw new Error('Unrecognized source type', sourceType);\n }\n }\n\n static getPlotlySeriesOrientation(series) {\n const { sources } = series;\n if (sources.length === 2 && sources[0].axis.type === dh.plot.AxisType.Y) {\n return ChartUtils.ORIENTATION.HORIZONTAL;\n }\n\n return ChartUtils.ORIENTATION.VERTICAL;\n }\n\n /**\n * Generate the plotly error bar data from the passed in data.\n * Iris passes in the values as absolute, plotly needs them as relative.\n * @param {Array[Number]} x The main data array\n * @param {Array[Number]} xLow The absolute low values\n * @param {Array[Number]} xHigh\n *\n * @returns {Object} The error_x object required by plotly, or null if none is required\n */\n static getPlotlyErrorBars(x, xLow, xHigh) {\n const array = xHigh.map((value, i) => value - x[i]);\n const arrayminus = xLow.map((value, i) => x[i] - value);\n return {\n type: 'data',\n symmetric: false,\n array,\n arrayminus,\n };\n }\n\n static getPlotlyDateFormat(formatter, columnType, formatPattern) {\n const tickformat =\n formatPattern == null\n ? null\n : formatPattern\n .replace('%', '%%')\n .replace(/S{9}/g, '%9f')\n .replace(/S{8}/g, '%8f')\n .replace(/S{7}/g, '%7f')\n .replace(/S{6}/g, '%6f')\n .replace(/S{5}/g, '%5f')\n .replace(/S{4}/g, '%4f')\n .replace(/S{3}/g, '%3f')\n .replace(/S{2}/g, '%2f')\n .replace(/S{1}/g, '%1f')\n .replace(/y{4}/g, '%Y')\n .replace(/y{2}/g, '%y')\n .replace(/M{4}/g, '%B')\n .replace(/M{3}/g, '%b')\n .replace(/M{2}/g, '%m')\n .replace(/M{1}/g, '%-m')\n .replace(/E{4,}/g, '%A')\n .replace(/E{1,}/g, '%a')\n .replace(/d{2}/g, '%d')\n .replace(/([^%]|^)d{1}/g, '$1%-d')\n .replace(/H{2}/g, '%H')\n .replace(/h{2}/g, '%I')\n .replace(/h{1}/g, '%-I')\n .replace(/m{2}/g, '%M')\n .replace(/s{2}/g, '%S')\n .replace(\"'T'\", 'T')\n .replace(' z', ''); // timezone added as suffix if necessary\n\n let ticksuffix = null;\n const dataFormatter = formatter.getColumnTypeFormatter(columnType);\n if (dataFormatter.dhTimeZone != null && dataFormatter.showTimeZone) {\n ticksuffix = dh.i18n.DateTimeFormat.format(\n ' z',\n new Date(),\n dataFormatter.dhTimeZone\n );\n }\n\n return { tickformat, ticksuffix, automargin: true };\n }\n\n static convertNumberPrefix(prefix) {\n return prefix.replace(/\\u00A4\\u00A4/g, 'USD').replace(/\\u00A4/g, '$');\n }\n\n static getPlotlyNumberFormat(formatter, columnType, formatPattern) {\n if (!formatPattern) {\n return null;\n }\n\n // We translate java formatting: https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html\n // Into d3 number formatting: https://github.com/d3/d3-format\n // We can't translate number formatting exactly, but should be able to translate the most common cases\n // First split it into the subpatterns; currently only handling the positive subpattern, ignoring the rest\n const subpatterns = formatPattern.split(';');\n const [\n ,\n prefix,\n placeholderDigits,\n zeroDigits,\n ,\n decimalDigits,\n optionalDecimalDigits,\n numberType,\n percentSign,\n suffix,\n ] = subpatterns[0].match(\n /^([^#,0.]*)([#,]*)([0,]*)(\\.?)(0*)(#*)(E?0*)(%?)(.*)/\n );\n\n const paddingLength = zeroDigits.replace(',', '').length;\n const isCommaSeparated =\n placeholderDigits.indexOf(',') >= 0 || zeroDigits.indexOf(',') >= 0;\n const comma = isCommaSeparated ? ',' : '';\n const plotlyNumberType = numberType ? 'e' : 'f';\n const type = percentSign || plotlyNumberType;\n const decimalLength = decimalDigits.length + optionalDecimalDigits.length;\n // IDS-4565 Plotly uses an older version of d3 which doesn't support the trim option or negative brackets\n // If plotly updates it's d3 version, this should be re-enabled\n // const trimOption = optionalDecimalDigits.length > 0 ? '~' : '';\n const trimOption = '';\n\n const tickformat = `0${paddingLength}${comma}.${decimalLength}${trimOption}${type}`;\n const tickprefix = ChartUtils.convertNumberPrefix(prefix);\n // prefix and suffix are processed the same\n const ticksuffix = ChartUtils.convertNumberPrefix(suffix);\n\n return { tickformat, tickprefix, ticksuffix, automargin: true };\n }\n\n /**\n * Gets the plotly axis formatting information from the source passed in\n * @param {dh.plot.Source} source The Source to get the formatter information from\n * @param {Formatter} formatter The current formatter for formatting data\n */\n static getPlotlyAxisFormat(source, formatter = null) {\n const { axis, columnType } = source;\n const { formatPattern } = axis;\n\n let axisFormat = null;\n if (TableUtils.isDateType(columnType)) {\n axisFormat = ChartUtils.getPlotlyDateFormat(\n formatter,\n columnType,\n formatPattern\n );\n axisFormat = ChartUtils.addTickSpacing(axisFormat, axis, true);\n } else if (TableUtils.isNumberType(columnType)) {\n axisFormat = ChartUtils.getPlotlyNumberFormat(\n formatter,\n columnType,\n formatPattern\n );\n axisFormat = ChartUtils.addTickSpacing(axisFormat, axis, false);\n }\n\n if (axis.formatType === dh.plot.AxisFormatType.CATEGORY) {\n if (axisFormat) {\n axisFormat.type = 'category';\n } else {\n axisFormat = { type: 'category', tickformat: null, ticksuffix: null };\n }\n }\n\n return axisFormat;\n }\n\n /**\n * Adds tick spacing for an axis that has gapBetweenMajorTicks defined.\n *\n * @param {object} axisFormat the current axis format, may be null\n * @param {object} axis the current axis\n * @param {boolean} isDateType indicates if the columns is a date type\n */\n static addTickSpacing(axisFormat, axis, isDateType) {\n const { gapBetweenMajorTicks } = axis;\n if (gapBetweenMajorTicks > 0) {\n const updatedFormat = axisFormat || {};\n let tickSpacing = gapBetweenMajorTicks;\n if (isDateType) {\n // Need to convert from nanoseconds to milliseconds\n tickSpacing = gapBetweenMajorTicks / NANOS_PER_MILLI;\n }\n if (axis.log) {\n tickSpacing = Math.log(tickSpacing);\n }\n // Note that tickmode defaults to 'auto'\n updatedFormat.tickmode = 'linear';\n updatedFormat.dtick = tickSpacing;\n return updatedFormat;\n }\n\n return axisFormat;\n }\n\n /**\n * Retrieve the data source for a given axis in a chart\n * @param {dh.plot.Chart} chart The chart to get the source for\n * @param {dh.plot.Axis} axis The axis to find the source for\n * @returns {dh.plot.Source} The first source matching this axis\n */\n static getSourceForAxis(chart, axis) {\n for (let i = 0; i < chart.series.length; i += 1) {\n const series = chart.series[i];\n for (let j = 0; j < series.sources.length; j += 1) {\n const source = series.sources[j];\n if (source.axis === axis) {\n return source;\n }\n }\n }\n\n return null;\n }\n\n /**\n * Get visibility setting for the series object\n * @param {string} name The series name to get the visibility for\n * @param {object} settings Chart settings\n * @returns {boolean|string} True for visible series and 'legendonly' for hidden\n */\n static getSeriesVisibility(name, settings) {\n if (settings?.hiddenSeries?.includes(name)) {\n return 'legendonly';\n }\n return true;\n }\n\n /**\n * Get hidden labels array from chart settings\n * @param {object} settings Chart settings\n * @returns {string[]} Array of hidden series names\n */\n static getHiddenLabels(settings) {\n if (settings?.hiddenSeries) {\n return [...settings.hiddenSeries];\n }\n return [];\n }\n\n /**\n * Create a default series data object. Apply styling to the object afterward.\n * @returns {Object} A simple series data object with no styling\n */\n static makeSeriesData(\n type,\n mode,\n name,\n orientation = ChartUtils.ORIENTATION.VERTICAL\n ) {\n return { type, mode, name, orientation };\n }\n\n /**\n * Create a data series (trace) for use with plotly\n * @param {dh.plot.Series} series The series to create the series data with\n * @param {Map<dh.plot.AxisType, dh.plot.Axis[]>} axisTypeMap The map of axes grouped by type\n * @param {boolean|string} seriesVisibility Visibility setting for the series\n * @param {Object} theme The theme properties for the plot. See ChartTheme.js for an example\n * @returns {Object} The series data (trace) object for use with plotly.\n */\n static makeSeriesDataFromSeries(\n series,\n axisTypeMap,\n seriesVisibility,\n theme\n ) {\n const { name, plotStyle, lineColor, shapeColor, sources } = series;\n\n const isBusinessTime = sources.some(source => source.axis.businessCalendar);\n const type = ChartUtils.getChartType(plotStyle, isBusinessTime);\n const mode = ChartUtils.getPlotlyChartMode(plotStyle);\n const orientation = ChartUtils.getPlotlySeriesOrientation(series);\n\n const seriesData = ChartUtils.makeSeriesData(type, mode, name, orientation);\n\n ChartUtils.addSourcesToSeriesData(\n seriesData,\n plotStyle,\n sources,\n axisTypeMap\n );\n\n ChartUtils.addStylingToSeriesData(\n seriesData,\n plotStyle,\n theme,\n lineColor,\n shapeColor,\n seriesVisibility\n );\n\n return seriesData;\n }\n\n static addSourcesToSeriesData(\n seriesDataParam,\n plotStyle,\n sources,\n axisTypeMap\n ) {\n const seriesData = seriesDataParam;\n for (let k = 0; k < sources.length; k += 1) {\n const source = sources[k];\n const { axis, type: sourceType } = source;\n\n const dataAttributeName = ChartUtils.getPlotlyProperty(\n plotStyle,\n sourceType\n );\n seriesData[dataAttributeName] = [];\n\n const axisProperty = ChartUtils.getAxisPropertyName(axis.type);\n const axes = axisTypeMap.get(axis.type);\n const axisIndex = axes.indexOf(axis);\n if (axisProperty != null) {\n const axisIndexString = axisIndex > 0 ? `${axisIndex + 1}` : '';\n seriesData[`${axisProperty}axis`] = `${axisProperty}${axisIndexString}`;\n }\n }\n }\n\n static addStylingToSeriesData(\n seriesDataParam,\n plotStyle,\n theme = {},\n lineColor = null,\n shapeColor = null,\n seriesVisibility = null\n ) {\n const seriesData = seriesDataParam;\n // Add some empty objects so we can fill them in later with details without checking for existence\n seriesData.marker = { line: {} }; // border line width on markers\n seriesData.line = {\n width: 1, // default line width for lines, should eventually be able to override\n };\n\n if (plotStyle === dh.plot.SeriesPlotStyle.AREA) {\n seriesData.fill = 'tozeroy';\n } else if (plotStyle === dh.plot.SeriesPlotStyle.STACKED_AREA) {\n seriesData.stackgroup = 'stack';\n } else if (plotStyle === dh.plot.SeriesPlotStyle.STEP) {\n seriesData.line.shape = 'hv'; // plot.ly horizontal then vertical step styling\n } else if (plotStyle === dh.plot.SeriesPlotStyle.HISTOGRAM) {\n // The default histfunc in plotly is 'count', but the data passed up from the API provides explicit x/y values and bins\n // Since it's converted to bar, just set the widths of each bar\n seriesData.width = [];\n Object.assign(seriesData.marker.line, {\n color: theme.paper_bgcolor,\n width: 1,\n });\n } else if (plotStyle === dh.plot.SeriesPlotStyle.OHLC) {\n seriesData.increasing = {\n line: { color: theme.ohlc_increasing },\n };\n seriesData.decreasing = {\n line: { color: theme.ohlc_decreasing },\n };\n } else if (plotStyle === dh.plot.SeriesPlotStyle.PIE) {\n seriesData.textinfo = 'label+percent';\n seriesData.outsidetextfont = { color: theme.title_color };\n }\n\n if (lineColor != null) {\n if (plotStyle === dh.plot.SeriesPlotStyle.BAR) {\n seriesData.marker.color = lineColor;\n } else {\n seriesData.line.color = lineColor;\n }\n }\n\n if (shapeColor != null) {\n seriesData.marker.color = shapeColor;\n }\n\n // Skipping pie charts\n // Pie slice visibility is configured in chart layout instead of series data\n if (seriesVisibility != null && plotStyle !== dh.plot.SeriesPlotStyle.PIE) {\n seriesData.visible = seriesVisibility;\n }\n }\n\n /**\n * Retrieve the axis formats from the provided figure.\n * Currently defaults to just the x/y axes.\n * @param {dh.plot.Figure} figure The figure to get the axis formats for\n * @param {Formatter} formatter The formatter to use when getting the axis format\n * @returns {Map<string, object>} A map of axis layout property names to axis formats\n */\n static getAxisFormats(figure, formatter) {\n const axisFormats = new Map();\n const nullFormat = { tickformat: null, ticksuffix: null };\n\n const { charts } = figure;\n\n for (let i = 0; i < charts.length; i += 1) {\n const chart = charts[i];\n const axisTypeMap = ChartUtils.groupArray(chart.axes, 'type');\n\n for (let j = 0; j < chart.series.length; j += 1) {\n const series = chart.series[j];\n const { sources } = series;\n\n for (let k = 0; k < sources.length; k += 1) {\n const source = sources[k];\n const { axis } = source;\n const { type: axisType } = axis;\n const typeAxes = axisTypeMap.get(axisType);\n const axisIndex = typeAxes.indexOf(axis);\n const axisProperty = ChartUtils.getAxisPropertyName(axisType);\n const axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n\n if (axisFormats.has(axisLayoutProperty)) {\n log.debug(`${axisLayoutProperty} already added.`);\n } else {\n log.debug(`Adding ${axisLayoutProperty} to axisFormats.`);\n const axisFormat = ChartUtils.getPlotlyAxisFormat(\n source,\n formatter\n );\n if (axisFormat === null) {\n axisFormats.set(axisLayoutProperty, nullFormat);\n } else {\n axisFormats.set(axisLayoutProperty, axisFormat);\n\n const { businessCalendar } = axis;\n if (businessCalendar) {\n axisFormat.rangebreaks = [];\n const {\n businessPeriods,\n businessDays,\n holidays,\n timeZone: calendarTimeZone,\n } = businessCalendar;\n const formatterTimeZone = formatter?.getColumnTypeFormatter(\n BUSINESS_COLUMN_TYPE\n )?.dhTimeZone;\n const timeZoneDiff = formatterTimeZone\n ? (calendarTimeZone.standardOffset -\n formatterTimeZone.standardOffset) /\n 60\n : 0;\n if (holidays.length > 0) {\n axisFormat.rangebreaks.push(\n ...ChartUtils.createRangeBreakValuesFromHolidays(\n holidays,\n calendarTimeZone,\n formatterTimeZone\n )\n );\n }\n businessPeriods.forEach(period =>\n axisFormat.rangebreaks.push({\n pattern: 'hour',\n bounds: [\n ChartUtils.periodToDecimal(period.close) + timeZoneDiff,\n ChartUtils.periodToDecimal(period.open) + timeZoneDiff,\n ],\n })\n );\n // If there are seven business days, then there is no weekend\n if (businessDays.length < DAYS.length) {\n ChartUtils.createBoundsFromDays(businessDays).forEach(\n weekendBounds =>\n axisFormat.rangebreaks.push({\n pattern: 'day of week',\n bounds: weekendBounds,\n })\n );\n }\n }\n\n if (axisFormats.size === chart.axes.length) {\n return axisFormats;\n }\n }\n }\n }\n }\n }\n\n return axisFormats;\n }\n\n static getChartType(plotStyle, isBusinessTime) {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.HISTOGRAM:\n // When reading data from the `Figure`, it already provides bins and values, so rather than using\n // plot.ly to calculate the bins and sum values, just convert it to a bar chart\n return 'bar';\n default:\n return ChartUtils.getPlotlyChartType(plotStyle, isBusinessTime);\n }\n }\n\n /**\n * Return the plotly axis property name\n * @param {dh.plot.AxisType} axisType The axis type to get the property name for\n */\n static getAxisPropertyName(axisType) {\n switch (axisType) {\n case dh.plot.AxisType.X:\n return 'x';\n case dh.plot.AxisType.Y:\n return 'y';\n default:\n return null;\n }\n }\n\n /**\n * Returns the plotly \"side\" value for the provided axis position\n * @param {dh.plot.AxisPosition} axisPosition The Iris AxisPosition of the axis\n */\n static getAxisSide(axisPosition) {\n switch (axisPosition) {\n case dh.plot.AxisPosition.BOTTOM:\n return 'bottom';\n case dh.plot.AxisPosition.TOP:\n return 'top';\n case dh.plot.AxisPosition.LEFT:\n return 'left';\n case dh.plot.AxisPosition.RIGHT:\n return 'right';\n default:\n return null;\n }\n }\n\n /**\n * Retrieve the chart that contains the passed in series from the figure\n * @param {dh.plot.Figure} figure The figure to retrieve the chart from\n * @param {dh.plot.Series} series The series to get the chart for\n */\n static getChartForSeries(figure, series) {\n const { charts } = figure;\n\n for (let i = 0; i < charts.length; i += 1) {\n const chart = charts[i];\n for (let j = 0; j < chart.series.length; j += 1) {\n if (series === chart.series[j]) {\n return chart;\n }\n }\n }\n\n return null;\n }\n\n /**\n * Get an object mapping axis to their ranges\n * @param {object} layout The plotly layout object to get the ranges from\n * @returns {object} An object mapping the axis name to it's range\n */\n static getLayoutRanges(layout) {\n const ranges = {};\n const keys = Object.keys(layout).filter(key => key.indexOf('axis') >= 0);\n for (let i = 0; i < keys.length; i += 1) {\n const key = keys[i];\n if (layout[key] && layout[key].range && !layout[key].autorange) {\n // Only want to add the range if it's not autoranged\n ranges[key] = [...layout[key].range];\n }\n }\n\n return ranges;\n }\n\n /**\n * Updates the axes positions and sizes in the layout object provided.\n * If the axis did not exist in the layout previously, it is created and added.\n * Any axis that no longer exists in axes is removed.\n * With Downsampling enabled, will also update the range on the axis itself as appropriate\n * @param {object} layoutParam The layout object to update\n * @param {dh.plot.Axis[]} axes The axes to update the layout with\n * @param {number} plotWidth The width of the plot to calculate the axis sizes for\n * @param {number} plotHeight The height of the plot to calculate the axis sizes for\n * @param {func} getRangeParser A function to retrieve the range parser for a given axis\n */\n static updateLayoutAxes(\n layoutParam,\n axes,\n plotWidth = 0,\n plotHeight = 0,\n getRangeParser = null,\n theme = {}\n ) {\n const xAxisSize =\n plotWidth > 0\n ? Math.max(\n ChartUtils.MIN_AXIS_SIZE,\n Math.min(\n ChartUtils.AXIS_SIZE_PX / plotHeight,\n ChartUtils.MAX_AXIS_SIZE\n )\n )\n : ChartUtils.DEFAULT_AXIS_SIZE;\n const yAxisSize =\n plotHeight > 0\n ? Math.max(\n ChartUtils.MIN_AXIS_SIZE,\n Math.min(\n ChartUtils.AXIS_SIZE_PX / plotWidth,\n ChartUtils.MAX_AXIS_SIZE\n )\n )\n : ChartUtils.DEFAULT_AXIS_SIZE;\n\n // Adjust the bounds based on where the legend is\n // For now, always assume the legend is shown on the right\n const bounds = {\n left: 0,\n bottom: 0,\n top: 1,\n right: 1,\n };\n const axisPositionMap = ChartUtils.groupArray(axes, 'position');\n const rightAxes = axisPositionMap.get(dh.plot.AxisPosition.RIGHT) || [];\n if (rightAxes.length > 0) {\n if (plotWidth > 0) {\n bounds.right =\n 1 -\n Math.max(\n 0,\n Math.min(\n ChartUtils.LEGEND_WIDTH_PX / plotWidth,\n ChartUtils.MAX_LEGEND_SIZE\n )\n );\n } else {\n bounds.right = 1 - ChartUtils.DEFAULT_AXIS_SIZE;\n }\n }\n\n const layout = layoutParam;\n const axisTypeMap = ChartUtils.groupArray(axes, 'type');\n const axisTypes = [...axisTypeMap.keys()];\n for (let j = 0; j < axisTypes.length; j += 1) {\n const axisType = axisTypes[j];\n const axisProperty = ChartUtils.getAxisPropertyName(axisType);\n if (axisProperty != null) {\n const typeAxes = axisTypeMap.get(axisType);\n const isYAxis = axisType === dh.plot.AxisType.Y;\n const plotSize = isYAxis ? plotHeight : plotWidth;\n let axisIndex = 0;\n for (axisIndex = 0; axisIndex < typeAxes.length; axisIndex += 1) {\n const axis = typeAxes[axisIndex];\n const axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n if (layout[axisLayoutProperty] == null) {\n layout[axisLayoutProperty] = ChartUtils.makeLayoutAxis(\n axisType,\n theme\n );\n }\n\n const layoutAxis = layout[axisLayoutProperty];\n ChartUtils.updateLayoutAxis(\n layoutAxis,\n axis,\n axisIndex,\n axisPositionMap,\n xAxisSize,\n yAxisSize,\n bounds\n );\n const { range, autorange } = layoutAxis;\n if (getRangeParser && range && !autorange) {\n const rangeParser = getRangeParser(axis);\n const [rangeStart, rangeEnd] = rangeParser(range);\n\n log.debug(\n 'Setting downsample range',\n plotSize,\n rangeStart,\n rangeEnd\n );\n\n axis.range(plotSize, rangeStart, rangeEnd);\n } else {\n axis.range(plotSize);\n }\n }\n\n let axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n while (layout[axisLayoutProperty] != null) {\n delete layout[axisLayoutProperty];\n\n axisIndex += 1;\n axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n }\n }\n }\n }\n\n static getAxisLayoutProperty(axisProperty, axisIndex) {\n const axisIndexString = axisIndex > 0 ? `${axisIndex + 1}` : '';\n return `${axisProperty}axis${axisIndexString}`;\n }\n\n /**\n * Updates the layout axis object in place\n * @param {object} layoutAxisParam The plotly layout axis param\n * @param {dh.plot.Axis} axis The Iris Axis to update the plotly layout with\n * @param {number} axisIndex The type index for this axis\n * @param {Map<dh.plot.AxisPosition, dh.plot.Axis>} axisPositionMap All the axes mapped by position\n * @param {number} axisSize The size of each axis in percent\n * @param {object} bounds The bounds of the axes domains\n */\n static updateLayoutAxis(\n layoutAxisParam,\n axis,\n axisIndex,\n axisPositionMap,\n xAxisSize,\n yAxisSize,\n bounds\n ) {\n const isYAxis = axis.type === dh.plot.AxisType.Y;\n const axisSize = isYAxis ? yAxisSize : xAxisSize;\n const layoutAxis = layoutAxisParam;\n layoutAxis.title.text = axis.label;\n if (axis.log) {\n layoutAxis.type = 'log';\n }\n layoutAxis.side = ChartUtils.getAxisSide(axis.position);\n if (axisIndex > 0) {\n layoutAxis.overlaying = ChartUtils.getAxisPropertyName(axis.type);\n\n const positionAxes = axisPositionMap.get(axis.position);\n const sideIndex = positionAxes.indexOf(axis);\n if (sideIndex > 0) {\n layoutAxis.anchor = 'free';\n\n if (axis.position === dh.plot.AxisPosition.RIGHT) {\n layoutAxis.position =\n bounds.right + (sideIndex - positionAxes.length + 1) * axisSize;\n } else if (axis.position === dh.plot.AxisPosition.TOP) {\n layoutAxis.position =\n bounds.top + (sideIndex - positionAxes.length + 1) * axisSize;\n } else if (axis.position === dh.plot.AxisPosition.BOTTOM) {\n layoutAxis.position =\n bounds.bottom + (positionAxes.length - sideIndex + 1) * axisSize;\n } else if (axis.position === dh.plot.AxisPosition.LEFT) {\n layoutAxis.position =\n bounds.left + (positionAxes.length - sideIndex + 1) * axisSize;\n }\n }\n } else if (axis.type === dh.plot.AxisType.X) {\n const leftAxes = axisPositionMap.get(dh.plot.AxisPosition.LEFT) || [];\n const rightAxes = axisPositionMap.get(dh.plot.AxisPosition.RIGHT) || [];\n const left = Math.max(\n bounds.left,\n bounds.left + (leftAxes.length - 1) * yAxisSize\n );\n const right = Math.min(\n bounds.right - (rightAxes.length - 1) * yAxisSize,\n bounds.right\n );\n layoutAxis.domain = [left, right];\n } else if (axis.type === dh.plot.AxisType.Y) {\n const bottomAxes = axisPositionMap.get(dh.plot.AxisPosition.BOTTOM) || [];\n const topAxes = axisPositionMap.get(dh.plot.AxisPosition.TOP) || [];\n const bottom = Math.max(\n bounds.bottom,\n bounds.bottom + (bottomAxes.length - 1) * xAxisSize\n );\n const top = Math.min(\n bounds.top - (topAxes.length - 1) * xAxisSize,\n bounds.top\n );\n layoutAxis.domain = [bottom, top];\n }\n }\n\n /**\n * Converts an open or close period to a declimal. e.g '09:30\" to 9.5\n *\n * @param {String} period the open or close value of the period\n */\n static periodToDecimal(period) {\n const values = period.split(':');\n return Number(values[0]) + Number(values[1] / 60);\n }\n\n /**\n * Creates range break bounds for plotly from business days.\n * For example a standard business week of ['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY']\n * will result in [[6,1]] meaning close on Saturday and open on Monday.\n * If you remove Wednesday from the array, then you get two closures [[6, 1], [3, 4]]\n *\n * @param {Array} businessDays the days to display on the x-axis\n */\n static createBoundsFromDays(businessDays) {\n const businessDaysInt = businessDays.map(day => DAYS.indexOf(day));\n const nonBusinessDaysInt = DAYS.filter(\n day => !businessDays.includes(day)\n ).map(day => DAYS.indexOf(day));\n // These are the days when business reopens (e.g. Monday after a weekend)\n const reopenDays = new Set();\n nonBusinessDaysInt.forEach(closed => {\n for (let i = closed + 1; i < closed + DAYS.length; i += 1) {\n const adjustedDay = i % DAYS.length;\n if (businessDaysInt.includes(adjustedDay)) {\n reopenDays.add(adjustedDay);\n break;\n }\n }\n });\n const boundsArray = [];\n // For each reopen day, find the furthest previous closed day\n reopenDays.forEach(open => {\n for (let i = open - 1; i > open - DAYS.length; i -= 1) {\n const adjustedDay = i < 0 ? i + DAYS.length : i;\n if (businessDaysInt.includes(adjustedDay)) {\n const closedDay = (adjustedDay + 1) % 7;\n boundsArray.push([closedDay, open]);\n break;\n }\n }\n });\n return boundsArray;\n }\n\n /**\n * Creates an array of range breaks for all holidays.\n *\n * @param {Array} holidays an array of holidays\n * @param {TimeZone} calendarTimeZone the time zone for the business calendar\n * @param {TimeZone} formatterTimeZone the time zone for the formatter\n */\n static createRangeBreakValuesFromHolidays(\n holidays,\n calendarTimeZone,\n formatterTimeZone\n ) {\n const fullHolidays = [];\n const partialHolidays = [];\n holidays.forEach(holiday => {\n if (holiday.businessPeriods.length > 0) {\n partialHolidays.push(\n ...ChartUtils.createPartialHoliday(\n holiday,\n calendarTimeZone,\n formatterTimeZone\n )\n );\n } else {\n fullHolidays.push(\n ChartUtils.createFullHoliday(\n holiday,\n calendarTimeZone,\n formatterTimeZone\n )\n );\n }\n });\n return [{ values: fullHolidays }, ...partialHolidays];\n }\n\n /**\n * Creates the range break value for a full holiday. A full holiday is day that has no business periods.\n *\n * @param {Holiday} holiday the full holiday\n * @param {TimeZone} calendarTimeZone the time zone for the business calendar\n * @param {TimeZone} formatterTimeZone the time zone for the formatter\n */\n static createFullHoliday(holiday, calendarTimeZone, formatterTimeZone) {\n return ChartUtils.adjustDateForTimeZone(\n `${holiday.date.toString()} 00:00:00.000000`,\n calendarTimeZone,\n formatterTimeZone\n );\n }\n\n /**\n * Creates the range break for a partial holiday. A partial holiday is holiday with business periods\n * that are different than the default business periods.\n *\n * @param {Holiday} holiday the partial holiday\n * @param {TimeZone} calendarTimeZone the time zone for the business calendar\n * @param {TimeZone} formatterTimeZone the time zone for the formatter\n */\n static createPartialHoliday(holiday, calendarTimeZone, formatterTimeZone) {\n // If a holiday has business periods {open1, close1} and {open2, close2}\n // This will generate range breaks for:\n // closed from 00:00 to open1\n // closed from close1 to open2\n // closed from close2 to 23:59:59.999999\n const dateString = holiday.date.toString();\n const closedPeriods = ['00:00'];\n holiday.businessPeriods.forEach(period => {\n closedPeriods.push(period.open);\n closedPeriods.push(period.close);\n });\n // To go up to 23:59:59.999999, we calculate the dvalue using 24 - close\n closedPeriods.push('24:00');\n\n const rangeBreaks = [];\n for (let i = 0; i < closedPeriods.length; i += 2) {\n const startClose = closedPeriods[i];\n const endClose = closedPeriods[i + 1];\n // Skip over any periods where start and close are the same (zero hours)\n if (startClose !== endClose) {\n const values = [\n ChartUtils.adjustDateForTimeZone(\n `${dateString} ${startClose}:00.000000`,\n calendarTimeZone,\n formatterTimeZone\n ),\n ];\n const dvalue =\n MILLIS_PER_HOUR *\n (ChartUtils.periodToDecimal(endClose) -\n ChartUtils.periodToDecimal(startClose));\n rangeBreaks.push({ values, dvalue });\n }\n }\n return rangeBreaks;\n }\n\n /**\n * Adjusts a date string from the calendar time zone to the formatter time zone.\n *\n * @param {string} dateString the date string\n * @param {TimeZone} calendarTimeZone the time zone for the business calendar\n * @param {TimeZone} formatterTimeZone the time zone for the formatter\n */\n static adjustDateForTimeZone(\n dateString,\n calendarTimeZone,\n formatterTimeZone\n ) {\n if (\n formatterTimeZone &&\n formatterTimeZone.standardOffset !== calendarTimeZone.standardOffset\n ) {\n return ChartUtils.unwrapValue(\n ChartUtils.wrapValue(\n dateString,\n BUSINESS_COLUMN_TYPE,\n calendarTimeZone\n ),\n formatterTimeZone\n );\n }\n return dateString;\n }\n\n /**\n * Groups an array and returns a map\n * @param {object[]} array The object to group\n * @param {string} property The property name to group by\n * @returns {Map<object, object>} A map containing the items grouped by their values for the property\n */\n static groupArray(array, property) {\n return array.reduce((result, item) => {\n const key = item[property];\n const group = result.get(key) || [];\n group.push(item);\n result.set(key, group);\n return result;\n }, new Map());\n }\n\n /**\n * Update\n */\n static updateRanges() {}\n\n /**\n * Unwraps a value provided from API to a value plotly can understand\n * Eg. Unwraps DateWrapper, LongWrapper objects.\n */\n static unwrapValue(value, timeZone = null) {\n if (value != null) {\n if (value.asDate) {\n return dh.i18n.DateTimeFormat.format(\n ChartUtils.DATE_FORMAT,\n value,\n timeZone\n );\n }\n\n if (value.asNumber) {\n return value.asNumber();\n }\n }\n\n return value;\n }\n\n /**\n *\n * @param {any} value The value to wrap up\n * @param {string} columnType The type of column this value is from\n * @param {dh.i18n.TimeZone} timeZone The time zone if applicable\n */\n static wrapValue(value, columnType, timeZone = null) {\n if (TableUtils.isDateType(columnType) && typeof value === 'string') {\n // Need to limit the format to the actual length of the string range set in plotly\n // Otherwise parse will fail\n const text = value;\n const format = ChartUtils.DATE_FORMAT.substr(0, value.length);\n const date = dh.i18n.DateTimeFormat.parse(format, text);\n if (!timeZone) {\n return date;\n }\n\n // IDS-5994 Due to date parsing, time zone, and daylight savings shenanigans, we need\n // to pass the actual offset with the time to have it parse correctly.\n // However, the offset can change based on the date because of Daylight Savings\n // So we end up parsing the date multiple times. And curse daylight savings.\n const tzFormat = `${format} Z`;\n const estimatedOffset = dh.i18n.DateTimeFormat.format(\n 'Z',\n date,\n timeZone\n );\n const estimatedDate = dh.i18n.DateTimeFormat.parse(\n tzFormat,\n `${text} ${estimatedOffset}`\n );\n const offset = dh.i18n.DateTimeFormat.format(\n 'Z',\n estimatedDate,\n timeZone\n );\n return dh.i18n.DateTimeFormat.parse(tzFormat, `${text} ${offset}`);\n }\n\n return value;\n }\n\n static makeLayoutAxis(type, theme = {}) {\n const axis = {\n automargin: true,\n gridcolor: theme.gridcolor,\n linecolor: theme.linecolor,\n rangeslider: { visible: false },\n showline: true,\n ticklen: 5, // act as padding, can't find a tick padding\n tickcolor: theme.paper_bgcolor, // hide ticks as padding\n tickfont: {\n color: theme.zerolinecolor,\n },\n title: {\n font: {\n color: theme.title_color,\n },\n },\n };\n\n if (type === dh.plot.AxisType.X) {\n Object.assign(axis, {\n showgrid: true,\n });\n } else if (type === dh.plot.AxisType.Y) {\n Object.assign(axis, {\n zerolinecolor: theme.zerolinecolor,\n zerolinewidth: 2,\n });\n }\n\n return axis;\n }\n\n /**\n * Parses the colorway property of a theme and returns an array of colors\n * Theme could have a single string with space separated colors or an array of strings representing the colorway\n * @param {ChartTheme} theme The theme to get colorway from\n * @returns {string[]} Colorway array for the theme\n */\n static getColorwayFromTheme(theme) {\n let colorway = [];\n if (theme.colorway) {\n if (Array.isArray(theme.colorway)) {\n colorway = theme.colorway;\n } else if (typeof theme.colorway === 'string') {\n colorway = theme.colorway.split(' ');\n } else {\n log.warn(`Unable to handle colorway property: ${theme.colorway}`);\n }\n }\n\n return colorway;\n }\n\n static makeDefaultLayout(theme = {}) {\n const layout = {\n ...theme,\n autosize: true,\n colorway: ChartUtils.getColorwayFromTheme(theme),\n font: {\n family: \"'Fira Sans', sans-serif\",\n },\n title: {\n font: {\n color: theme.title_color,\n },\n yanchor: 'top',\n pad: { ...ChartUtils.DEFAULT_TITLE_PADDING },\n y: 1,\n },\n legend: {\n font: {\n color: theme.title_color,\n },\n },\n margin: { ...ChartUtils.DEFAULT_MARGIN },\n xaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.X, theme),\n yaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.Y, theme),\n };\n layout.datarevision = 0;\n return layout;\n }\n\n /**\n * Dehydrate settings so they can be JSONified\n * @param {object} settings Chart builder settings\n */\n static dehydrateSettings(settings) {\n return {\n ...settings,\n type: `${settings.type}`,\n };\n }\n\n /**\n * Hydrate settings from a JSONable object\n * @param {object} settings Dehydrated settings\n */\n static hydrateSettings(settings) {\n return {\n ...settings,\n type: dh.plot.SeriesPlotStyle[settings.type],\n };\n }\n\n static titleFromSettings(settings) {\n const {\n series,\n xAxis,\n title = `${series.join(', ')} by ${xAxis}`,\n } = settings;\n\n return title;\n }\n\n /**\n * Creates the Figure settings from the Chart Builder settings\n * This should be deprecated at some point, and have Chart Builder create the figure settings directly.\n * This logic will still need to exist to translate existing charts, but could be part of a migration script\n * to translate the data.\n * Change when we decide to add more functionality to the Chart Builder.\n * @param {object} settings The chart builder settings\n * @param {string} settings.title The title for this figure\n * @param {string} settings.xAxis The name of the column to use for the x-axis\n * @param {string[]} settings.series The name of the columns to use for the series of this figure\n * @param {dh.plot.SeriesPlotStyle} settings.type The plot style for this figure\n */\n static makeFigureSettings(settings, table) {\n const { series, xAxis: settingsAxis, type } = settings;\n const title = ChartUtils.titleFromSettings(settings);\n const xAxis = {\n formatType: `${dh.plot.AxisFormatType.NUMBER}`,\n type: `${dh.plot.AxisType.X}`,\n position: `${dh.plot.AxisPosition.BOTTOM}`,\n };\n const yAxis = {\n formatType: `${dh.plot.AxisFormatType.NUMBER}`,\n type: `${dh.plot.AxisType.Y}`,\n position: `${dh.plot.AxisPosition.LEFT}`,\n };\n\n return {\n charts: [\n {\n chartType: `${dh.plot.ChartType.XY}`,\n axes: [xAxis, yAxis],\n series: series.map(name => ({\n plotStyle: `${type}`,\n name,\n dataSources: [\n {\n type: `${dh.plot.SourceType.X}`,\n columnName: settingsAxis,\n axis: xAxis,\n table,\n },\n {\n type: `${dh.plot.SourceType.Y}`,\n columnName: name,\n axis: yAxis,\n table,\n },\n ],\n })),\n },\n ],\n title,\n };\n }\n}\n\nexport default ChartUtils;\n"],"file":"ChartUtils.js"}
1
+ {"version":3,"sources":["../src/ChartUtils.js"],"names":["Log","TableUtils","dh","ChartTheme","log","module","DAYS","Object","freeze","calendar","DayOfWeek","values","BUSINESS_COLUMN_TYPE","MILLIS_PER_HOUR","NANOS_PER_MILLI","ChartUtils","getPlotlyChartType","plotStyle","isBusinessTime","plot","SeriesPlotStyle","SCATTER","LINE","BAR","STACKED_BAR","PIE","HISTOGRAM","OHLC","getPlotlyChartMode","getPlotlyProperty","sourceType","SourceType","X","Y","TIME","Z","X_LOW","X_HIGH","Y_LOW","Y_HIGH","OPEN","HIGH","LOW","CLOSE","SHAPE","SIZE","LABEL","COLOR","Error","getPlotlySeriesOrientation","series","sources","length","axis","type","AxisType","ORIENTATION","HORIZONTAL","VERTICAL","getPlotlyErrorBars","x","xLow","xHigh","array","map","value","i","arrayminus","symmetric","getPlotlyDateFormat","formatter","columnType","formatPattern","tickformat","replace","ticksuffix","dataFormatter","getColumnTypeFormatter","dhTimeZone","showTimeZone","i18n","DateTimeFormat","format","Date","automargin","convertNumberPrefix","prefix","getPlotlyNumberFormat","subpatterns","split","placeholderDigits","zeroDigits","decimalDigits","optionalDecimalDigits","numberType","percentSign","suffix","match","paddingLength","isCommaSeparated","indexOf","comma","plotlyNumberType","decimalLength","trimOption","tickprefix","getPlotlyAxisFormat","source","axisFormat","isDateType","addTickSpacing","isNumberType","formatType","AxisFormatType","CATEGORY","gapBetweenMajorTicks","updatedFormat","tickSpacing","Math","tickmode","dtick","getSourceForAxis","chart","j","getSeriesVisibility","name","settings","hiddenSeries","includes","getHiddenLabels","makeSeriesData","mode","orientation","makeSeriesDataFromSeries","axisTypeMap","seriesVisibility","lineColor","shapeColor","some","businessCalendar","getChartType","seriesData","addSourcesToSeriesData","addStylingToSeriesData","seriesDataParam","k","dataAttributeName","axisProperty","getAxisPropertyName","axes","get","axisIndex","axisIndexString","marker","line","width","AREA","fill","STACKED_AREA","stackgroup","STEP","shape","assign","color","paper_bgcolor","increasing","ohlc_increasing","decreasing","ohlc_decreasing","textinfo","outsidetextfont","title_color","visible","getAxisFormats","figure","axisFormats","Map","nullFormat","charts","groupArray","axisType","typeAxes","axisLayoutProperty","getAxisLayoutProperty","has","debug","set","rangebreaks","businessPeriods","businessDays","holidays","timeZone","calendarTimeZone","formatterTimeZone","timeZoneDiff","standardOffset","push","createRangeBreakValuesFromHolidays","forEach","period","pattern","bounds","periodToDecimal","close","open","createBoundsFromDays","weekendBounds","size","getAxisSide","axisPosition","AxisPosition","BOTTOM","TOP","LEFT","RIGHT","getChartForSeries","getLayoutRanges","layout","ranges","keys","filter","key","range","autorange","updateLayoutAxes","layoutParam","plotWidth","plotHeight","getRangeParser","xAxisSize","max","MIN_AXIS_SIZE","min","AXIS_SIZE_PX","MAX_AXIS_SIZE","DEFAULT_AXIS_SIZE","yAxisSize","left","bottom","top","right","axisPositionMap","rightAxes","LEGEND_WIDTH_PX","MAX_LEGEND_SIZE","axisTypes","isYAxis","plotSize","makeLayoutAxis","layoutAxis","updateLayoutAxis","rangeParser","rangeStart","rangeEnd","layoutAxisParam","axisSize","title","text","label","side","position","overlaying","positionAxes","sideIndex","anchor","leftAxes","domain","bottomAxes","topAxes","Number","businessDaysInt","day","nonBusinessDaysInt","reopenDays","Set","closed","adjustedDay","add","boundsArray","closedDay","fullHolidays","partialHolidays","holiday","createPartialHoliday","createFullHoliday","adjustDateForTimeZone","date","toString","dateString","closedPeriods","rangeBreaks","startClose","endClose","dvalue","unwrapValue","wrapValue","property","reduce","result","item","group","updateRanges","asDate","DATE_FORMAT","asNumber","substr","parse","tzFormat","estimatedOffset","estimatedDate","offset","gridcolor","linecolor","rangeslider","showline","ticklen","tickcolor","tickfont","zerolinecolor","font","showgrid","zerolinewidth","makeDefaultLayout","autosize","colorway","family","yanchor","pad","DEFAULT_TITLE_PADDING","y","legend","margin","DEFAULT_MARGIN","xaxis","yaxis","datarevision","dehydrateSettings","hydrateSettings","titleFromSettings","xAxis","join","makeFigureSettings","table","settingsAxis","NUMBER","yAxis","chartType","ChartType","XY","dataSources","columnName","l","r","t","b"],"mappings":";;;;;;AAAA,OAAOA,GAAP,MAAgB,gBAAhB;AACA,SAASC,UAAT,QAA2B,sBAA3B;AACA,OAAOC,EAAP,MAAe,uBAAf;OACOC,U;AAEP,IAAMC,GAAG,GAAGJ,GAAG,CAACK,MAAJ,CAAW,YAAX,CAAZ;AAEA,IAAMC,IAAI,GAAGC,MAAM,CAACC,MAAP,CAAcN,EAAE,CAACO,QAAH,CAAYC,SAAZ,CAAsBC,MAAtB,EAAd,CAAb;AAEA,IAAMC,oBAAoB,GAAG,yCAA7B;AAEA,IAAMC,eAAe,GAAG,OAAxB;AAEA,IAAMC,eAAe,GAAG,OAAxB;;AAEA,MAAMC,UAAN,CAAiB;AA0Bf;AACF;AACA;AACA;AACA;AAC2B,SAAlBC,kBAAkB,CAACC,SAAD,EAAYC,cAAZ,EAA4B;AACnD,YAAQD,SAAR;AACE,WAAKf,EAAE,CAACiB,IAAH,CAAQC,eAAR,CAAwBC,OAA7B;AACE;AACA,eAAO,CAACH,cAAD,GAAkB,WAAlB,GAAgC,SAAvC;;AACF,WAAKhB,EAAE,CAACiB,IAAH,CAAQC,eAAR,CAAwBE,IAA7B;AACE;AACA;AACA;AACA,eAAO,SAAP;;AACF,WAAKpB,EAAE,CAACiB,IAAH,CAAQC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,U,iBAkBiB,4B;;gBAlBjBA,U,oBAoBoBR,MAAM,CAACC,MAAP,CAAc;AAAEuV,EAAAA,CAAC,EAAE,EAAL;AAASC,EAAAA,CAAC,EAAE,EAAZ;AAAgBC,EAAAA,CAAC,EAAE,EAAnB;AAAuBC,EAAAA,CAAC,EAAE,EAA1B;AAA8B3B,EAAAA,GAAG,EAAE;AAAnC,CAAd,C;;gBApBpBxT,U,2BAsB2BR,MAAM,CAACC,MAAP,CAAc;AAAEyV,EAAAA,CAAC,EAAE;AAAL,CAAd,C;;gBAtB3BlV,U,0BAwB0B,E;;AA+wChC,eAAeA,UAAf","sourcesContent":["import Log from '@deephaven/log';\nimport { TableUtils } from '@deephaven/iris-grid';\nimport dh from '@deephaven/jsapi-shim';\nimport ChartTheme from './ChartTheme';\n\nconst log = Log.module('ChartUtils');\n\nconst DAYS = Object.freeze(dh.calendar.DayOfWeek.values());\n\nconst BUSINESS_COLUMN_TYPE = 'io.deephaven.db.tables.utils.DBDateTime';\n\nconst MILLIS_PER_HOUR = 3600000;\n\nconst NANOS_PER_MILLI = 1000000;\n\nclass ChartUtils {\n static DEFAULT_AXIS_SIZE = 0.15;\n\n static MIN_AXIS_SIZE = 0.025;\n\n static MAX_AXIS_SIZE = 0.2;\n\n static AXIS_SIZE_PX = 75;\n\n static LEGEND_WIDTH_PX = 50;\n\n static MAX_LEGEND_SIZE = 0.25;\n\n static ORIENTATION = Object.freeze({\n HORIZONTAL: 'h',\n VERTICAL: 'v',\n });\n\n static DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss.SSSSSS';\n\n static DEFAULT_MARGIN = Object.freeze({ l: 60, r: 50, t: 30, b: 60, pad: 0 });\n\n static DEFAULT_TITLE_PADDING = Object.freeze({ t: 8 });\n\n static SUBTITLE_LINE_HEIGHT = 25;\n\n /**\n * Converts the Iris plot style into a plotly chart type\n * @param {String} plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle\n * @param {boolean} isBusinessTime If the plot is using business time for an axis\n */\n static getPlotlyChartType(plotStyle, isBusinessTime) {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.SCATTER:\n // scattergl mode is more performant, but doesn't support the rangebreaks we need for businessTime calendars\n return !isBusinessTime ? 'scattergl' : 'scatter';\n case dh.plot.SeriesPlotStyle.LINE:\n // There is also still some artifacting bugs with scattergl: https://github.com/plotly/plotly.js/issues/3522\n // The artifacting only occurs on line plots, which we can draw with fairly decent performance using SVG paths\n // Once the above plotly issue is fixed, scattergl should be used here (when !isBusinessTime)\n return 'scatter';\n case dh.plot.SeriesPlotStyle.BAR:\n case dh.plot.SeriesPlotStyle.STACKED_BAR:\n return 'bar';\n\n case dh.plot.SeriesPlotStyle.PIE:\n return 'pie';\n\n case dh.plot.SeriesPlotStyle.HISTOGRAM:\n return 'histogram';\n\n case dh.plot.SeriesPlotStyle.OHLC:\n return 'ohlc';\n\n default:\n return null;\n }\n }\n\n /**\n * Converts the Iris plot style into a plotly chart mode\n * @param {String} plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle.*\n */\n static getPlotlyChartMode(plotStyle) {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.SCATTER:\n return 'markers';\n case dh.plot.SeriesPlotStyle.LINE:\n return 'lines';\n default:\n return null;\n }\n }\n\n /**\n * Get the property to set on the series data for plotly\n * @param {dh.plot.SeriesPlotStyle} plotStyle The plot style of the series\n * @param {dh.plot.SourceType} sourceType The source type for the series\n */\n static getPlotlyProperty(plotStyle, sourceType) {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.PIE:\n switch (sourceType) {\n case dh.plot.SourceType.X:\n return 'labels';\n case dh.plot.SourceType.Y:\n return 'values';\n default:\n break;\n }\n break;\n case dh.plot.SeriesPlotStyle.OHLC:\n switch (sourceType) {\n case dh.plot.SourceType.TIME:\n return 'x';\n default:\n break;\n }\n break;\n default:\n break;\n }\n\n switch (sourceType) {\n case dh.plot.SourceType.X:\n return 'x';\n case dh.plot.SourceType.Y:\n return 'y';\n case dh.plot.SourceType.Z:\n return 'z';\n case dh.plot.SourceType.X_LOW:\n return 'xLow';\n case dh.plot.SourceType.X_HIGH:\n return 'xHigh';\n case dh.plot.SourceType.Y_LOW:\n return 'yLow';\n case dh.plot.SourceType.Y_HIGH:\n return 'yHigh';\n case dh.plot.SourceType.TIME:\n return 'time';\n case dh.plot.SourceType.OPEN:\n return 'open';\n case dh.plot.SourceType.HIGH:\n return 'high';\n case dh.plot.SourceType.LOW:\n return 'low';\n case dh.plot.SourceType.CLOSE:\n return 'close';\n case dh.plot.SourceType.SHAPE:\n return 'shape';\n case dh.plot.SourceType.SIZE:\n return 'size';\n case dh.plot.SourceType.LABEL:\n return 'label';\n case dh.plot.SourceType.COLOR:\n return 'color';\n default:\n throw new Error('Unrecognized source type', sourceType);\n }\n }\n\n static getPlotlySeriesOrientation(series) {\n const { sources } = series;\n if (sources.length === 2 && sources[0].axis.type === dh.plot.AxisType.Y) {\n return ChartUtils.ORIENTATION.HORIZONTAL;\n }\n\n return ChartUtils.ORIENTATION.VERTICAL;\n }\n\n /**\n * Generate the plotly error bar data from the passed in data.\n * Iris passes in the values as absolute, plotly needs them as relative.\n * @param {Array[Number]} x The main data array\n * @param {Array[Number]} xLow The absolute low values\n * @param {Array[Number]} xHigh\n *\n * @returns {Object} The error_x object required by plotly, or null if none is required\n */\n static getPlotlyErrorBars(x, xLow, xHigh) {\n const array = xHigh.map((value, i) => value - x[i]);\n const arrayminus = xLow.map((value, i) => x[i] - value);\n return {\n type: 'data',\n symmetric: false,\n array,\n arrayminus,\n };\n }\n\n static getPlotlyDateFormat(formatter, columnType, formatPattern) {\n const tickformat =\n formatPattern == null\n ? null\n : formatPattern\n .replace('%', '%%')\n .replace(/S{9}/g, '%9f')\n .replace(/S{8}/g, '%8f')\n .replace(/S{7}/g, '%7f')\n .replace(/S{6}/g, '%6f')\n .replace(/S{5}/g, '%5f')\n .replace(/S{4}/g, '%4f')\n .replace(/S{3}/g, '%3f')\n .replace(/S{2}/g, '%2f')\n .replace(/S{1}/g, '%1f')\n .replace(/y{4}/g, '%Y')\n .replace(/y{2}/g, '%y')\n .replace(/M{4}/g, '%B')\n .replace(/M{3}/g, '%b')\n .replace(/M{2}/g, '%m')\n .replace(/M{1}/g, '%-m')\n .replace(/E{4,}/g, '%A')\n .replace(/E{1,}/g, '%a')\n .replace(/d{2}/g, '%d')\n .replace(/([^%]|^)d{1}/g, '$1%-d')\n .replace(/H{2}/g, '%H')\n .replace(/h{2}/g, '%I')\n .replace(/h{1}/g, '%-I')\n .replace(/m{2}/g, '%M')\n .replace(/s{2}/g, '%S')\n .replace(\"'T'\", 'T')\n .replace(' z', ''); // timezone added as suffix if necessary\n\n let ticksuffix = null;\n const dataFormatter = formatter.getColumnTypeFormatter(columnType);\n if (dataFormatter.dhTimeZone != null && dataFormatter.showTimeZone) {\n ticksuffix = dh.i18n.DateTimeFormat.format(\n ' z',\n new Date(),\n dataFormatter.dhTimeZone\n );\n }\n\n return { tickformat, ticksuffix, automargin: true };\n }\n\n static convertNumberPrefix(prefix) {\n return prefix.replace(/\\u00A4\\u00A4/g, 'USD').replace(/\\u00A4/g, '$');\n }\n\n static getPlotlyNumberFormat(formatter, columnType, formatPattern) {\n if (!formatPattern) {\n return null;\n }\n\n // We translate java formatting: https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html\n // Into d3 number formatting: https://github.com/d3/d3-format\n // We can't translate number formatting exactly, but should be able to translate the most common cases\n // First split it into the subpatterns; currently only handling the positive subpattern, ignoring the rest\n const subpatterns = formatPattern.split(';');\n const [\n ,\n prefix,\n placeholderDigits,\n zeroDigits,\n ,\n decimalDigits,\n optionalDecimalDigits,\n numberType,\n percentSign,\n suffix,\n ] = subpatterns[0].match(\n /^([^#,0.]*)([#,]*)([0,]*)(\\.?)(0*)(#*)(E?0*)(%?)(.*)/\n );\n\n const paddingLength = zeroDigits.replace(',', '').length;\n const isCommaSeparated =\n placeholderDigits.indexOf(',') >= 0 || zeroDigits.indexOf(',') >= 0;\n const comma = isCommaSeparated ? ',' : '';\n const plotlyNumberType = numberType ? 'e' : 'f';\n const type = percentSign || plotlyNumberType;\n const decimalLength = decimalDigits.length + optionalDecimalDigits.length;\n // IDS-4565 Plotly uses an older version of d3 which doesn't support the trim option or negative brackets\n // If plotly updates it's d3 version, this should be re-enabled\n // const trimOption = optionalDecimalDigits.length > 0 ? '~' : '';\n const trimOption = '';\n\n const tickformat = `0${paddingLength}${comma}.${decimalLength}${trimOption}${type}`;\n const tickprefix = ChartUtils.convertNumberPrefix(prefix);\n // prefix and suffix are processed the same\n const ticksuffix = ChartUtils.convertNumberPrefix(suffix);\n\n return { tickformat, tickprefix, ticksuffix, automargin: true };\n }\n\n /**\n * Gets the plotly axis formatting information from the source passed in\n * @param {dh.plot.Source} source The Source to get the formatter information from\n * @param {Formatter} formatter The current formatter for formatting data\n */\n static getPlotlyAxisFormat(source, formatter = null) {\n const { axis, columnType } = source;\n const { formatPattern } = axis;\n\n let axisFormat = null;\n if (TableUtils.isDateType(columnType)) {\n axisFormat = ChartUtils.getPlotlyDateFormat(\n formatter,\n columnType,\n formatPattern\n );\n axisFormat = ChartUtils.addTickSpacing(axisFormat, axis, true);\n } else if (TableUtils.isNumberType(columnType)) {\n axisFormat = ChartUtils.getPlotlyNumberFormat(\n formatter,\n columnType,\n formatPattern\n );\n axisFormat = ChartUtils.addTickSpacing(axisFormat, axis, false);\n }\n\n if (axis.formatType === dh.plot.AxisFormatType.CATEGORY) {\n if (axisFormat) {\n axisFormat.type = 'category';\n } else {\n axisFormat = { type: 'category', tickformat: null, ticksuffix: null };\n }\n }\n\n return axisFormat;\n }\n\n /**\n * Adds tick spacing for an axis that has gapBetweenMajorTicks defined.\n *\n * @param {object} axisFormat the current axis format, may be null\n * @param {object} axis the current axis\n * @param {boolean} isDateType indicates if the columns is a date type\n */\n static addTickSpacing(axisFormat, axis, isDateType) {\n const { gapBetweenMajorTicks } = axis;\n if (gapBetweenMajorTicks > 0) {\n const updatedFormat = axisFormat || {};\n let tickSpacing = gapBetweenMajorTicks;\n if (isDateType) {\n // Need to convert from nanoseconds to milliseconds\n tickSpacing = gapBetweenMajorTicks / NANOS_PER_MILLI;\n }\n if (axis.log) {\n tickSpacing = Math.log(tickSpacing);\n }\n // Note that tickmode defaults to 'auto'\n updatedFormat.tickmode = 'linear';\n updatedFormat.dtick = tickSpacing;\n return updatedFormat;\n }\n\n return axisFormat;\n }\n\n /**\n * Retrieve the data source for a given axis in a chart\n * @param {dh.plot.Chart} chart The chart to get the source for\n * @param {dh.plot.Axis} axis The axis to find the source for\n * @returns {dh.plot.Source} The first source matching this axis\n */\n static getSourceForAxis(chart, axis) {\n for (let i = 0; i < chart.series.length; i += 1) {\n const series = chart.series[i];\n for (let j = 0; j < series.sources.length; j += 1) {\n const source = series.sources[j];\n if (source.axis === axis) {\n return source;\n }\n }\n }\n\n return null;\n }\n\n /**\n * Get visibility setting for the series object\n * @param {string} name The series name to get the visibility for\n * @param {object} settings Chart settings\n * @returns {boolean|string} True for visible series and 'legendonly' for hidden\n */\n static getSeriesVisibility(name, settings) {\n if (settings?.hiddenSeries?.includes(name)) {\n return 'legendonly';\n }\n return true;\n }\n\n /**\n * Get hidden labels array from chart settings\n * @param {object} settings Chart settings\n * @returns {string[]} Array of hidden series names\n */\n static getHiddenLabels(settings) {\n if (settings?.hiddenSeries) {\n return [...settings.hiddenSeries];\n }\n return [];\n }\n\n /**\n * Create a default series data object. Apply styling to the object afterward.\n * @returns {Object} A simple series data object with no styling\n */\n static makeSeriesData(\n type,\n mode,\n name,\n orientation = ChartUtils.ORIENTATION.VERTICAL\n ) {\n return { type, mode, name, orientation };\n }\n\n /**\n * Create a data series (trace) for use with plotly\n * @param {dh.plot.Series} series The series to create the series data with\n * @param {Map<dh.plot.AxisType, dh.plot.Axis[]>} axisTypeMap The map of axes grouped by type\n * @param {boolean|string} seriesVisibility Visibility setting for the series\n * @returns {Object} The series data (trace) object for use with plotly.\n */\n static makeSeriesDataFromSeries(series, axisTypeMap, seriesVisibility) {\n const { name, plotStyle, lineColor, shapeColor, sources } = series;\n\n const isBusinessTime = sources.some(source => source.axis.businessCalendar);\n const type = ChartUtils.getChartType(plotStyle, isBusinessTime);\n const mode = ChartUtils.getPlotlyChartMode(plotStyle);\n const orientation = ChartUtils.getPlotlySeriesOrientation(series);\n\n const seriesData = ChartUtils.makeSeriesData(type, mode, name, orientation);\n\n ChartUtils.addSourcesToSeriesData(\n seriesData,\n plotStyle,\n sources,\n axisTypeMap\n );\n\n ChartUtils.addStylingToSeriesData(\n seriesData,\n plotStyle,\n lineColor,\n shapeColor,\n seriesVisibility\n );\n\n return seriesData;\n }\n\n static addSourcesToSeriesData(\n seriesDataParam,\n plotStyle,\n sources,\n axisTypeMap\n ) {\n const seriesData = seriesDataParam;\n for (let k = 0; k < sources.length; k += 1) {\n const source = sources[k];\n const { axis, type: sourceType } = source;\n\n const dataAttributeName = ChartUtils.getPlotlyProperty(\n plotStyle,\n sourceType\n );\n seriesData[dataAttributeName] = [];\n\n const axisProperty = ChartUtils.getAxisPropertyName(axis.type);\n const axes = axisTypeMap.get(axis.type);\n const axisIndex = axes.indexOf(axis);\n if (axisProperty != null) {\n const axisIndexString = axisIndex > 0 ? `${axisIndex + 1}` : '';\n seriesData[`${axisProperty}axis`] = `${axisProperty}${axisIndexString}`;\n }\n }\n }\n\n static addStylingToSeriesData(\n seriesDataParam,\n plotStyle,\n lineColor = null,\n shapeColor = null,\n seriesVisibility = null\n ) {\n const seriesData = seriesDataParam;\n // Add some empty objects so we can fill them in later with details without checking for existence\n seriesData.marker = { line: {} }; // border line width on markers\n seriesData.line = {\n width: 1, // default line width for lines, should eventually be able to override\n };\n\n if (plotStyle === dh.plot.SeriesPlotStyle.AREA) {\n seriesData.fill = 'tozeroy';\n } else if (plotStyle === dh.plot.SeriesPlotStyle.STACKED_AREA) {\n seriesData.stackgroup = 'stack';\n } else if (plotStyle === dh.plot.SeriesPlotStyle.STEP) {\n seriesData.line.shape = 'hv'; // plot.ly horizontal then vertical step styling\n } else if (plotStyle === dh.plot.SeriesPlotStyle.HISTOGRAM) {\n // The default histfunc in plotly is 'count', but the data passed up from the API provides explicit x/y values and bins\n // Since it's converted to bar, just set the widths of each bar\n seriesData.width = [];\n Object.assign(seriesData.marker.line, {\n color: ChartTheme.paper_bgcolor,\n width: 1,\n });\n } else if (plotStyle === dh.plot.SeriesPlotStyle.OHLC) {\n seriesData.increasing = {\n line: { color: ChartTheme.ohlc_increasing },\n };\n seriesData.decreasing = {\n line: { color: ChartTheme.ohlc_decreasing },\n };\n } else if (plotStyle === dh.plot.SeriesPlotStyle.PIE) {\n seriesData.textinfo = 'label+percent';\n seriesData.outsidetextfont = { color: ChartTheme.title_color };\n }\n\n if (lineColor != null) {\n if (plotStyle === dh.plot.SeriesPlotStyle.BAR) {\n seriesData.marker.color = lineColor;\n } else {\n seriesData.line.color = lineColor;\n }\n }\n\n if (shapeColor != null) {\n seriesData.marker.color = shapeColor;\n }\n\n // Skipping pie charts\n // Pie slice visibility is configured in chart layout instead of series data\n if (seriesVisibility != null && plotStyle !== dh.plot.SeriesPlotStyle.PIE) {\n seriesData.visible = seriesVisibility;\n }\n }\n\n /**\n * Retrieve the axis formats from the provided figure.\n * Currently defaults to just the x/y axes.\n * @param {dh.plot.Figure} figure The figure to get the axis formats for\n * @param {Formatter} formatter The formatter to use when getting the axis format\n * @returns {Map<string, object>} A map of axis layout property names to axis formats\n */\n static getAxisFormats(figure, formatter) {\n const axisFormats = new Map();\n const nullFormat = { tickformat: null, ticksuffix: null };\n\n const { charts } = figure;\n\n for (let i = 0; i < charts.length; i += 1) {\n const chart = charts[i];\n const axisTypeMap = ChartUtils.groupArray(chart.axes, 'type');\n\n for (let j = 0; j < chart.series.length; j += 1) {\n const series = chart.series[j];\n const { sources } = series;\n\n for (let k = 0; k < sources.length; k += 1) {\n const source = sources[k];\n const { axis } = source;\n const { type: axisType } = axis;\n const typeAxes = axisTypeMap.get(axisType);\n const axisIndex = typeAxes.indexOf(axis);\n const axisProperty = ChartUtils.getAxisPropertyName(axisType);\n const axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n\n if (axisFormats.has(axisLayoutProperty)) {\n log.debug(`${axisLayoutProperty} already added.`);\n } else {\n log.debug(`Adding ${axisLayoutProperty} to axisFormats.`);\n const axisFormat = ChartUtils.getPlotlyAxisFormat(\n source,\n formatter\n );\n if (axisFormat === null) {\n axisFormats.set(axisLayoutProperty, nullFormat);\n } else {\n axisFormats.set(axisLayoutProperty, axisFormat);\n\n const { businessCalendar } = axis;\n if (businessCalendar) {\n axisFormat.rangebreaks = [];\n const {\n businessPeriods,\n businessDays,\n holidays,\n timeZone: calendarTimeZone,\n } = businessCalendar;\n const formatterTimeZone = formatter?.getColumnTypeFormatter(\n BUSINESS_COLUMN_TYPE\n )?.dhTimeZone;\n const timeZoneDiff = formatterTimeZone\n ? (calendarTimeZone.standardOffset -\n formatterTimeZone.standardOffset) /\n 60\n : 0;\n if (holidays.length > 0) {\n axisFormat.rangebreaks.push(\n ...ChartUtils.createRangeBreakValuesFromHolidays(\n holidays,\n calendarTimeZone,\n formatterTimeZone\n )\n );\n }\n businessPeriods.forEach(period =>\n axisFormat.rangebreaks.push({\n pattern: 'hour',\n bounds: [\n ChartUtils.periodToDecimal(period.close) + timeZoneDiff,\n ChartUtils.periodToDecimal(period.open) + timeZoneDiff,\n ],\n })\n );\n // If there are seven business days, then there is no weekend\n if (businessDays.length < DAYS.length) {\n ChartUtils.createBoundsFromDays(businessDays).forEach(\n weekendBounds =>\n axisFormat.rangebreaks.push({\n pattern: 'day of week',\n bounds: weekendBounds,\n })\n );\n }\n }\n\n if (axisFormats.size === chart.axes.length) {\n return axisFormats;\n }\n }\n }\n }\n }\n }\n\n return axisFormats;\n }\n\n static getChartType(plotStyle, isBusinessTime) {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.HISTOGRAM:\n // When reading data from the `Figure`, it already provides bins and values, so rather than using\n // plot.ly to calculate the bins and sum values, just convert it to a bar chart\n return 'bar';\n default:\n return ChartUtils.getPlotlyChartType(plotStyle, isBusinessTime);\n }\n }\n\n /**\n * Return the plotly axis property name\n * @param {dh.plot.AxisType} axisType The axis type to get the property name for\n */\n static getAxisPropertyName(axisType) {\n switch (axisType) {\n case dh.plot.AxisType.X:\n return 'x';\n case dh.plot.AxisType.Y:\n return 'y';\n default:\n return null;\n }\n }\n\n /**\n * Returns the plotly \"side\" value for the provided axis position\n * @param {dh.plot.AxisPosition} axisPosition The Iris AxisPosition of the axis\n */\n static getAxisSide(axisPosition) {\n switch (axisPosition) {\n case dh.plot.AxisPosition.BOTTOM:\n return 'bottom';\n case dh.plot.AxisPosition.TOP:\n return 'top';\n case dh.plot.AxisPosition.LEFT:\n return 'left';\n case dh.plot.AxisPosition.RIGHT:\n return 'right';\n default:\n return null;\n }\n }\n\n /**\n * Retrieve the chart that contains the passed in series from the figure\n * @param {dh.plot.Figure} figure The figure to retrieve the chart from\n * @param {dh.plot.Series} series The series to get the chart for\n */\n static getChartForSeries(figure, series) {\n const { charts } = figure;\n\n for (let i = 0; i < charts.length; i += 1) {\n const chart = charts[i];\n for (let j = 0; j < chart.series.length; j += 1) {\n if (series === chart.series[j]) {\n return chart;\n }\n }\n }\n\n return null;\n }\n\n /**\n * Get an object mapping axis to their ranges\n * @param {object} layout The plotly layout object to get the ranges from\n * @returns {object} An object mapping the axis name to it's range\n */\n static getLayoutRanges(layout) {\n const ranges = {};\n const keys = Object.keys(layout).filter(key => key.indexOf('axis') >= 0);\n for (let i = 0; i < keys.length; i += 1) {\n const key = keys[i];\n if (layout[key] && layout[key].range && !layout[key].autorange) {\n // Only want to add the range if it's not autoranged\n ranges[key] = [...layout[key].range];\n }\n }\n\n return ranges;\n }\n\n /**\n * Updates the axes positions and sizes in the layout object provided.\n * If the axis did not exist in the layout previously, it is created and added.\n * Any axis that no longer exists in axes is removed.\n * With Downsampling enabled, will also update the range on the axis itself as appropriate\n * @param {object} layoutParam The layout object to update\n * @param {dh.plot.Axis[]} axes The axes to update the layout with\n * @param {number} plotWidth The width of the plot to calculate the axis sizes for\n * @param {number} plotHeight The height of the plot to calculate the axis sizes for\n * @param {func} getRangeParser A function to retrieve the range parser for a given axis\n */\n static updateLayoutAxes(\n layoutParam,\n axes,\n plotWidth = 0,\n plotHeight = 0,\n getRangeParser = null\n ) {\n const xAxisSize =\n plotWidth > 0\n ? Math.max(\n ChartUtils.MIN_AXIS_SIZE,\n Math.min(\n ChartUtils.AXIS_SIZE_PX / plotHeight,\n ChartUtils.MAX_AXIS_SIZE\n )\n )\n : ChartUtils.DEFAULT_AXIS_SIZE;\n const yAxisSize =\n plotHeight > 0\n ? Math.max(\n ChartUtils.MIN_AXIS_SIZE,\n Math.min(\n ChartUtils.AXIS_SIZE_PX / plotWidth,\n ChartUtils.MAX_AXIS_SIZE\n )\n )\n : ChartUtils.DEFAULT_AXIS_SIZE;\n\n // Adjust the bounds based on where the legend is\n // For now, always assume the legend is shown on the right\n const bounds = {\n left: 0,\n bottom: 0,\n top: 1,\n right: 1,\n };\n const axisPositionMap = ChartUtils.groupArray(axes, 'position');\n const rightAxes = axisPositionMap.get(dh.plot.AxisPosition.RIGHT) || [];\n if (rightAxes.length > 0) {\n if (plotWidth > 0) {\n bounds.right =\n 1 -\n Math.max(\n 0,\n Math.min(\n ChartUtils.LEGEND_WIDTH_PX / plotWidth,\n ChartUtils.MAX_LEGEND_SIZE\n )\n );\n } else {\n bounds.right = 1 - ChartUtils.DEFAULT_AXIS_SIZE;\n }\n }\n\n const layout = layoutParam;\n const axisTypeMap = ChartUtils.groupArray(axes, 'type');\n const axisTypes = [...axisTypeMap.keys()];\n for (let j = 0; j < axisTypes.length; j += 1) {\n const axisType = axisTypes[j];\n const axisProperty = ChartUtils.getAxisPropertyName(axisType);\n if (axisProperty != null) {\n const typeAxes = axisTypeMap.get(axisType);\n const isYAxis = axisType === dh.plot.AxisType.Y;\n const plotSize = isYAxis ? plotHeight : plotWidth;\n let axisIndex = 0;\n for (axisIndex = 0; axisIndex < typeAxes.length; axisIndex += 1) {\n const axis = typeAxes[axisIndex];\n const axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n if (layout[axisLayoutProperty] == null) {\n layout[axisLayoutProperty] = ChartUtils.makeLayoutAxis(axisType);\n }\n\n const layoutAxis = layout[axisLayoutProperty];\n ChartUtils.updateLayoutAxis(\n layoutAxis,\n axis,\n axisIndex,\n axisPositionMap,\n xAxisSize,\n yAxisSize,\n bounds\n );\n const { range, autorange } = layoutAxis;\n if (getRangeParser && range && !autorange) {\n const rangeParser = getRangeParser(axis);\n const [rangeStart, rangeEnd] = rangeParser(range);\n\n log.debug(\n 'Setting downsample range',\n plotSize,\n rangeStart,\n rangeEnd\n );\n\n axis.range(plotSize, rangeStart, rangeEnd);\n } else {\n axis.range(plotSize);\n }\n }\n\n let axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n while (layout[axisLayoutProperty] != null) {\n delete layout[axisLayoutProperty];\n\n axisIndex += 1;\n axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n }\n }\n }\n }\n\n static getAxisLayoutProperty(axisProperty, axisIndex) {\n const axisIndexString = axisIndex > 0 ? `${axisIndex + 1}` : '';\n return `${axisProperty}axis${axisIndexString}`;\n }\n\n /**\n * Updates the layout axis object in place\n * @param {object} layoutAxisParam The plotly layout axis param\n * @param {dh.plot.Axis} axis The Iris Axis to update the plotly layout with\n * @param {number} axisIndex The type index for this axis\n * @param {Map<dh.plot.AxisPosition, dh.plot.Axis>} axisPositionMap All the axes mapped by position\n * @param {number} axisSize The size of each axis in percent\n * @param {object} bounds The bounds of the axes domains\n */\n static updateLayoutAxis(\n layoutAxisParam,\n axis,\n axisIndex,\n axisPositionMap,\n xAxisSize,\n yAxisSize,\n bounds\n ) {\n const isYAxis = axis.type === dh.plot.AxisType.Y;\n const axisSize = isYAxis ? yAxisSize : xAxisSize;\n const layoutAxis = layoutAxisParam;\n layoutAxis.title.text = axis.label;\n if (axis.log) {\n layoutAxis.type = 'log';\n }\n layoutAxis.side = ChartUtils.getAxisSide(axis.position);\n if (axisIndex > 0) {\n layoutAxis.overlaying = ChartUtils.getAxisPropertyName(axis.type);\n\n const positionAxes = axisPositionMap.get(axis.position);\n const sideIndex = positionAxes.indexOf(axis);\n if (sideIndex > 0) {\n layoutAxis.anchor = 'free';\n\n if (axis.position === dh.plot.AxisPosition.RIGHT) {\n layoutAxis.position =\n bounds.right + (sideIndex - positionAxes.length + 1) * axisSize;\n } else if (axis.position === dh.plot.AxisPosition.TOP) {\n layoutAxis.position =\n bounds.top + (sideIndex - positionAxes.length + 1) * axisSize;\n } else if (axis.position === dh.plot.AxisPosition.BOTTOM) {\n layoutAxis.position =\n bounds.bottom + (positionAxes.length - sideIndex + 1) * axisSize;\n } else if (axis.position === dh.plot.AxisPosition.LEFT) {\n layoutAxis.position =\n bounds.left + (positionAxes.length - sideIndex + 1) * axisSize;\n }\n }\n } else if (axis.type === dh.plot.AxisType.X) {\n const leftAxes = axisPositionMap.get(dh.plot.AxisPosition.LEFT) || [];\n const rightAxes = axisPositionMap.get(dh.plot.AxisPosition.RIGHT) || [];\n const left = Math.max(\n bounds.left,\n bounds.left + (leftAxes.length - 1) * yAxisSize\n );\n const right = Math.min(\n bounds.right - (rightAxes.length - 1) * yAxisSize,\n bounds.right\n );\n layoutAxis.domain = [left, right];\n } else if (axis.type === dh.plot.AxisType.Y) {\n const bottomAxes = axisPositionMap.get(dh.plot.AxisPosition.BOTTOM) || [];\n const topAxes = axisPositionMap.get(dh.plot.AxisPosition.TOP) || [];\n const bottom = Math.max(\n bounds.bottom,\n bounds.bottom + (bottomAxes.length - 1) * xAxisSize\n );\n const top = Math.min(\n bounds.top - (topAxes.length - 1) * xAxisSize,\n bounds.top\n );\n layoutAxis.domain = [bottom, top];\n }\n }\n\n /**\n * Converts an open or close period to a declimal. e.g '09:30\" to 9.5\n *\n * @param {String} period the open or close value of the period\n */\n static periodToDecimal(period) {\n const values = period.split(':');\n return Number(values[0]) + Number(values[1] / 60);\n }\n\n /**\n * Creates range break bounds for plotly from business days.\n * For example a standard business week of ['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY']\n * will result in [[6,1]] meaning close on Saturday and open on Monday.\n * If you remove Wednesday from the array, then you get two closures [[6, 1], [3, 4]]\n *\n * @param {Array} businessDays the days to display on the x-axis\n */\n static createBoundsFromDays(businessDays) {\n const businessDaysInt = businessDays.map(day => DAYS.indexOf(day));\n const nonBusinessDaysInt = DAYS.filter(\n day => !businessDays.includes(day)\n ).map(day => DAYS.indexOf(day));\n // These are the days when business reopens (e.g. Monday after a weekend)\n const reopenDays = new Set();\n nonBusinessDaysInt.forEach(closed => {\n for (let i = closed + 1; i < closed + DAYS.length; i += 1) {\n const adjustedDay = i % DAYS.length;\n if (businessDaysInt.includes(adjustedDay)) {\n reopenDays.add(adjustedDay);\n break;\n }\n }\n });\n const boundsArray = [];\n // For each reopen day, find the furthest previous closed day\n reopenDays.forEach(open => {\n for (let i = open - 1; i > open - DAYS.length; i -= 1) {\n const adjustedDay = i < 0 ? i + DAYS.length : i;\n if (businessDaysInt.includes(adjustedDay)) {\n const closedDay = (adjustedDay + 1) % 7;\n boundsArray.push([closedDay, open]);\n break;\n }\n }\n });\n return boundsArray;\n }\n\n /**\n * Creates an array of range breaks for all holidays.\n *\n * @param {Array} holidays an array of holidays\n * @param {TimeZone} calendarTimeZone the time zone for the business calendar\n * @param {TimeZone} formatterTimeZone the time zone for the formatter\n */\n static createRangeBreakValuesFromHolidays(\n holidays,\n calendarTimeZone,\n formatterTimeZone\n ) {\n const fullHolidays = [];\n const partialHolidays = [];\n holidays.forEach(holiday => {\n if (holiday.businessPeriods.length > 0) {\n partialHolidays.push(\n ...ChartUtils.createPartialHoliday(\n holiday,\n calendarTimeZone,\n formatterTimeZone\n )\n );\n } else {\n fullHolidays.push(\n ChartUtils.createFullHoliday(\n holiday,\n calendarTimeZone,\n formatterTimeZone\n )\n );\n }\n });\n return [{ values: fullHolidays }, ...partialHolidays];\n }\n\n /**\n * Creates the range break value for a full holiday. A full holiday is day that has no business periods.\n *\n * @param {Holiday} holiday the full holiday\n * @param {TimeZone} calendarTimeZone the time zone for the business calendar\n * @param {TimeZone} formatterTimeZone the time zone for the formatter\n */\n static createFullHoliday(holiday, calendarTimeZone, formatterTimeZone) {\n return ChartUtils.adjustDateForTimeZone(\n `${holiday.date.toString()} 00:00:00.000000`,\n calendarTimeZone,\n formatterTimeZone\n );\n }\n\n /**\n * Creates the range break for a partial holiday. A partial holiday is holiday with business periods\n * that are different than the default business periods.\n *\n * @param {Holiday} holiday the partial holiday\n * @param {TimeZone} calendarTimeZone the time zone for the business calendar\n * @param {TimeZone} formatterTimeZone the time zone for the formatter\n */\n static createPartialHoliday(holiday, calendarTimeZone, formatterTimeZone) {\n // If a holiday has business periods {open1, close1} and {open2, close2}\n // This will generate range breaks for:\n // closed from 00:00 to open1\n // closed from close1 to open2\n // closed from close2 to 23:59:59.999999\n const dateString = holiday.date.toString();\n const closedPeriods = ['00:00'];\n holiday.businessPeriods.forEach(period => {\n closedPeriods.push(period.open);\n closedPeriods.push(period.close);\n });\n // To go up to 23:59:59.999999, we calculate the dvalue using 24 - close\n closedPeriods.push('24:00');\n\n const rangeBreaks = [];\n for (let i = 0; i < closedPeriods.length; i += 2) {\n const startClose = closedPeriods[i];\n const endClose = closedPeriods[i + 1];\n // Skip over any periods where start and close are the same (zero hours)\n if (startClose !== endClose) {\n const values = [\n ChartUtils.adjustDateForTimeZone(\n `${dateString} ${startClose}:00.000000`,\n calendarTimeZone,\n formatterTimeZone\n ),\n ];\n const dvalue =\n MILLIS_PER_HOUR *\n (ChartUtils.periodToDecimal(endClose) -\n ChartUtils.periodToDecimal(startClose));\n rangeBreaks.push({ values, dvalue });\n }\n }\n return rangeBreaks;\n }\n\n /**\n * Adjusts a date string from the calendar time zone to the formatter time zone.\n *\n * @param {string} dateString the date string\n * @param {TimeZone} calendarTimeZone the time zone for the business calendar\n * @param {TimeZone} formatterTimeZone the time zone for the formatter\n */\n static adjustDateForTimeZone(\n dateString,\n calendarTimeZone,\n formatterTimeZone\n ) {\n if (\n formatterTimeZone &&\n formatterTimeZone.standardOffset !== calendarTimeZone.standardOffset\n ) {\n return ChartUtils.unwrapValue(\n ChartUtils.wrapValue(\n dateString,\n BUSINESS_COLUMN_TYPE,\n calendarTimeZone\n ),\n formatterTimeZone\n );\n }\n return dateString;\n }\n\n /**\n * Groups an array and returns a map\n * @param {object[]} array The object to group\n * @param {string} property The property name to group by\n * @returns {Map<object, object>} A map containing the items grouped by their values for the property\n */\n static groupArray(array, property) {\n return array.reduce((result, item) => {\n const key = item[property];\n const group = result.get(key) || [];\n group.push(item);\n result.set(key, group);\n return result;\n }, new Map());\n }\n\n /**\n * Update\n */\n static updateRanges() {}\n\n /**\n * Unwraps a value provided from API to a value plotly can understand\n * Eg. Unwraps DateWrapper, LongWrapper objects.\n */\n static unwrapValue(value, timeZone = null) {\n if (value != null) {\n if (value.asDate) {\n return dh.i18n.DateTimeFormat.format(\n ChartUtils.DATE_FORMAT,\n value,\n timeZone\n );\n }\n\n if (value.asNumber) {\n return value.asNumber();\n }\n }\n\n return value;\n }\n\n /**\n *\n * @param {any} value The value to wrap up\n * @param {string} columnType The type of column this value is from\n * @param {dh.i18n.TimeZone} timeZone The time zone if applicable\n */\n static wrapValue(value, columnType, timeZone = null) {\n if (TableUtils.isDateType(columnType) && typeof value === 'string') {\n // Need to limit the format to the actual length of the string range set in plotly\n // Otherwise parse will fail\n const text = value;\n const format = ChartUtils.DATE_FORMAT.substr(0, value.length);\n const date = dh.i18n.DateTimeFormat.parse(format, text);\n if (!timeZone) {\n return date;\n }\n\n // IDS-5994 Due to date parsing, time zone, and daylight savings shenanigans, we need\n // to pass the actual offset with the time to have it parse correctly.\n // However, the offset can change based on the date because of Daylight Savings\n // So we end up parsing the date multiple times. And curse daylight savings.\n const tzFormat = `${format} Z`;\n const estimatedOffset = dh.i18n.DateTimeFormat.format(\n 'Z',\n date,\n timeZone\n );\n const estimatedDate = dh.i18n.DateTimeFormat.parse(\n tzFormat,\n `${text} ${estimatedOffset}`\n );\n const offset = dh.i18n.DateTimeFormat.format(\n 'Z',\n estimatedDate,\n timeZone\n );\n return dh.i18n.DateTimeFormat.parse(tzFormat, `${text} ${offset}`);\n }\n\n return value;\n }\n\n static makeLayoutAxis(type) {\n const axis = {\n automargin: true,\n gridcolor: ChartTheme.gridcolor,\n linecolor: ChartTheme.linecolor,\n rangeslider: { visible: false },\n showline: true,\n ticklen: 5, // act as padding, can't find a tick padding\n tickcolor: ChartTheme.paper_bgcolor, // hide ticks as padding\n tickfont: {\n color: ChartTheme.zerolinecolor,\n },\n title: {\n font: {\n color: ChartTheme.title_color,\n },\n },\n };\n\n if (type === dh.plot.AxisType.X) {\n Object.assign(axis, {\n showgrid: true,\n });\n } else if (type === dh.plot.AxisType.Y) {\n Object.assign(axis, {\n zerolinecolor: ChartTheme.zerolinecolor,\n zerolinewidth: 2,\n });\n }\n\n return axis;\n }\n\n static makeDefaultLayout() {\n const layout = {\n ...ChartTheme,\n autosize: true,\n colorway: ChartTheme.colorway ? ChartTheme.colorway.split(' ') : [],\n font: {\n family: \"'Fira Sans', sans-serif\",\n },\n title: {\n font: {\n color: ChartTheme.title_color,\n },\n yanchor: 'top',\n pad: { ...ChartUtils.DEFAULT_TITLE_PADDING },\n y: 1,\n text: 'Untitled',\n },\n legend: {\n font: {\n color: ChartTheme.title_color,\n },\n },\n margin: { ...ChartUtils.DEFAULT_MARGIN },\n xaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.X),\n yaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.Y),\n };\n layout.datarevision = 0;\n return layout;\n }\n\n /**\n * Dehydrate settings so they can be JSONified\n * @param {object} settings Chart builder settings\n */\n static dehydrateSettings(settings) {\n return {\n ...settings,\n type: `${settings.type}`,\n };\n }\n\n /**\n * Hydrate settings from a JSONable object\n * @param {object} settings Dehydrated settings\n */\n static hydrateSettings(settings) {\n return {\n ...settings,\n type: dh.plot.SeriesPlotStyle[settings.type],\n };\n }\n\n static titleFromSettings(settings) {\n const {\n series,\n xAxis,\n title = `${series.join(', ')} by ${xAxis}`,\n } = settings;\n\n return title;\n }\n\n /**\n * Creates the Figure settings from the Chart Builder settings\n * This should be deprecated at some point, and have Chart Builder create the figure settings directly.\n * This logic will still need to exist to translate existing charts, but could be part of a migration script\n * to translate the data.\n * Change when we decide to add more functionality to the Chart Builder.\n * @param {object} settings The chart builder settings\n * @param {string} settings.title The title for this figure\n * @param {string} settings.xAxis The name of the column to use for the x-axis\n * @param {string[]} settings.series The name of the columns to use for the series of this figure\n * @param {dh.plot.SeriesPlotStyle} settings.type The plot style for this figure\n */\n static makeFigureSettings(settings, table) {\n const { series, xAxis: settingsAxis, type } = settings;\n const title = ChartUtils.titleFromSettings(settings);\n const xAxis = {\n formatType: `${dh.plot.AxisFormatType.NUMBER}`,\n type: `${dh.plot.AxisType.X}`,\n position: `${dh.plot.AxisPosition.BOTTOM}`,\n };\n const yAxis = {\n formatType: `${dh.plot.AxisFormatType.NUMBER}`,\n type: `${dh.plot.AxisType.Y}`,\n position: `${dh.plot.AxisPosition.LEFT}`,\n };\n\n return {\n charts: [\n {\n chartType: `${dh.plot.ChartType.XY}`,\n axes: [xAxis, yAxis],\n series: series.map(name => ({\n plotStyle: `${type}`,\n name,\n dataSources: [\n {\n type: `${dh.plot.SourceType.X}`,\n columnName: settingsAxis,\n axis: xAxis,\n table,\n },\n {\n type: `${dh.plot.SourceType.Y}`,\n columnName: name,\n axis: yAxis,\n table,\n },\n ],\n })),\n },\n ],\n title,\n };\n }\n}\n\nexport default ChartUtils;\n"],"file":"ChartUtils.js"}