WaterfallSeries.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /* *
  2. *
  3. * (c) 2010-2021 Torstein Honsi
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. 'use strict';
  11. var __extends = (this && this.__extends) || (function () {
  12. var extendStatics = function (d, b) {
  13. extendStatics = Object.setPrototypeOf ||
  14. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  16. return extendStatics(d, b);
  17. };
  18. return function (d, b) {
  19. extendStatics(d, b);
  20. function __() { this.constructor = d; }
  21. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22. };
  23. })();
  24. import Chart from '../../Core/Chart/Chart.js';
  25. import H from '../../Core/Globals.js';
  26. import palette from '../../Core/Color/Palette.js';
  27. import SeriesRegistry from '../../Core/Series/SeriesRegistry.js';
  28. var _a = SeriesRegistry.seriesTypes, ColumnSeries = _a.column, LineSeries = _a.line;
  29. import U from '../../Core/Utilities.js';
  30. var arrayMax = U.arrayMax, arrayMin = U.arrayMin, correctFloat = U.correctFloat, extend = U.extend, merge = U.merge, objectEach = U.objectEach, pick = U.pick;
  31. import WaterfallAxis from '../../Core/Axis/WaterfallAxis.js';
  32. import WaterfallPoint from './WaterfallPoint.js';
  33. import '../../Core/Options.js';
  34. /**
  35. * Returns true if the key is a direct property of the object.
  36. * @private
  37. * @param {*} obj - Object with property to test
  38. * @param {string} key - Property key to test
  39. * @return {boolean} - Whether it is a direct property
  40. */
  41. function ownProp(obj, key) {
  42. return Object.hasOwnProperty.call(obj, key);
  43. }
  44. /* eslint-disable no-invalid-this, valid-jsdoc */
  45. // eslint-disable-next-line valid-jsdoc
  46. /**
  47. * Waterfall series type.
  48. *
  49. * @private
  50. */
  51. var WaterfallSeries = /** @class */ (function (_super) {
  52. __extends(WaterfallSeries, _super);
  53. function WaterfallSeries() {
  54. /* *
  55. *
  56. * Static properties
  57. *
  58. * */
  59. var _this = _super !== null && _super.apply(this, arguments) || this;
  60. /* *
  61. *
  62. * Properties
  63. *
  64. * */
  65. _this.chart = void 0;
  66. _this.data = void 0;
  67. _this.options = void 0;
  68. _this.points = void 0;
  69. _this.stackedYNeg = void 0;
  70. _this.stackedYPos = void 0;
  71. _this.stackKey = void 0;
  72. _this.xData = void 0;
  73. _this.yAxis = void 0;
  74. _this.yData = void 0;
  75. return _this;
  76. }
  77. /* *
  78. *
  79. * Functions
  80. *
  81. * */
  82. // After generating points, set y-values for all sums.
  83. WaterfallSeries.prototype.generatePoints = function () {
  84. var point, len, i, y;
  85. // Parent call:
  86. ColumnSeries.prototype.generatePoints.apply(this);
  87. for (i = 0, len = this.points.length; i < len; i++) {
  88. point = this.points[i];
  89. y = this.processedYData[i];
  90. // override point value for sums
  91. // #3710 Update point does not propagate to sum
  92. if (point.isIntermediateSum || point.isSum) {
  93. point.y = correctFloat(y);
  94. }
  95. }
  96. };
  97. // Translate data points from raw values
  98. WaterfallSeries.prototype.translate = function () {
  99. var series = this, options = series.options, yAxis = series.yAxis, len, i, points, point, shapeArgs, y, yValue, previousY, previousIntermediate, range, minPointLength = pick(options.minPointLength, 5), halfMinPointLength = minPointLength / 2, threshold = options.threshold, stacking = options.stacking, tooltipY, actualStack = yAxis.waterfall.stacks[series.stackKey], actualStackX, dummyStackItem, total, pointY, yPos, hPos;
  100. // run column series translate
  101. ColumnSeries.prototype.translate.apply(series);
  102. previousY = previousIntermediate = threshold;
  103. points = series.points;
  104. for (i = 0, len = points.length; i < len; i++) {
  105. // cache current point object
  106. point = points[i];
  107. yValue = series.processedYData[i];
  108. shapeArgs = point.shapeArgs;
  109. range = [0, yValue];
  110. pointY = point.y;
  111. // code responsible for correct positions of stacked points
  112. // starts here
  113. if (stacking) {
  114. if (actualStack) {
  115. actualStackX = actualStack[i];
  116. if (stacking === 'overlap') {
  117. total =
  118. actualStackX.stackState[actualStackX.stateIndex--];
  119. y = pointY >= 0 ? total : total - pointY;
  120. if (ownProp(actualStackX, 'absolutePos')) {
  121. delete actualStackX.absolutePos;
  122. }
  123. if (ownProp(actualStackX, 'absoluteNeg')) {
  124. delete actualStackX.absoluteNeg;
  125. }
  126. }
  127. else {
  128. if (pointY >= 0) {
  129. total = actualStackX.threshold +
  130. actualStackX.posTotal;
  131. actualStackX.posTotal -= pointY;
  132. y = total;
  133. }
  134. else {
  135. total = actualStackX.threshold +
  136. actualStackX.negTotal;
  137. actualStackX.negTotal -= pointY;
  138. y = total - pointY;
  139. }
  140. if (!actualStackX.posTotal) {
  141. if (ownProp(actualStackX, 'absolutePos')) {
  142. actualStackX.posTotal =
  143. actualStackX.absolutePos;
  144. delete actualStackX.absolutePos;
  145. }
  146. }
  147. if (!actualStackX.negTotal) {
  148. if (ownProp(actualStackX, 'absoluteNeg')) {
  149. actualStackX.negTotal =
  150. actualStackX.absoluteNeg;
  151. delete actualStackX.absoluteNeg;
  152. }
  153. }
  154. }
  155. if (!point.isSum) {
  156. // the connectorThreshold property is later used in
  157. // getCrispPath function to draw a connector line in a
  158. // correct place
  159. actualStackX.connectorThreshold =
  160. actualStackX.threshold + actualStackX.stackTotal;
  161. }
  162. if (yAxis.reversed) {
  163. yPos = (pointY >= 0) ? (y - pointY) : (y + pointY);
  164. hPos = y;
  165. }
  166. else {
  167. yPos = y;
  168. hPos = y - pointY;
  169. }
  170. point.below = yPos <= pick(threshold, 0);
  171. shapeArgs.y = yAxis.translate(yPos, 0, 1, 0, 1);
  172. shapeArgs.height = Math.abs(shapeArgs.y -
  173. yAxis.translate(hPos, 0, 1, 0, 1));
  174. dummyStackItem = yAxis.waterfall.dummyStackItem;
  175. if (dummyStackItem) {
  176. dummyStackItem.x = i;
  177. dummyStackItem.label = actualStack[i].label;
  178. dummyStackItem.setOffset(series.pointXOffset || 0, series.barW || 0, series.stackedYNeg[i], series.stackedYPos[i]);
  179. }
  180. }
  181. }
  182. else {
  183. // up points
  184. y =
  185. Math.max(previousY, previousY + pointY) + range[0];
  186. shapeArgs.y =
  187. yAxis.translate(y, 0, 1, 0, 1);
  188. // sum points
  189. if (point.isSum) {
  190. shapeArgs.y = yAxis.translate(range[1], 0, 1, 0, 1);
  191. shapeArgs.height = Math.min(yAxis.translate(range[0], 0, 1, 0, 1), yAxis.len) - shapeArgs.y; // #4256
  192. }
  193. else if (point.isIntermediateSum) {
  194. if (pointY >= 0) {
  195. yPos = range[1] + previousIntermediate;
  196. hPos = previousIntermediate;
  197. }
  198. else {
  199. yPos = previousIntermediate;
  200. hPos = range[1] + previousIntermediate;
  201. }
  202. if (yAxis.reversed) {
  203. // swapping values
  204. yPos ^= hPos;
  205. hPos ^= yPos;
  206. yPos ^= hPos;
  207. }
  208. shapeArgs.y = yAxis.translate(yPos, 0, 1, 0, 1);
  209. shapeArgs.height = Math.abs(shapeArgs.y -
  210. Math.min(yAxis.translate(hPos, 0, 1, 0, 1), yAxis.len));
  211. previousIntermediate += range[1];
  212. // If it's not the sum point, update previous stack end position
  213. // and get shape height (#3886)
  214. }
  215. else {
  216. shapeArgs.height = yValue > 0 ?
  217. yAxis.translate(previousY, 0, 1, 0, 1) - shapeArgs.y :
  218. yAxis.translate(previousY, 0, 1, 0, 1) - yAxis.translate(previousY - yValue, 0, 1, 0, 1);
  219. previousY += yValue;
  220. point.below = previousY < pick(threshold, 0);
  221. }
  222. // #3952 Negative sum or intermediate sum not rendered correctly
  223. if (shapeArgs.height < 0) {
  224. shapeArgs.y += shapeArgs.height;
  225. shapeArgs.height *= -1;
  226. }
  227. }
  228. point.plotY = shapeArgs.y =
  229. Math.round(shapeArgs.y) - (series.borderWidth % 2) / 2;
  230. // #3151
  231. shapeArgs.height =
  232. Math.max(Math.round(shapeArgs.height), 0.001);
  233. point.yBottom = shapeArgs.y + shapeArgs.height;
  234. if (shapeArgs.height <= minPointLength && !point.isNull) {
  235. shapeArgs.height = minPointLength;
  236. shapeArgs.y -= halfMinPointLength;
  237. point.plotY = shapeArgs.y;
  238. if (point.y < 0) {
  239. point.minPointLengthOffset = -halfMinPointLength;
  240. }
  241. else {
  242. point.minPointLengthOffset = halfMinPointLength;
  243. }
  244. }
  245. else {
  246. if (point.isNull) {
  247. shapeArgs.width = 0;
  248. }
  249. point.minPointLengthOffset = 0;
  250. }
  251. // Correct tooltip placement (#3014)
  252. tooltipY =
  253. point.plotY + (point.negative ? shapeArgs.height : 0);
  254. if (series.chart.inverted) {
  255. point.tooltipPos[0] = yAxis.len - tooltipY;
  256. }
  257. else {
  258. point.tooltipPos[1] = tooltipY;
  259. }
  260. }
  261. };
  262. // Call default processData then override yData to reflect waterfall's
  263. // extremes on yAxis
  264. WaterfallSeries.prototype.processData = function (force) {
  265. var series = this, options = series.options, yData = series.yData,
  266. // #3710 Update point does not propagate to sum
  267. points = options.data, point, dataLength = yData.length, threshold = options.threshold || 0, subSum, sum, dataMin, dataMax, y, i;
  268. sum = subSum = dataMin = dataMax = 0;
  269. for (i = 0; i < dataLength; i++) {
  270. y = yData[i];
  271. point = points && points[i] ? points[i] : {};
  272. if (y === 'sum' || point.isSum) {
  273. yData[i] = correctFloat(sum);
  274. }
  275. else if (y === 'intermediateSum' ||
  276. point.isIntermediateSum) {
  277. yData[i] = correctFloat(subSum);
  278. subSum = 0;
  279. }
  280. else {
  281. sum += y;
  282. subSum += y;
  283. }
  284. dataMin = Math.min(sum, dataMin);
  285. dataMax = Math.max(sum, dataMax);
  286. }
  287. _super.prototype.processData.call(this, force);
  288. // Record extremes only if stacking was not set:
  289. if (!options.stacking) {
  290. series.dataMin = dataMin + threshold;
  291. series.dataMax = dataMax;
  292. }
  293. return;
  294. };
  295. // Return y value or string if point is sum
  296. WaterfallSeries.prototype.toYData = function (pt) {
  297. if (pt.isSum) {
  298. return 'sum';
  299. }
  300. if (pt.isIntermediateSum) {
  301. return 'intermediateSum';
  302. }
  303. return pt.y;
  304. };
  305. WaterfallSeries.prototype.updateParallelArrays = function (point, i) {
  306. _super.prototype.updateParallelArrays.call(this, point, i);
  307. // Prevent initial sums from triggering an error (#3245, #7559)
  308. if (this.yData[0] === 'sum' || this.yData[0] === 'intermediateSum') {
  309. this.yData[0] = null;
  310. }
  311. };
  312. // Postprocess mapping between options and SVG attributes
  313. WaterfallSeries.prototype.pointAttribs = function (point, state) {
  314. var upColor = this.options.upColor, attr;
  315. // Set or reset up color (#3710, update to negative)
  316. if (upColor && !point.options.color) {
  317. point.color = point.y > 0 ? upColor : null;
  318. }
  319. attr = ColumnSeries.prototype.pointAttribs.call(this, point, state);
  320. // The dashStyle option in waterfall applies to the graph, not
  321. // the points
  322. delete attr.dashstyle;
  323. return attr;
  324. };
  325. // Return an empty path initially, because we need to know the stroke-width
  326. // in order to set the final path.
  327. WaterfallSeries.prototype.getGraphPath = function () {
  328. return [['M', 0, 0]];
  329. };
  330. // Draw columns' connector lines
  331. WaterfallSeries.prototype.getCrispPath = function () {
  332. var data = this.data, yAxis = this.yAxis, length = data.length, graphNormalizer = Math.round(this.graph.strokeWidth()) % 2 / 2, borderNormalizer = Math.round(this.borderWidth) % 2 / 2, reversedXAxis = this.xAxis.reversed, reversedYAxis = this.yAxis.reversed, stacking = this.options.stacking, path = [], connectorThreshold, prevStack, prevStackX, prevPoint, yPos, isPos, prevArgs, pointArgs, i;
  333. for (i = 1; i < length; i++) {
  334. pointArgs = data[i].shapeArgs;
  335. prevPoint = data[i - 1];
  336. prevArgs = data[i - 1].shapeArgs;
  337. prevStack = yAxis.waterfall.stacks[this.stackKey];
  338. isPos = prevPoint.y > 0 ? -prevArgs.height : 0;
  339. if (prevStack && prevArgs && pointArgs) {
  340. prevStackX = prevStack[i - 1];
  341. // y position of the connector is different when series are
  342. // stacked, yAxis is reversed and it also depends on point's
  343. // value
  344. if (stacking) {
  345. connectorThreshold = prevStackX.connectorThreshold;
  346. yPos = Math.round((yAxis.translate(connectorThreshold, 0, 1, 0, 1) +
  347. (reversedYAxis ? isPos : 0))) - graphNormalizer;
  348. }
  349. else {
  350. yPos =
  351. prevArgs.y + prevPoint.minPointLengthOffset +
  352. borderNormalizer - graphNormalizer;
  353. }
  354. path.push([
  355. 'M',
  356. (prevArgs.x || 0) + (reversedXAxis ?
  357. 0 :
  358. (prevArgs.width || 0)),
  359. yPos
  360. ], [
  361. 'L',
  362. (pointArgs.x || 0) + (reversedXAxis ?
  363. (pointArgs.width || 0) :
  364. 0),
  365. yPos
  366. ]);
  367. }
  368. if (prevArgs &&
  369. path.length &&
  370. ((!stacking && prevPoint.y < 0 && !reversedYAxis) ||
  371. (prevPoint.y > 0 && reversedYAxis))) {
  372. path[path.length - 2][2] += prevArgs.height;
  373. path[path.length - 1][2] += prevArgs.height;
  374. }
  375. }
  376. return path;
  377. };
  378. // The graph is initially drawn with an empty definition, then updated with
  379. // crisp rendering.
  380. WaterfallSeries.prototype.drawGraph = function () {
  381. LineSeries.prototype.drawGraph.call(this);
  382. this.graph.attr({
  383. d: this.getCrispPath()
  384. });
  385. };
  386. // Waterfall has stacking along the x-values too.
  387. WaterfallSeries.prototype.setStackedPoints = function () {
  388. var series = this, options = series.options, waterfallStacks = series.yAxis.waterfall.stacks, seriesThreshold = options.threshold, stackThreshold = seriesThreshold || 0, interSum = stackThreshold, stackKey = series.stackKey, xData = series.xData, xLength = xData.length, actualStack, actualStackX, totalYVal, actualSum, prevSum, statesLen, posTotal, negTotal, xPoint, yVal, x, alreadyChanged, changed;
  389. // function responsible for calculating correct values for stackState
  390. // array of each stack item. The arguments are: firstS - the value for
  391. // the first state, nextS - the difference between the previous and the
  392. // newest state, sInx - counter used in the for that updates each state
  393. // when necessary, sOff - offset that must be added to each state when
  394. // they need to be updated (if point isn't a total sum)
  395. // eslint-disable-next-line require-jsdoc
  396. function calculateStackState(firstS, nextS, sInx, sOff) {
  397. if (!statesLen) {
  398. actualStackX.stackState[0] = firstS;
  399. statesLen = actualStackX.stackState.length;
  400. }
  401. else {
  402. for (sInx; sInx < statesLen; sInx++) {
  403. actualStackX.stackState[sInx] += sOff;
  404. }
  405. }
  406. actualStackX.stackState.push(actualStackX.stackState[statesLen - 1] + nextS);
  407. }
  408. series.yAxis.stacking.usePercentage = false;
  409. totalYVal = actualSum = prevSum = stackThreshold;
  410. // code responsible for creating stacks for waterfall series
  411. if (series.visible ||
  412. !series.chart.options.chart.ignoreHiddenSeries) {
  413. changed = waterfallStacks.changed;
  414. alreadyChanged = waterfallStacks.alreadyChanged;
  415. // in case of a redraw, stack for each x value must be
  416. // emptied (only for the first series in a specific stack)
  417. // and recalculated once more
  418. if (alreadyChanged &&
  419. alreadyChanged.indexOf(stackKey) < 0) {
  420. changed = true;
  421. }
  422. if (!waterfallStacks[stackKey]) {
  423. waterfallStacks[stackKey] = {};
  424. }
  425. actualStack = waterfallStacks[stackKey];
  426. for (var i = 0; i < xLength; i++) {
  427. x = xData[i];
  428. if (!actualStack[x] || changed) {
  429. actualStack[x] = {
  430. negTotal: 0,
  431. posTotal: 0,
  432. stackTotal: 0,
  433. threshold: 0,
  434. stateIndex: 0,
  435. stackState: [],
  436. label: ((changed &&
  437. actualStack[x]) ?
  438. actualStack[x].label :
  439. void 0)
  440. };
  441. }
  442. actualStackX = actualStack[x];
  443. yVal = series.yData[i];
  444. if (yVal >= 0) {
  445. actualStackX.posTotal += yVal;
  446. }
  447. else {
  448. actualStackX.negTotal += yVal;
  449. }
  450. // points do not exist yet, so raw data is used
  451. xPoint = options.data[i];
  452. posTotal = actualStackX.absolutePos =
  453. actualStackX.posTotal;
  454. negTotal = actualStackX.absoluteNeg =
  455. actualStackX.negTotal;
  456. actualStackX.stackTotal = posTotal + negTotal;
  457. statesLen = actualStackX.stackState.length;
  458. if (xPoint && xPoint.isIntermediateSum) {
  459. calculateStackState(prevSum, actualSum, 0, prevSum);
  460. prevSum = actualSum;
  461. actualSum = seriesThreshold;
  462. // swapping values
  463. stackThreshold ^= interSum;
  464. interSum ^= stackThreshold;
  465. stackThreshold ^= interSum;
  466. }
  467. else if (xPoint && xPoint.isSum) {
  468. calculateStackState(seriesThreshold, totalYVal, statesLen);
  469. stackThreshold = seriesThreshold;
  470. }
  471. else {
  472. calculateStackState(stackThreshold, yVal, 0, totalYVal);
  473. if (xPoint) {
  474. totalYVal += yVal;
  475. actualSum += yVal;
  476. }
  477. }
  478. actualStackX.stateIndex++;
  479. actualStackX.threshold = stackThreshold;
  480. stackThreshold += actualStackX.stackTotal;
  481. }
  482. waterfallStacks.changed = false;
  483. if (!waterfallStacks.alreadyChanged) {
  484. waterfallStacks.alreadyChanged = [];
  485. }
  486. waterfallStacks.alreadyChanged.push(stackKey);
  487. }
  488. };
  489. // Extremes for a non-stacked series are recorded in processData.
  490. // In case of stacking, use Series.stackedYData to calculate extremes.
  491. WaterfallSeries.prototype.getExtremes = function () {
  492. var stacking = this.options.stacking, yAxis, waterfallStacks, stackedYNeg, stackedYPos;
  493. if (stacking) {
  494. yAxis = this.yAxis;
  495. waterfallStacks = yAxis.waterfall.stacks;
  496. stackedYNeg = this.stackedYNeg = [];
  497. stackedYPos = this.stackedYPos = [];
  498. // the visible y range can be different when stacking is set to
  499. // overlap and different when it's set to normal
  500. if (stacking === 'overlap') {
  501. objectEach(waterfallStacks[this.stackKey], function (stackX) {
  502. stackedYNeg.push(arrayMin(stackX.stackState));
  503. stackedYPos.push(arrayMax(stackX.stackState));
  504. });
  505. }
  506. else {
  507. objectEach(waterfallStacks[this.stackKey], function (stackX) {
  508. stackedYNeg.push(stackX.negTotal + stackX.threshold);
  509. stackedYPos.push(stackX.posTotal + stackX.threshold);
  510. });
  511. }
  512. return {
  513. dataMin: arrayMin(stackedYNeg),
  514. dataMax: arrayMax(stackedYPos)
  515. };
  516. }
  517. // When not stacking, data extremes have already been computed in the
  518. // processData function.
  519. return {
  520. dataMin: this.dataMin,
  521. dataMax: this.dataMax
  522. };
  523. };
  524. /**
  525. * A waterfall chart displays sequentially introduced positive or negative
  526. * values in cumulative columns.
  527. *
  528. * @sample highcharts/demo/waterfall/
  529. * Waterfall chart
  530. * @sample highcharts/plotoptions/waterfall-inverted/
  531. * Horizontal (inverted) waterfall
  532. * @sample highcharts/plotoptions/waterfall-stacked/
  533. * Stacked waterfall chart
  534. *
  535. * @extends plotOptions.column
  536. * @excluding boostThreshold, boostBlending
  537. * @product highcharts
  538. * @requires highcharts-more
  539. * @optionparent plotOptions.waterfall
  540. */
  541. WaterfallSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  542. /**
  543. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  544. * @apioption plotOptions.waterfall.color
  545. */
  546. /**
  547. * The color used specifically for positive point columns. When not
  548. * specified, the general series color is used.
  549. *
  550. * In styled mode, the waterfall colors can be set with the
  551. * `.highcharts-point-negative`, `.highcharts-sum` and
  552. * `.highcharts-intermediate-sum` classes.
  553. *
  554. * @sample {highcharts} highcharts/demo/waterfall/
  555. * Waterfall
  556. *
  557. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  558. * @product highcharts
  559. * @apioption plotOptions.waterfall.upColor
  560. */
  561. dataLabels: {
  562. inside: true
  563. },
  564. /**
  565. * The width of the line connecting waterfall columns.
  566. *
  567. * @product highcharts
  568. */
  569. lineWidth: 1,
  570. /**
  571. * The color of the line that connects columns in a waterfall series.
  572. *
  573. * In styled mode, the stroke can be set with the `.highcharts-graph`
  574. * class.
  575. *
  576. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  577. * @since 3.0
  578. * @product highcharts
  579. */
  580. lineColor: palette.neutralColor80,
  581. /**
  582. * A name for the dash style to use for the line connecting the columns
  583. * of the waterfall series. Possible values: Dash, DashDot, Dot,
  584. * LongDash, LongDashDot, LongDashDotDot, ShortDash, ShortDashDot,
  585. * ShortDashDotDot, ShortDot, Solid
  586. *
  587. * In styled mode, the stroke dash-array can be set with the
  588. * `.highcharts-graph` class.
  589. *
  590. * @type {Highcharts.DashStyleValue}
  591. * @since 3.0
  592. * @product highcharts
  593. */
  594. dashStyle: 'Dot',
  595. /**
  596. * The color of the border of each waterfall column.
  597. *
  598. * In styled mode, the border stroke can be set with the
  599. * `.highcharts-point` class.
  600. *
  601. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  602. * @since 3.0
  603. * @product highcharts
  604. */
  605. borderColor: palette.neutralColor80,
  606. states: {
  607. hover: {
  608. lineWidthPlus: 0 // #3126
  609. }
  610. }
  611. });
  612. return WaterfallSeries;
  613. }(ColumnSeries));
  614. extend(WaterfallSeries.prototype, {
  615. getZonesGraphs: LineSeries.prototype.getZonesGraphs,
  616. pointValKey: 'y',
  617. // Property needed to prevent lines between the columns from disappearing
  618. // when negativeColor is used.
  619. showLine: true,
  620. pointClass: WaterfallPoint
  621. });
  622. SeriesRegistry.registerSeriesType('waterfall', WaterfallSeries);
  623. WaterfallAxis.compose(H.Axis, Chart);
  624. /* *
  625. *
  626. * Export
  627. *
  628. * */
  629. export default WaterfallSeries;
  630. /**
  631. *
  632. * API Options
  633. *
  634. */
  635. /**
  636. * A `waterfall` series. If the [type](#series.waterfall.type) option
  637. * is not specified, it is inherited from [chart.type](#chart.type).
  638. *
  639. * @extends series,plotOptions.waterfall
  640. * @excluding dataParser, dataURL, boostThreshold, boostBlending
  641. * @product highcharts
  642. * @requires highcharts-more
  643. * @apioption series.waterfall
  644. */
  645. /**
  646. * An array of data points for the series. For the `waterfall` series
  647. * type, points can be given in the following ways:
  648. *
  649. * 1. An array of numerical values. In this case, the numerical values will be
  650. * interpreted as `y` options. The `x` values will be automatically
  651. * calculated, either starting at 0 and incremented by 1, or from
  652. * `pointStart` and `pointInterval` given in the series options. If the axis
  653. * has categories, these will be used. Example:
  654. * ```js
  655. * data: [0, 5, 3, 5]
  656. * ```
  657. *
  658. * 2. An array of arrays with 2 values. In this case, the values correspond to
  659. * `x,y`. If the first value is a string, it is applied as the name of the
  660. * point, and the `x` value is inferred.
  661. * ```js
  662. * data: [
  663. * [0, 7],
  664. * [1, 8],
  665. * [2, 3]
  666. * ]
  667. * ```
  668. *
  669. * 3. An array of objects with named values. The following snippet shows only a
  670. * few settings, see the complete options set below. If the total number of
  671. * data points exceeds the series'
  672. * [turboThreshold](#series.waterfall.turboThreshold), this option is not
  673. * available.
  674. * ```js
  675. * data: [{
  676. * x: 1,
  677. * y: 8,
  678. * name: "Point2",
  679. * color: "#00FF00"
  680. * }, {
  681. * x: 1,
  682. * y: 8,
  683. * name: "Point1",
  684. * color: "#FF00FF"
  685. * }]
  686. * ```
  687. *
  688. * @sample {highcharts} highcharts/chart/reflow-true/
  689. * Numerical values
  690. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  691. * Arrays of numeric x and y
  692. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  693. * Arrays of datetime x and y
  694. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  695. * Arrays of point.name and y
  696. * @sample {highcharts} highcharts/series/data-array-of-objects/
  697. * Config objects
  698. *
  699. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  700. * @extends series.line.data
  701. * @excluding marker
  702. * @product highcharts
  703. * @apioption series.waterfall.data
  704. */
  705. /**
  706. * When this property is true, the points acts as a summary column for
  707. * the values added or substracted since the last intermediate sum,
  708. * or since the start of the series. The `y` value is ignored.
  709. *
  710. * @sample {highcharts} highcharts/demo/waterfall/
  711. * Waterfall
  712. *
  713. * @type {boolean}
  714. * @default false
  715. * @product highcharts
  716. * @apioption series.waterfall.data.isIntermediateSum
  717. */
  718. /**
  719. * When this property is true, the point display the total sum across
  720. * the entire series. The `y` value is ignored.
  721. *
  722. * @sample {highcharts} highcharts/demo/waterfall/
  723. * Waterfall
  724. *
  725. * @type {boolean}
  726. * @default false
  727. * @product highcharts
  728. * @apioption series.waterfall.data.isSum
  729. */
  730. ''; // adds doclets above to transpiled file