MapLineSeries.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /**
  2. * (c) 2010-2019 Torstein Honsi
  3. *
  4. * License: www.highcharts.com/license
  5. */
  6. 'use strict';
  7. import H from '../parts/Globals.js';
  8. import '../parts/Utilities.js';
  9. import '../parts/Options.js';
  10. var seriesType = H.seriesType,
  11. seriesTypes = H.seriesTypes;
  12. /**
  13. * @private
  14. * @class
  15. * @name Highcharts.seriesTypes.mapline
  16. *
  17. * @augments Highcharts.Series
  18. */
  19. seriesType('mapline', 'map'
  20. /**
  21. * A mapline series is a special case of the map series where the value
  22. * colors are applied to the strokes rather than the fills. It can also be
  23. * used for freeform drawing, like dividers, in the map.
  24. *
  25. * @sample maps/demo/mapline-mappoint/
  26. * Mapline and map-point chart
  27. *
  28. * @extends plotOptions.map
  29. * @product highmaps
  30. * @optionparent plotOptions.mapline
  31. */
  32. , {
  33. /**
  34. * The width of the map line.
  35. */
  36. lineWidth: 1,
  37. /**
  38. * Fill color for the map line shapes
  39. *
  40. * @type {Highcharts.ColorString}
  41. */
  42. fillColor: 'none'
  43. }, {
  44. type: 'mapline',
  45. colorProp: 'stroke',
  46. pointAttrToOptions: {
  47. 'stroke': 'color',
  48. 'stroke-width': 'lineWidth'
  49. },
  50. /**
  51. * Get presentational attributes
  52. *
  53. * @private
  54. * @function Highcharts.seriesTypes.mapline#pointAttribs
  55. *
  56. * @param {Highcharts.Point} point
  57. *
  58. * @param {string} state
  59. *
  60. * @return {Highcharts.Dictionary<*>}
  61. */
  62. pointAttribs: function (point, state) {
  63. var attr = seriesTypes.map.prototype.pointAttribs.call(
  64. this,
  65. point,
  66. state
  67. );
  68. // The difference from a map series is that the stroke takes the
  69. // point color
  70. attr.fill = this.options.fillColor;
  71. return attr;
  72. },
  73. drawLegendSymbol: seriesTypes.line.prototype.drawLegendSymbol
  74. });
  75. /**
  76. * A `mapline` series. If the [type](#series.mapline.type) option is
  77. * not specified, it is inherited from [chart.type](#chart.type).
  78. *
  79. * @extends series,plotOptions.mapline
  80. * @excluding dataParser, dataURL, marker
  81. * @product highmaps
  82. * @apioption series.mapline
  83. */
  84. /**
  85. * An array of data points for the series. For the `mapline` series type,
  86. * points can be given in the following ways:
  87. *
  88. * 1. An array of numerical values. In this case, the numerical values
  89. * will be interpreted as `value` options. Example:
  90. *
  91. * ```js
  92. * data: [0, 5, 3, 5]
  93. * ```
  94. *
  95. * 2. An array of arrays with 2 values. In this case, the values correspond
  96. * to `[hc-key, value]`. Example:
  97. *
  98. * ```js
  99. * data: [
  100. * ['us-ny', 0],
  101. * ['us-mi', 5],
  102. * ['us-tx', 3],
  103. * ['us-ak', 5]
  104. * ]
  105. * ```
  106. *
  107. * 3. An array of objects with named values. The following snippet shows only a
  108. * few settings, see the complete options set below. If the total number of data
  109. * points exceeds the series' [turboThreshold](#series.map.turboThreshold),
  110. * this option is not available.
  111. *
  112. * ```js
  113. * data: [{
  114. * value: 6,
  115. * name: "Point2",
  116. * color: "#00FF00"
  117. * }, {
  118. * value: 6,
  119. * name: "Point1",
  120. * color: "#FF00FF"
  121. * }]
  122. * ```
  123. *
  124. * @type {Array<number|Array<string,number>|object>}
  125. * @product highmaps
  126. * @apioption series.mapline.data
  127. */