Scatter.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* *
  2. * (c) 2010-2019 Torstein Honsi
  3. *
  4. * Scatter 3D series.
  5. *
  6. * License: www.highcharts.com/license
  7. */
  8. 'use strict';
  9. import H from '../parts/Globals.js';
  10. import '../parts/Utilities.js';
  11. var Point = H.Point,
  12. seriesType = H.seriesType,
  13. seriesTypes = H.seriesTypes;
  14. /**
  15. * @private
  16. * @class
  17. * @name Highcharts.seriesTypes.scatter3d
  18. *
  19. * @augments Highcharts.Series
  20. */
  21. seriesType(
  22. 'scatter3d',
  23. 'scatter',
  24. /**
  25. * A 3D scatter plot uses x, y and z coordinates to display values for three
  26. * variables for a set of data.
  27. *
  28. * @sample {highcharts} highcharts/3d/scatter/
  29. * Simple 3D scatter
  30. * @sample {highcharts} highcharts/demo/3d-scatter-draggable
  31. * Draggable 3d scatter
  32. *
  33. * @extends plotOptions.scatter
  34. * @product highcharts
  35. * @optionparent plotOptions.scatter3d
  36. */
  37. {
  38. tooltip: {
  39. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>'
  40. }
  41. // Series class
  42. }, {
  43. pointAttribs: function (point) {
  44. var attribs = seriesTypes.scatter.prototype.pointAttribs
  45. .apply(this, arguments);
  46. if (this.chart.is3d() && point) {
  47. attribs.zIndex = H.pointCameraDistance(point, this.chart);
  48. }
  49. return attribs;
  50. },
  51. axisTypes: ['xAxis', 'yAxis', 'zAxis'],
  52. pointArrayMap: ['x', 'y', 'z'],
  53. parallelArrays: ['x', 'y', 'z'],
  54. // Require direct touch rather than using the k-d-tree, because the
  55. // k-d-tree currently doesn't take the xyz coordinate system into
  56. // account (#4552)
  57. directTouch: true
  58. // Point class
  59. }, {
  60. applyOptions: function () {
  61. Point.prototype.applyOptions.apply(this, arguments);
  62. if (this.z === undefined) {
  63. this.z = 0;
  64. }
  65. return this;
  66. }
  67. }
  68. );
  69. /**
  70. * A `scatter3d` series. If the [type](#series.scatter3d.type) option is
  71. * not specified, it is inherited from [chart.type](#chart.type).
  72. *
  73. * scatter3d](#plotOptions.scatter3d).
  74. *
  75. * @extends series,plotOptions.scatter3d
  76. * @product highcharts
  77. * @apioption series.scatter3d
  78. */
  79. /**
  80. * An array of data points for the series. For the `scatter3d` series
  81. * type, points can be given in the following ways:
  82. *
  83. * 1. An array of arrays with 3 values. In this case, the values correspond
  84. * to `x,y,z`. If the first value is a string, it is applied as the name
  85. * of the point, and the `x` value is inferred.
  86. *
  87. * ```js
  88. * data: [
  89. * [0, 0, 1],
  90. * [1, 8, 7],
  91. * [2, 9, 2]
  92. * ]
  93. * ```
  94. *
  95. * 3. An array of objects with named values. The following snippet shows only a
  96. * few settings, see the complete options set below. If the total number of data
  97. * points exceeds the series'
  98. * [turboThreshold](#series.scatter3d.turboThreshold), this option is not
  99. * available.
  100. *
  101. * ```js
  102. * data: [{
  103. * x: 1,
  104. * y: 2,
  105. * z: 24,
  106. * name: "Point2",
  107. * color: "#00FF00"
  108. * }, {
  109. * x: 1,
  110. * y: 4,
  111. * z: 12,
  112. * name: "Point1",
  113. * color: "#FF00FF"
  114. * }]
  115. * ```
  116. *
  117. * @sample {highcharts} highcharts/chart/reflow-true/
  118. * Numerical values
  119. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  120. * Arrays of numeric x and y
  121. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  122. * Arrays of datetime x and y
  123. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  124. * Arrays of point.name and y
  125. * @sample {highcharts} highcharts/series/data-array-of-objects/
  126. * Config objects
  127. *
  128. * @type {Array<Array<number>|*>}
  129. * @extends series.scatter.data
  130. * @product highcharts
  131. * @apioption series.scatter3d.data
  132. */
  133. /**
  134. * The z value for each data point.
  135. *
  136. * @type {number}
  137. * @product highcharts
  138. * @apioption series.scatter3d.data.z
  139. */