@fluentui/react-charting 5.23.58 → 5.23.60

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.
Files changed (186) hide show
  1. package/CHANGELOG.json +55 -1
  2. package/CHANGELOG.md +24 -2
  3. package/dist/react-charting.d.ts +26 -1
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +6 -0
  7. package/lib/components/AreaChart/AreaChart.base.d.ts +3 -1
  8. package/lib/components/AreaChart/AreaChart.base.js +8 -2
  9. package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
  10. package/lib/components/DeclarativeChart/DeclarativeChart.d.ts +1 -1
  11. package/lib/components/DeclarativeChart/DeclarativeChart.js +35 -12
  12. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  13. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +8 -4
  14. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  15. package/lib/components/DeclarativeChart/index.d.ts +0 -1
  16. package/lib/components/DeclarativeChart/index.js.map +1 -1
  17. package/lib/components/DonutChart/DonutChart.base.d.ts +3 -1
  18. package/lib/components/DonutChart/DonutChart.base.js +8 -2
  19. package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
  20. package/lib/components/GaugeChart/GaugeChart.base.d.ts +3 -1
  21. package/lib/components/GaugeChart/GaugeChart.base.js +7 -1
  22. package/lib/components/GaugeChart/GaugeChart.base.js.map +1 -1
  23. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +3 -1
  24. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +7 -1
  25. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  26. package/lib/components/HeatMapChart/HeatMapChart.base.d.ts +3 -1
  27. package/lib/components/HeatMapChart/HeatMapChart.base.js +8 -2
  28. package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  29. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -1
  30. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +7 -1
  31. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  32. package/lib/components/Legends/Legends.base.d.ts +8 -2
  33. package/lib/components/Legends/Legends.base.js +12 -1
  34. package/lib/components/Legends/Legends.base.js.map +1 -1
  35. package/lib/components/Legends/Legends.styles.d.ts +8 -0
  36. package/lib/components/Legends/Legends.styles.js +21 -8
  37. package/lib/components/Legends/Legends.styles.js.map +1 -1
  38. package/lib/components/Legends/Legends.types.d.ts +15 -1
  39. package/lib/components/Legends/Legends.types.js.map +1 -1
  40. package/lib/components/LineChart/LineChart.base.d.ts +11 -1
  41. package/lib/components/LineChart/LineChart.base.js +101 -23
  42. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  43. package/lib/components/LineChart/LineChart.types.d.ts +5 -0
  44. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  45. package/lib/components/SankeyChart/SankeyChart.base.d.ts +2 -1
  46. package/lib/components/SankeyChart/SankeyChart.base.js +4 -0
  47. package/lib/components/SankeyChart/SankeyChart.base.js.map +1 -1
  48. package/lib/components/VerticalBarChart/VerticalBarChart.base.d.ts +3 -1
  49. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +7 -1
  50. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  51. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -1
  52. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +7 -1
  53. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  54. package/lib/index.d.ts +2 -2
  55. package/lib/index.js.map +1 -1
  56. package/lib/types/IDataPoint.d.ts +14 -0
  57. package/lib/types/IDataPoint.js.map +1 -1
  58. package/lib/utilities/image-export-utils.d.ts +13 -0
  59. package/lib/{components/DeclarativeChart/imageExporter.js → utilities/image-export-utils.js} +65 -63
  60. package/lib/utilities/image-export-utils.js.map +1 -0
  61. package/lib/utilities/utilities.d.ts +2 -0
  62. package/lib/utilities/utilities.js +44 -0
  63. package/lib/utilities/utilities.js.map +1 -1
  64. package/lib-amd/components/AreaChart/AreaChart.base.d.ts +3 -1
  65. package/lib-amd/components/AreaChart/AreaChart.base.js +7 -2
  66. package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
  67. package/lib-amd/components/DeclarativeChart/DeclarativeChart.d.ts +1 -1
  68. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +36 -12
  69. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  70. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +8 -4
  71. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  72. package/lib-amd/components/DeclarativeChart/index.d.ts +0 -1
  73. package/lib-amd/components/DeclarativeChart/index.js.map +1 -1
  74. package/lib-amd/components/DonutChart/DonutChart.base.d.ts +3 -1
  75. package/lib-amd/components/DonutChart/DonutChart.base.js +7 -2
  76. package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
  77. package/lib-amd/components/GaugeChart/GaugeChart.base.d.ts +3 -1
  78. package/lib-amd/components/GaugeChart/GaugeChart.base.js +7 -2
  79. package/lib-amd/components/GaugeChart/GaugeChart.base.js.map +1 -1
  80. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +3 -1
  81. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +7 -2
  82. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  83. package/lib-amd/components/HeatMapChart/HeatMapChart.base.d.ts +3 -1
  84. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +7 -2
  85. package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  86. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -1
  87. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +7 -2
  88. package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  89. package/lib-amd/components/Legends/Legends.base.d.ts +8 -2
  90. package/lib-amd/components/Legends/Legends.base.js +12 -2
  91. package/lib-amd/components/Legends/Legends.base.js.map +1 -1
  92. package/lib-amd/components/Legends/Legends.styles.d.ts +8 -0
  93. package/lib-amd/components/Legends/Legends.styles.js +22 -9
  94. package/lib-amd/components/Legends/Legends.styles.js.map +1 -1
  95. package/lib-amd/components/Legends/Legends.types.d.ts +15 -1
  96. package/lib-amd/components/Legends/Legends.types.js.map +1 -1
  97. package/lib-amd/components/LineChart/LineChart.base.d.ts +11 -1
  98. package/lib-amd/components/LineChart/LineChart.base.js +100 -24
  99. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  100. package/lib-amd/components/LineChart/LineChart.types.d.ts +5 -0
  101. package/lib-amd/components/LineChart/LineChart.types.js.map +1 -1
  102. package/lib-amd/components/SankeyChart/SankeyChart.base.d.ts +2 -1
  103. package/lib-amd/components/SankeyChart/SankeyChart.base.js +4 -1
  104. package/lib-amd/components/SankeyChart/SankeyChart.base.js.map +1 -1
  105. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.d.ts +3 -1
  106. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +7 -2
  107. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  108. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -1
  109. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +7 -2
  110. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  111. package/lib-amd/index.d.ts +2 -2
  112. package/lib-amd/index.js.map +1 -1
  113. package/lib-amd/types/IDataPoint.d.ts +14 -0
  114. package/lib-amd/types/IDataPoint.js.map +1 -1
  115. package/lib-amd/utilities/image-export-utils.d.ts +13 -0
  116. package/lib-amd/{components/DeclarativeChart/imageExporter.js → utilities/image-export-utils.js} +69 -67
  117. package/lib-amd/utilities/image-export-utils.js.map +1 -0
  118. package/lib-amd/utilities/utilities.d.ts +2 -0
  119. package/lib-amd/utilities/utilities.js +47 -2
  120. package/lib-amd/utilities/utilities.js.map +1 -1
  121. package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +3 -1
  122. package/lib-commonjs/components/AreaChart/AreaChart.base.js +7 -1
  123. package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
  124. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.d.ts +1 -1
  125. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +35 -12
  126. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  127. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +8 -4
  128. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  129. package/lib-commonjs/components/DeclarativeChart/index.d.ts +0 -1
  130. package/lib-commonjs/components/DeclarativeChart/index.js.map +1 -1
  131. package/lib-commonjs/components/DonutChart/DonutChart.base.d.ts +3 -1
  132. package/lib-commonjs/components/DonutChart/DonutChart.base.js +7 -1
  133. package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
  134. package/lib-commonjs/components/GaugeChart/GaugeChart.base.d.ts +3 -1
  135. package/lib-commonjs/components/GaugeChart/GaugeChart.base.js +7 -1
  136. package/lib-commonjs/components/GaugeChart/GaugeChart.base.js.map +1 -1
  137. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +3 -1
  138. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +7 -1
  139. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  140. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.d.ts +3 -1
  141. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +7 -1
  142. package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
  143. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -1
  144. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +7 -1
  145. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
  146. package/lib-commonjs/components/Legends/Legends.base.d.ts +8 -2
  147. package/lib-commonjs/components/Legends/Legends.base.js +12 -1
  148. package/lib-commonjs/components/Legends/Legends.base.js.map +1 -1
  149. package/lib-commonjs/components/Legends/Legends.styles.d.ts +8 -0
  150. package/lib-commonjs/components/Legends/Legends.styles.js +22 -9
  151. package/lib-commonjs/components/Legends/Legends.styles.js.map +1 -1
  152. package/lib-commonjs/components/Legends/Legends.types.d.ts +15 -1
  153. package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
  154. package/lib-commonjs/components/LineChart/LineChart.base.d.ts +11 -1
  155. package/lib-commonjs/components/LineChart/LineChart.base.js +101 -23
  156. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  157. package/lib-commonjs/components/LineChart/LineChart.types.d.ts +5 -0
  158. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  159. package/lib-commonjs/components/SankeyChart/SankeyChart.base.d.ts +2 -1
  160. package/lib-commonjs/components/SankeyChart/SankeyChart.base.js +4 -0
  161. package/lib-commonjs/components/SankeyChart/SankeyChart.base.js.map +1 -1
  162. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.d.ts +3 -1
  163. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +7 -1
  164. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  165. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -1
  166. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +7 -1
  167. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  168. package/lib-commonjs/index.d.ts +2 -2
  169. package/lib-commonjs/index.js.map +1 -1
  170. package/lib-commonjs/types/IDataPoint.d.ts +14 -0
  171. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  172. package/lib-commonjs/utilities/image-export-utils.d.ts +13 -0
  173. package/lib-commonjs/{components/DeclarativeChart/imageExporter.js → utilities/image-export-utils.js} +70 -67
  174. package/lib-commonjs/utilities/image-export-utils.js.map +1 -0
  175. package/lib-commonjs/utilities/utilities.d.ts +2 -0
  176. package/lib-commonjs/utilities/utilities.js +47 -1
  177. package/lib-commonjs/utilities/utilities.js.map +1 -1
  178. package/package.json +4 -4
  179. package/src/components/Legends/Legends.types.ts +20 -1
  180. package/src/components/LineChart/LineChart.types.ts +6 -0
  181. package/lib/components/DeclarativeChart/imageExporter.d.ts +0 -10
  182. package/lib/components/DeclarativeChart/imageExporter.js.map +0 -1
  183. package/lib-amd/components/DeclarativeChart/imageExporter.d.ts +0 -10
  184. package/lib-amd/components/DeclarativeChart/imageExporter.js.map +0 -1
  185. package/lib-commonjs/components/DeclarativeChart/imageExporter.d.ts +0 -10
  186. package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +0 -1
@@ -1,5 +1,18 @@
1
1
  import { __assign } from "tslib";
2
2
  import { HighContrastSelector, getFocusStyle } from '@fluentui/react/lib/Styling';
3
+ // Constants needed to create legends using SVG for image export
4
+ export var LEGEND_CONTAINER_MARGIN_TOP = 8;
5
+ export var LEGEND_CONTAINER_MARGIN_START = 12;
6
+ export var LEGEND_PADDING = 8;
7
+ export var LEGEND_HEIGHT = 32;
8
+ export var LEGEND_SHAPE_BORDER = 1;
9
+ var LEGEND_SHAPE_SIZE_WITHOUT_BORDER = 12;
10
+ // SVG strokes are drawn centered around the path, with half of the stroke width extending inward
11
+ // (overlapping the fill area) and half outward. To ensure the filled area maintains its intended size,
12
+ // expand the shape accordingly.
13
+ export var LEGEND_SHAPE_SIZE = LEGEND_SHAPE_SIZE_WITHOUT_BORDER + LEGEND_SHAPE_BORDER;
14
+ export var LEGEND_SHAPE_MARGIN_END = 8;
15
+ export var INACTIVE_LEGEND_TEXT_OPACITY = 0.67;
3
16
  export var getStyles = function (props) {
4
17
  var _a, _b;
5
18
  var className = props.className, theme = props.theme, _c = props.isLineLegendInBarChart, isLineLegendInBarChart = _c === void 0 ? false : _c;
@@ -30,7 +43,7 @@ export var getStyles = function (props) {
30
43
  alignItems: 'center',
31
44
  cursor: 'pointer',
32
45
  border: 'none',
33
- padding: '8px',
46
+ padding: "".concat(LEGEND_PADDING, "px"),
34
47
  background: 'none',
35
48
  textTransform: 'capitalize',
36
49
  },
@@ -42,11 +55,11 @@ export var getStyles = function (props) {
42
55
  opacity: props.colorOnSelectedState === theme.semanticColors.buttonBackground ? '0.6' : '',
43
56
  },
44
57
  _a),
45
- width: '12px',
46
- height: isLineLegendInBarChart ? '4px' : '12px',
58
+ width: "".concat(LEGEND_SHAPE_SIZE_WITHOUT_BORDER, "px"),
59
+ height: isLineLegendInBarChart ? '4px' : "".concat(LEGEND_SHAPE_SIZE_WITHOUT_BORDER, "px"),
47
60
  backgroundColor: props.stripePattern ? '' : props.colorOnSelectedState,
48
- marginRight: '8px',
49
- border: '1px solid',
61
+ marginRight: "".concat(LEGEND_SHAPE_MARGIN_END, "px"),
62
+ border: "".concat(LEGEND_SHAPE_BORDER, "px solid"),
50
63
  borderColor: props.borderColor ? props.borderColor : theme === null || theme === void 0 ? void 0 : theme.semanticColors.buttonBorder,
51
64
  content: props.stripePattern
52
65
  ? // eslint-disable-next-line @fluentui/max-len
@@ -55,7 +68,7 @@ export var getStyles = function (props) {
55
68
  },
56
69
  shape: [
57
70
  {
58
- marginRight: '8px',
71
+ marginRight: "".concat(LEGEND_SHAPE_MARGIN_END, "px"),
59
72
  },
60
73
  ],
61
74
  triangle: {
@@ -81,7 +94,7 @@ export var getStyles = function (props) {
81
94
  },
82
95
  _b),
83
96
  },
84
- text: __assign(__assign({}, fonts.small), { lineHeight: '16px', color: theme === null || theme === void 0 ? void 0 : theme.semanticColors.bodyText, opacity: props.colorOnSelectedState === theme.semanticColors.buttonBackground ? '0.67' : '' }),
97
+ text: __assign(__assign({}, fonts.small), { lineHeight: '16px', color: theme === null || theme === void 0 ? void 0 : theme.semanticColors.bodyText, opacity: props.colorOnSelectedState === theme.semanticColors.buttonBackground ? "".concat(INACTIVE_LEGEND_TEXT_OPACITY) : '' }),
85
98
  hoverChange: {
86
99
  width: '12px',
87
100
  height: '12px',
@@ -92,7 +105,7 @@ export var getStyles = function (props) {
92
105
  },
93
106
  overflowIndicationTextStyle: [
94
107
  getFocusStyle(theme, options),
95
- __assign(__assign({ cursor: 'pointer', color: theme === null || theme === void 0 ? void 0 : theme.semanticColors.bodyText }, fonts.small), { lineHeight: '16px', padding: '8px' }),
108
+ __assign(__assign({ cursor: 'pointer', color: theme === null || theme === void 0 ? void 0 : theme.semanticColors.bodyText }, fonts.small), { lineHeight: '16px', padding: "".concat(LEGEND_PADDING, "px") }),
96
109
  ],
97
110
  hoverCardRoot: {
98
111
  padding: '8px',
@@ -1 +1 @@
1
- {"version":3,"file":"Legends.styles.js","sourceRoot":"../src/","sources":["components/Legends/Legends.styles.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAkC,MAAM,6BAA6B,CAAC;AAElH,MAAM,CAAC,IAAM,SAAS,GAAG,UAAC,KAAwB;;IACxC,IAAA,SAAS,GAA4C,KAAK,UAAjD,EAAE,KAAK,GAAqC,KAAK,MAA1C,EAAE,KAAmC,KAAK,uBAAV,EAA9B,sBAAsB,mBAAG,KAAK,KAAA,CAAW;IAC7D,IAAA,KAAqB,KAAM,EAAzB,OAAO,aAAA,EAAE,KAAK,WAAW,CAAC;IAClC,IAAM,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YACd,eAAe,EAAE,KAAM,CAAC,cAAc,CAAC,gBAAgB;YACvD,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,WAAW;YACnB,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK;SACnE;QACD,2BAA2B,EAAE;YAC3B,aAAa,CAAC,KAAM,EAAE,OAAO,CAAC;gCAE5B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAC,QAAQ,IAClC,KAAK,CAAC,KAAK,KACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,KAAK;SAEjB;QACD,aAAa,EAAE;YACb,OAAO,EAAE,KAAK;SACf;QACD,kBAAkB,EAAE;YAClB,eAAe,EAAE;gBACf,IAAI,EAAE,CAAC,aAAa,CAAC,KAAM,EAAE,OAAO,CAAC,CAAC;aACvC;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { ILegendsStyles, ILegendStyleProps } from './Legends.types';\nimport { HighContrastSelector, getFocusStyle, IGetFocusStylesOptions, IStyle } from '@fluentui/react/lib/Styling';\n\nexport const getStyles = (props: ILegendStyleProps): ILegendsStyles => {\n const { className, theme, isLineLegendInBarChart = false } = props;\n const { palette, fonts } = theme!;\n const options: IGetFocusStylesOptions = {\n inset: undefined,\n position: undefined,\n highContrastStyle: {\n outlineColor: theme!.semanticColors.focusBorder,\n },\n borderColor: 'transparent',\n outlineColor: undefined,\n };\n return {\n root: [\n {\n whiteSpace: 'nowrap',\n width: '100%',\n alignItems: 'center',\n margin: '-8px 0 0 -8px',\n },\n className,\n ],\n legend: [\n getFocusStyle(theme!, options),\n {\n display: 'flex',\n alignItems: 'center',\n cursor: 'pointer',\n border: 'none',\n padding: '8px',\n background: 'none',\n textTransform: 'capitalize',\n },\n ],\n rect: {\n selectors: {\n [HighContrastSelector]: {\n content: `linear-gradient(to right, ${props.colorOnSelectedState}, ${props.colorOnSelectedState})`,\n opacity: props.colorOnSelectedState === theme!.semanticColors.buttonBackground ? '0.6' : '',\n },\n },\n width: '12px',\n height: isLineLegendInBarChart ? '4px' : '12px',\n backgroundColor: props.stripePattern ? '' : props.colorOnSelectedState,\n marginRight: '8px',\n border: '1px solid',\n borderColor: props.borderColor ? props.borderColor : theme?.semanticColors.buttonBorder,\n content: props.stripePattern\n ? // eslint-disable-next-line @fluentui/max-len\n `repeating-linear-gradient(135deg, transparent, transparent 3px, ${props.colorOnSelectedState} 1px, ${props.colorOnSelectedState} 4px)`\n : '',\n },\n shape: [\n {\n marginRight: '8px',\n },\n ],\n triangle: {\n width: '0',\n height: '0',\n borderLeft: '6px solid transparent',\n borderRight: '6px solid transparent',\n borderTop: '10.4px solid',\n borderTopColor: props.colorOnSelectedState,\n marginRight: '8px',\n opacity:\n props.colorOnSelectedState === theme!.semanticColors.buttonBackground\n ? '0.6'\n : props.opacity\n ? props.opacity\n : '',\n selectors: {\n [HighContrastSelector]: {\n border: '0px',\n height: '10.4px',\n width: '10.4px',\n clipPath: 'polygon(50% 100%, 0 0, 100% 0)',\n backgroundImage: `linear-gradient(to right, ${props.colorOnSelectedState}, ${props.colorOnSelectedState})`,\n } as IStyle,\n },\n },\n text: {\n ...fonts.small,\n lineHeight: '16px',\n color: theme?.semanticColors.bodyText,\n opacity: props.colorOnSelectedState === theme!.semanticColors.buttonBackground ? '0.67' : '',\n },\n hoverChange: {\n width: '12px',\n height: '12px',\n backgroundColor: theme!.semanticColors.buttonBackground,\n marginRight: '8px',\n border: '1px solid',\n borderColor: props.borderColor ? props.borderColor : palette.black,\n },\n overflowIndicationTextStyle: [\n getFocusStyle(theme!, options),\n {\n cursor: 'pointer',\n color: theme?.semanticColors.bodyText,\n ...fonts.small,\n lineHeight: '16px',\n padding: '8px',\n },\n ],\n hoverCardRoot: {\n padding: '8px',\n },\n subComponentStyles: {\n hoverCardStyles: {\n host: [getFocusStyle(theme!, options)],\n },\n },\n };\n};\n"]}
1
+ {"version":3,"file":"Legends.styles.js","sourceRoot":"../src/","sources":["components/Legends/Legends.styles.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAkC,MAAM,6BAA6B,CAAC;AAElH,gEAAgE;AAChE,MAAM,CAAC,IAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,IAAM,6BAA6B,GAAG,EAAE,CAAC;AAChD,MAAM,CAAC,IAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,IAAM,aAAa,GAAG,EAAE,CAAC;AAChC,MAAM,CAAC,IAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,IAAM,gCAAgC,GAAG,EAAE,CAAC;AAC5C,iGAAiG;AACjG,uGAAuG;AACvG,gCAAgC;AAChC,MAAM,CAAC,IAAM,iBAAiB,GAAG,gCAAgC,GAAG,mBAAmB,CAAC;AACxF,MAAM,CAAC,IAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,MAAM,CAAC,IAAM,4BAA4B,GAAG,IAAI,CAAC;AAEjD,MAAM,CAAC,IAAM,SAAS,GAAG,UAAC,KAAwB;;IACxC,IAAA,SAAS,GAA4C,KAAK,UAAjD,EAAE,KAAK,GAAqC,KAAK,MAA1C,EAAE,KAAmC,KAAK,uBAAV,EAA9B,sBAAsB,mBAAG,KAAK,KAAA,CAAW;IAC7D,IAAA,KAAqB,KAAM,EAAzB,OAAO,aAAA,EAAE,KAAK,WAAW,CAAC;IAClC,IAAM,OAAO,GAA2B;QACtC,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,SAAS;QACnB,iBAAiB,EAAE;YACjB,YAAY,EAAE,KAAM,CAAC,cAAc,CAAC,WAAW;SAChD;QACD,WAAW,EAAE,aAAa;QAC1B,YAAY,EAAE,SAAS;KACxB,CAAC;IACF,OAAO;QACL,IAAI,EAAE;YACJ;gBACE,UAAU,EAAE,QAAQ;gBACpB,KAAK,EAAE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AC,CAAC,CAAC,OAAO,CAAC,KAAK;SACnE;QACD,2BAA2B,EAAE;YAC3B,aAAa,CAAC,KAAM,EAAE,OAAO,CAAC;gCAE5B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAC,QAAQ,IAClC,KAAK,CAAC,KAAK,KACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,UAAG,cAAc,OAAI;SAEjC;QACD,aAAa,EAAE;YACb,OAAO,EAAE,KAAK;SACf;QACD,kBAAkB,EAAE;YAClB,eAAe,EAAE;gBACf,IAAI,EAAE,CAAC,aAAa,CAAC,KAAM,EAAE,OAAO,CAAC,CAAC;aACvC;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { ILegendsStyles, ILegendStyleProps } from './Legends.types';\nimport { HighContrastSelector, getFocusStyle, IGetFocusStylesOptions, IStyle } from '@fluentui/react/lib/Styling';\n\n// Constants needed to create legends using SVG for image export\nexport const LEGEND_CONTAINER_MARGIN_TOP = 8;\nexport const LEGEND_CONTAINER_MARGIN_START = 12;\nexport const LEGEND_PADDING = 8;\nexport const LEGEND_HEIGHT = 32;\nexport const LEGEND_SHAPE_BORDER = 1;\nconst LEGEND_SHAPE_SIZE_WITHOUT_BORDER = 12;\n// SVG strokes are drawn centered around the path, with half of the stroke width extending inward\n// (overlapping the fill area) and half outward. To ensure the filled area maintains its intended size,\n// expand the shape accordingly.\nexport const LEGEND_SHAPE_SIZE = LEGEND_SHAPE_SIZE_WITHOUT_BORDER + LEGEND_SHAPE_BORDER;\nexport const LEGEND_SHAPE_MARGIN_END = 8;\nexport const INACTIVE_LEGEND_TEXT_OPACITY = 0.67;\n\nexport const getStyles = (props: ILegendStyleProps): ILegendsStyles => {\n const { className, theme, isLineLegendInBarChart = false } = props;\n const { palette, fonts } = theme!;\n const options: IGetFocusStylesOptions = {\n inset: undefined,\n position: undefined,\n highContrastStyle: {\n outlineColor: theme!.semanticColors.focusBorder,\n },\n borderColor: 'transparent',\n outlineColor: undefined,\n };\n return {\n root: [\n {\n whiteSpace: 'nowrap',\n width: '100%',\n alignItems: 'center',\n margin: '-8px 0 0 -8px',\n },\n className,\n ],\n legend: [\n getFocusStyle(theme!, options),\n {\n display: 'flex',\n alignItems: 'center',\n cursor: 'pointer',\n border: 'none',\n padding: `${LEGEND_PADDING}px`,\n background: 'none',\n textTransform: 'capitalize',\n },\n ],\n rect: {\n selectors: {\n [HighContrastSelector]: {\n content: `linear-gradient(to right, ${props.colorOnSelectedState}, ${props.colorOnSelectedState})`,\n opacity: props.colorOnSelectedState === theme!.semanticColors.buttonBackground ? '0.6' : '',\n },\n },\n width: `${LEGEND_SHAPE_SIZE_WITHOUT_BORDER}px`,\n height: isLineLegendInBarChart ? '4px' : `${LEGEND_SHAPE_SIZE_WITHOUT_BORDER}px`,\n backgroundColor: props.stripePattern ? '' : props.colorOnSelectedState,\n marginRight: `${LEGEND_SHAPE_MARGIN_END}px`,\n border: `${LEGEND_SHAPE_BORDER}px solid`,\n borderColor: props.borderColor ? props.borderColor : theme?.semanticColors.buttonBorder,\n content: props.stripePattern\n ? // eslint-disable-next-line @fluentui/max-len\n `repeating-linear-gradient(135deg, transparent, transparent 3px, ${props.colorOnSelectedState} 1px, ${props.colorOnSelectedState} 4px)`\n : '',\n },\n shape: [\n {\n marginRight: `${LEGEND_SHAPE_MARGIN_END}px`,\n },\n ],\n triangle: {\n width: '0',\n height: '0',\n borderLeft: '6px solid transparent',\n borderRight: '6px solid transparent',\n borderTop: '10.4px solid',\n borderTopColor: props.colorOnSelectedState,\n marginRight: '8px',\n opacity:\n props.colorOnSelectedState === theme!.semanticColors.buttonBackground\n ? '0.6'\n : props.opacity\n ? props.opacity\n : '',\n selectors: {\n [HighContrastSelector]: {\n border: '0px',\n height: '10.4px',\n width: '10.4px',\n clipPath: 'polygon(50% 100%, 0 0, 100% 0)',\n backgroundImage: `linear-gradient(to right, ${props.colorOnSelectedState}, ${props.colorOnSelectedState})`,\n } as IStyle,\n },\n },\n text: {\n ...fonts.small,\n lineHeight: '16px',\n color: theme?.semanticColors.bodyText,\n opacity:\n props.colorOnSelectedState === theme!.semanticColors.buttonBackground ? `${INACTIVE_LEGEND_TEXT_OPACITY}` : '',\n },\n hoverChange: {\n width: '12px',\n height: '12px',\n backgroundColor: theme!.semanticColors.buttonBackground,\n marginRight: '8px',\n border: '1px solid',\n borderColor: props.borderColor ? props.borderColor : palette.black,\n },\n overflowIndicationTextStyle: [\n getFocusStyle(theme!, options),\n {\n cursor: 'pointer',\n color: theme?.semanticColors.bodyText,\n ...fonts.small,\n lineHeight: '16px',\n padding: `${LEGEND_PADDING}px`,\n },\n ],\n hoverCardRoot: {\n padding: '8px',\n },\n subComponentStyles: {\n hoverCardStyles: {\n host: [getFocusStyle(theme!, options)],\n },\n },\n };\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { ITheme, IStyle } from '@fluentui/react/lib/Styling';
3
- import { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
3
+ import { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
4
4
  import { IHoverCardStyleProps, IHoverCardStyles } from '@fluentui/react/lib/HoverCard';
5
5
  import { IOverflowSetProps } from '@fluentui/react/lib/OverflowSet';
6
6
  import { IFocusZoneProps } from '@fluentui/react-focus';
@@ -234,6 +234,10 @@ export interface ILegendsProps {
234
234
  * The shape for the legend.
235
235
  */
236
236
  shape?: LegendShape;
237
+ /**
238
+ * Callback to access the public methods and properties of the component.
239
+ */
240
+ ref?: IRefObject<ILegendContainer>;
237
241
  }
238
242
  /**
239
243
  * @public
@@ -243,3 +247,13 @@ export interface ILegendsProps {
243
247
  * {@docCategory Legends}
244
248
  */
245
249
  export type LegendShape = 'default' | 'triangle' | keyof typeof Points | keyof typeof CustomPoints;
250
+ /**
251
+ * {@docCategory Legends}
252
+ */
253
+ export interface ILegendContainer {
254
+ toSVG: (svgWidth: number, isRTL?: boolean) => {
255
+ node: SVGGElement | null;
256
+ width: number;
257
+ height: number;
258
+ };
259
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"Legends.types.js","sourceRoot":"../src/","sources":["components/Legends/Legends.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { IHoverCardStyleProps, IHoverCardStyles } from '@fluentui/react/lib/HoverCard';\nimport { IOverflowSetProps } from '@fluentui/react/lib/OverflowSet';\nimport { IFocusZoneProps } from '@fluentui/react-focus';\nimport { CustomPoints, Points } from '../../utilities/utilities';\n\nexport interface ILegendOverflowData {\n primary: ILegend[];\n\n overflow?: ILegend[];\n}\n\n/**\n * @public\n * {@docCategory Legends}\n */\nexport interface ILegendSubComponentStyles {\n hoverCardStyles: IStyleFunctionOrObject<IHoverCardStyleProps, IHoverCardStyles>;\n}\n\n/**\n * @public\n * Legends styles\n * {@docCategory Legends}\n */\nexport interface ILegendsStyles {\n /**\n * Style set for the root of the legend component\n */\n root: IStyle;\n\n /**\n * Style set for Legend. This is a wrapping class for text of legend and the rectange box that represents a legend\n */\n legend: IStyle;\n\n /**\n * Style set for the rectangle that represents a legend\n */\n rect: IStyle;\n\n /**\n * styles set for the shape that represents a legend\n */\n shape: IStyle;\n\n /**\n * Style set for the triangle that represents a legend\n */\n triangle: IStyle;\n\n /**\n * Style for the legend text\n */\n text: IStyle;\n\n /**\n * Style for the legend text\n */\n hoverChange: IStyle;\n\n /**\n * Style for the text that indicates the no.of legends that are in hovercard due to lack of space\n */\n overflowIndicationTextStyle: IStyle;\n\n /**\n * Style for the overflow container\n */\n hoverCardRoot: IStyle;\n\n /**\n * sub component styles\n */\n subComponentStyles: ILegendSubComponentStyles;\n}\n\n/**\n * @public\n * ILegend interface\n * {@docCategory Legends}\n */\nexport interface ILegend {\n /**\n * Defines the title of the legend\n */\n title: string;\n\n /**\n * Defines the function that is executed on clicking this legend\n */\n action?: VoidFunction;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n hoverAction?: VoidFunction;\n\n /**\n * Defines the function that is executed upon moving the mouse away from the legend\n */\n onMouseOutAction?: (isLegendFocused?: boolean) => void;\n\n /**\n * The color for the legend\n */\n color: string;\n\n /**\n * The opacity of the legend color\n */\n opacity?: number;\n\n /**\n * The shape for the legend\n */\n shape?: LegendShape;\n\n /**\n * Indicated whether or not to apply stripe pattern\n */\n stripePattern?: boolean;\n\n /**\n * Indicates if the legend belongs to a line in the Bar Chart\n */\n isLineLegendInBarChart?: boolean;\n\n /*\n * native button props for the legend button\n */\n nativeButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n}\n\n/**\n * @public\n * Legend style properties\n * {@docCategory Legends}\n */\nexport interface ILegendStyleProps {\n theme?: ITheme;\n className?: string;\n colorOnSelectedState?: string;\n borderColor?: string;\n opacity?: number;\n overflow?: boolean;\n stripePattern?: boolean;\n isLineLegendInBarChart?: boolean;\n}\n\n/**\n * @public\n * Legend properties\n * {@docCategory Legends}\n */\nexport interface ILegendsProps {\n /**\n * Prop that takes list of legends\n */\n legends: ILegend[];\n\n /**\n * Additional CSS class(es) to apply to the legneds component.\n */\n className?: string;\n\n /**\n * Theme (provided through customization.)\n */\n theme?: ITheme;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<ILegendStyleProps, ILegendsStyles>;\n\n /**\n * This prop makes the legends component align itself to the center in the container it is sitting in\n */\n centerLegends?: boolean;\n\n /**\n * Enable the legends to wrap lines if there is not enough space to show all legends on a single line\n */\n enabledWrapLines?: boolean;\n\n /**\n * props for the overflow set component\n */\n overflowProps?: Partial<IOverflowSetProps>;\n\n /**\n * focus zone props in hover card\n */\n focusZonePropsInHoverCard?: IFocusZoneProps;\n\n /**\n * text for overflow legends string\n */\n overflowText?: string;\n\n /**\n * prop that decides if legends are focusable\n * @default true\n */\n allowFocusOnLegends?: boolean;\n\n /**\n * prop that decide if we can select multiple legends or single legend at a time\n * @default false\n */\n canSelectMultipleLegends?: boolean;\n\n /**\n * Defines the function that is executed upon hiding of hover card\n * make sure to send prop when the prop is canSelectMultipleLegends is set to true\n * and empty the selected state legends\n */\n onLegendHoverCardLeave?: VoidFunction;\n\n /**\n * Callback issued when the selected option changes.\n */\n onChange?: (selectedLegends: string[], event: React.MouseEvent<HTMLButtonElement>, currentLegend?: ILegend) => void;\n\n /**\n * Keys (title) that will be initially used to set selected items. This prop is used for multi-select scenarios when\n * canSelectMultipleLegends is true; for single-select, use defaultSelectedLegend.\n *\n * Updating this prop does not change the selection after the component has been initialized. For controlled\n * selections, use selectedLegends instead.\n *\n * @see selectedLegends for setting the selected legends in controlled mode.\n * @see defaultSelectedLegend for setting the initially selected legend when canSelectMultipleLegends is false.\n */\n defaultSelectedLegends?: string[];\n\n /**\n * Key that will be initially used to set selected item. This prop is used for single-select scenarios when\n * canSelectMultipleLegends is false or unspecified; for multi-select, use defaultSelectedLegends.\n *\n * Updating this prop does not change the selection after the component has been initialized. For controlled\n * selections, use selectedLegend instead.\n *\n * @see selectedLegend for setting the selected legend in controlled mode.\n * @see defaultSelectedLegends for setting the initially selected legends when canSelectMultipleLegends is true.\n */\n defaultSelectedLegend?: string;\n\n /**\n * Keys (title) that will be used to set selected items in multi-select scenarios when canSelectMultipleLegends is\n * true. For single-select, use selectedLegend.\n *\n * When this prop is provided, the component is controlled and does not automatically update the selection based on\n * user interactions; the parent component must update the value passed to this property by handling the onChange\n * event.\n *\n * @see defaultSelectedLegends for setting the initially-selected legends in uncontrolled mode.\n * @see selectedLegends for setting the selected legends when `canSelectMultipleLegends` is `true`.\n */\n selectedLegends?: string[];\n\n /**\n * Key (title) that will be used to set the selected item in single-select scenarios when canSelectMultipleLegends is\n * false or unspecified. For multi-select, use selectedLegends.\n *\n * When this prop is provided, the component is controlled and does not automatically update the selection based on\n * user interactions; the parent component must update the value passed to this property by handling the onChange\n * event.\n *\n * @see defaultSelectedLegend for setting the initially-selected legend in uncontrolled mode.\n * @see selectedLegend for setting the selected legend when `canSelectMultipleLegends` is `false`.\n */\n selectedLegend?: string;\n\n /**\n * The shape for the legend.\n */\n shape?: LegendShape;\n}\n\n/**\n * @public\n * The shape for the legend\n * default: show the rect legend\n * triangle: show the triangle legend\n * {@docCategory Legends}\n */\nexport type LegendShape = 'default' | 'triangle' | keyof typeof Points | keyof typeof CustomPoints;\n"]}
1
+ {"version":3,"file":"Legends.types.js","sourceRoot":"../src/","sources":["components/Legends/Legends.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { IHoverCardStyleProps, IHoverCardStyles } from '@fluentui/react/lib/HoverCard';\nimport { IOverflowSetProps } from '@fluentui/react/lib/OverflowSet';\nimport { IFocusZoneProps } from '@fluentui/react-focus';\nimport { CustomPoints, Points } from '../../utilities/utilities';\n\nexport interface ILegendOverflowData {\n primary: ILegend[];\n\n overflow?: ILegend[];\n}\n\n/**\n * @public\n * {@docCategory Legends}\n */\nexport interface ILegendSubComponentStyles {\n hoverCardStyles: IStyleFunctionOrObject<IHoverCardStyleProps, IHoverCardStyles>;\n}\n\n/**\n * @public\n * Legends styles\n * {@docCategory Legends}\n */\nexport interface ILegendsStyles {\n /**\n * Style set for the root of the legend component\n */\n root: IStyle;\n\n /**\n * Style set for Legend. This is a wrapping class for text of legend and the rectange box that represents a legend\n */\n legend: IStyle;\n\n /**\n * Style set for the rectangle that represents a legend\n */\n rect: IStyle;\n\n /**\n * styles set for the shape that represents a legend\n */\n shape: IStyle;\n\n /**\n * Style set for the triangle that represents a legend\n */\n triangle: IStyle;\n\n /**\n * Style for the legend text\n */\n text: IStyle;\n\n /**\n * Style for the legend text\n */\n hoverChange: IStyle;\n\n /**\n * Style for the text that indicates the no.of legends that are in hovercard due to lack of space\n */\n overflowIndicationTextStyle: IStyle;\n\n /**\n * Style for the overflow container\n */\n hoverCardRoot: IStyle;\n\n /**\n * sub component styles\n */\n subComponentStyles: ILegendSubComponentStyles;\n}\n\n/**\n * @public\n * ILegend interface\n * {@docCategory Legends}\n */\nexport interface ILegend {\n /**\n * Defines the title of the legend\n */\n title: string;\n\n /**\n * Defines the function that is executed on clicking this legend\n */\n action?: VoidFunction;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n hoverAction?: VoidFunction;\n\n /**\n * Defines the function that is executed upon moving the mouse away from the legend\n */\n onMouseOutAction?: (isLegendFocused?: boolean) => void;\n\n /**\n * The color for the legend\n */\n color: string;\n\n /**\n * The opacity of the legend color\n */\n opacity?: number;\n\n /**\n * The shape for the legend\n */\n shape?: LegendShape;\n\n /**\n * Indicated whether or not to apply stripe pattern\n */\n stripePattern?: boolean;\n\n /**\n * Indicates if the legend belongs to a line in the Bar Chart\n */\n isLineLegendInBarChart?: boolean;\n\n /*\n * native button props for the legend button\n */\n nativeButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n}\n\n/**\n * @public\n * Legend style properties\n * {@docCategory Legends}\n */\nexport interface ILegendStyleProps {\n theme?: ITheme;\n className?: string;\n colorOnSelectedState?: string;\n borderColor?: string;\n opacity?: number;\n overflow?: boolean;\n stripePattern?: boolean;\n isLineLegendInBarChart?: boolean;\n}\n\n/**\n * @public\n * Legend properties\n * {@docCategory Legends}\n */\nexport interface ILegendsProps {\n /**\n * Prop that takes list of legends\n */\n legends: ILegend[];\n\n /**\n * Additional CSS class(es) to apply to the legneds component.\n */\n className?: string;\n\n /**\n * Theme (provided through customization.)\n */\n theme?: ITheme;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<ILegendStyleProps, ILegendsStyles>;\n\n /**\n * This prop makes the legends component align itself to the center in the container it is sitting in\n */\n centerLegends?: boolean;\n\n /**\n * Enable the legends to wrap lines if there is not enough space to show all legends on a single line\n */\n enabledWrapLines?: boolean;\n\n /**\n * props for the overflow set component\n */\n overflowProps?: Partial<IOverflowSetProps>;\n\n /**\n * focus zone props in hover card\n */\n focusZonePropsInHoverCard?: IFocusZoneProps;\n\n /**\n * text for overflow legends string\n */\n overflowText?: string;\n\n /**\n * prop that decides if legends are focusable\n * @default true\n */\n allowFocusOnLegends?: boolean;\n\n /**\n * prop that decide if we can select multiple legends or single legend at a time\n * @default false\n */\n canSelectMultipleLegends?: boolean;\n\n /**\n * Defines the function that is executed upon hiding of hover card\n * make sure to send prop when the prop is canSelectMultipleLegends is set to true\n * and empty the selected state legends\n */\n onLegendHoverCardLeave?: VoidFunction;\n\n /**\n * Callback issued when the selected option changes.\n */\n onChange?: (selectedLegends: string[], event: React.MouseEvent<HTMLButtonElement>, currentLegend?: ILegend) => void;\n\n /**\n * Keys (title) that will be initially used to set selected items. This prop is used for multi-select scenarios when\n * canSelectMultipleLegends is true; for single-select, use defaultSelectedLegend.\n *\n * Updating this prop does not change the selection after the component has been initialized. For controlled\n * selections, use selectedLegends instead.\n *\n * @see selectedLegends for setting the selected legends in controlled mode.\n * @see defaultSelectedLegend for setting the initially selected legend when canSelectMultipleLegends is false.\n */\n defaultSelectedLegends?: string[];\n\n /**\n * Key that will be initially used to set selected item. This prop is used for single-select scenarios when\n * canSelectMultipleLegends is false or unspecified; for multi-select, use defaultSelectedLegends.\n *\n * Updating this prop does not change the selection after the component has been initialized. For controlled\n * selections, use selectedLegend instead.\n *\n * @see selectedLegend for setting the selected legend in controlled mode.\n * @see defaultSelectedLegends for setting the initially selected legends when canSelectMultipleLegends is true.\n */\n defaultSelectedLegend?: string;\n\n /**\n * Keys (title) that will be used to set selected items in multi-select scenarios when canSelectMultipleLegends is\n * true. For single-select, use selectedLegend.\n *\n * When this prop is provided, the component is controlled and does not automatically update the selection based on\n * user interactions; the parent component must update the value passed to this property by handling the onChange\n * event.\n *\n * @see defaultSelectedLegends for setting the initially-selected legends in uncontrolled mode.\n * @see selectedLegends for setting the selected legends when `canSelectMultipleLegends` is `true`.\n */\n selectedLegends?: string[];\n\n /**\n * Key (title) that will be used to set the selected item in single-select scenarios when canSelectMultipleLegends is\n * false or unspecified. For multi-select, use selectedLegends.\n *\n * When this prop is provided, the component is controlled and does not automatically update the selection based on\n * user interactions; the parent component must update the value passed to this property by handling the onChange\n * event.\n *\n * @see defaultSelectedLegend for setting the initially-selected legend in uncontrolled mode.\n * @see selectedLegend for setting the selected legend when `canSelectMultipleLegends` is `false`.\n */\n selectedLegend?: string;\n\n /**\n * The shape for the legend.\n */\n shape?: LegendShape;\n\n /**\n * Callback to access the public methods and properties of the component.\n */\n ref?: IRefObject<ILegendContainer>;\n}\n\n/**\n * @public\n * The shape for the legend\n * default: show the rect legend\n * triangle: show the triangle legend\n * {@docCategory Legends}\n */\nexport type LegendShape = 'default' | 'triangle' | keyof typeof Points | keyof typeof CustomPoints;\n\n/**\n * {@docCategory Legends}\n */\nexport interface ILegendContainer {\n toSVG: (\n svgWidth: number,\n isRTL?: boolean,\n ) => {\n node: SVGGElement | null;\n width: number;\n height: number;\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { IAccessibilityProps, IBasestate, ILineChartProps, ILineChartPoints, ICustomizedCalloutData, IColorFillBarsProps, ILineChartDataPoint } from '../../index';
3
- import { IChart } from '../../types/index';
3
+ import { IChart, IImageExportOptions } from '../../types/index';
4
4
  type LineChartDataWithIndex = ILineChartPoints & {
5
5
  index: number;
6
6
  };
@@ -41,13 +41,21 @@ export declare class LineChartBase extends React.Component<ILineChartProps, ILin
41
41
  private _emptyChartId;
42
42
  private _isRTL;
43
43
  private _cartesianChartRef;
44
+ private _legendsRef;
45
+ private _xMin;
46
+ private _yMin;
47
+ private _xMax;
48
+ private _xPadding;
49
+ private _yPadding;
44
50
  constructor(props: ILineChartProps);
45
51
  componentDidUpdate(prevProps: ILineChartProps): void;
46
52
  render(): JSX.Element;
47
53
  get chartContainer(): HTMLElement | null;
54
+ toImage: (opts?: IImageExportOptions) => Promise<string>;
48
55
  private _getDomainNRangeValues;
49
56
  private _injectIndexPropertyInLineChartData;
50
57
  private _getCustomizedCallout;
58
+ private _getNumericMinMaxOfY;
51
59
  private _getMargins;
52
60
  private _initializeLineChartData;
53
61
  private _handleSingleLegendSelectionAction;
@@ -57,6 +65,7 @@ export declare class LineChartBase extends React.Component<ILineChartProps, ILin
57
65
  private _getBoxWidthOfShape;
58
66
  private _getPath;
59
67
  private _getPointFill;
68
+ private _getRangeForScatterMarkerSize;
60
69
  private _createLines;
61
70
  private _createColorFillBars;
62
71
  private _getStripePattern;
@@ -89,6 +98,7 @@ export declare class LineChartBase extends React.Component<ILineChartProps, ILin
89
98
  private _noLegendHighlighted;
90
99
  private _getColorFillBarOpacity;
91
100
  private _getAriaLabel;
101
+ private _getDomainNRangeValuesWithPadding;
92
102
  private _isChartEmpty;
93
103
  private _getChartTitle;
94
104
  }
@@ -4,11 +4,13 @@ import { select as d3Select, pointer } from 'd3-selection';
4
4
  import { bisector } from 'd3-array';
5
5
  import { Legends } from '../Legends/index';
6
6
  import { line as d3Line, curveLinear as d3curveLinear } from 'd3-shape';
7
+ import { max as d3Max, min as d3Min } from 'd3-array';
7
8
  import { classNamesFunction, getId, find, memoizeFunction, getRTL, initializeComponentRef, } from '@fluentui/react/lib/Utilities';
8
9
  import { CartesianChart, } from '../../index';
9
10
  import { DirectionalHint } from '@fluentui/react/lib/Callout';
10
11
  import { EventsAnnotation } from './eventAnnotation/EventAnnotation';
11
12
  import { calloutData, ChartTypes, getXAxisType, XAxisTypes, tooltipOfXAxislabels, Points, pointTypes, getTypeOfAxis, getNextColor, getColorFromToken, findNumericMinMaxOfY, createNumericYAxis, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfNumericForAreaChart, createStringYAxis, formatDate, areArraysEqual, } from '../../utilities/index';
13
+ import { toImage } from '../../utilities/image-export-utils';
12
14
  var getClassNames = classNamesFunction();
13
15
  var PointSize;
14
16
  (function (PointSize) {
@@ -59,9 +61,21 @@ var LineChartBase = /** @class */ (function (_super) {
59
61
  _this_1._yAxisScale = '';
60
62
  _this_1.eventLabelHeight = 36;
61
63
  _this_1._isRTL = getRTL();
64
+ _this_1._xMin = Number.NEGATIVE_INFINITY;
65
+ _this_1._yMin = Number.NEGATIVE_INFINITY;
66
+ _this_1._xMax = Number.POSITIVE_INFINITY;
67
+ _this_1._xPadding = 0;
68
+ _this_1._yPadding = 0;
69
+ _this_1.toImage = function (opts) {
70
+ var _a, _b;
71
+ return toImage((_a = _this_1._cartesianChartRef.current) === null || _a === void 0 ? void 0 : _a.chartContainer, (_b = _this_1._legendsRef.current) === null || _b === void 0 ? void 0 : _b.toSVG, _this_1._isRTL, opts);
72
+ };
62
73
  _this_1._getDomainNRangeValues = function (points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shiftX) {
63
74
  var domainNRangeValue;
64
- if (xAxisType === XAxisTypes.NumericAxis) {
75
+ if (_this_1.props.lineMode === 'scatter' && xAxisType === XAxisTypes.NumericAxis) {
76
+ domainNRangeValue = _this_1._getDomainNRangeValuesWithPadding(points, margins, width, isRTL);
77
+ }
78
+ else if (xAxisType === XAxisTypes.NumericAxis) {
65
79
  domainNRangeValue = domainRangeOfNumericForAreaChart(points, margins, width, isRTL);
66
80
  }
67
81
  else if (xAxisType === XAxisTypes.DateAxis) {
@@ -105,6 +119,18 @@ var LineChartBase = /** @class */ (function (_super) {
105
119
  ? _this_1.props.onRenderCalloutPerDataPoint(_this_1.state.dataPointCalloutProps)
106
120
  : null;
107
121
  };
122
+ _this_1._getNumericMinMaxOfY = function (points) {
123
+ // eslint-disable-next-line @typescript-eslint/no-shadow
124
+ var _a = findNumericMinMaxOfY(points), startValue = _a.startValue, endValue = _a.endValue;
125
+ _this_1._yMin = startValue;
126
+ if (_this_1.props.lineMode === 'scatter') {
127
+ _this_1._yPadding = (endValue - startValue) * 0.1;
128
+ }
129
+ return {
130
+ startValue: startValue - _this_1._yPadding,
131
+ endValue: endValue + _this_1._yPadding,
132
+ };
133
+ };
108
134
  _this_1._getMargins = function (margins) {
109
135
  _this_1.margins = margins;
110
136
  };
@@ -548,6 +574,34 @@ var LineChartBase = /** @class */ (function (_super) {
548
574
  var yValue = point.yAxisCalloutData || point.y;
549
575
  return ((_a = point.callOutAccessibilityData) === null || _a === void 0 ? void 0 : _a.ariaLabel) || "".concat(xValue, ". ").concat(legend, ", ").concat(yValue, ".");
550
576
  };
577
+ _this_1._getDomainNRangeValuesWithPadding = function (points, margins, width, isRTL) {
578
+ _this_1._xMin = d3Min(points, function (point) {
579
+ return d3Min(point.data, function (item) { return item.x; });
580
+ });
581
+ _this_1._xMax = d3Max(points, function (point) {
582
+ return d3Max(point.data, function (item) {
583
+ return item.x;
584
+ });
585
+ });
586
+ if (_this_1.props.lineMode === 'scatter') {
587
+ _this_1._xPadding = (_this_1._xMax - _this_1._xMin) * 0.1;
588
+ }
589
+ var rStartValue = margins.left;
590
+ var rEndValue = width - margins.right;
591
+ return isRTL
592
+ ? {
593
+ dStartValue: _this_1._xMax + _this_1._xPadding,
594
+ dEndValue: _this_1._xMin - _this_1._xPadding,
595
+ rStartValue: rStartValue,
596
+ rEndValue: rEndValue,
597
+ }
598
+ : {
599
+ dStartValue: _this_1._xMin - _this_1._xPadding,
600
+ dEndValue: _this_1._xMax + _this_1._xPadding,
601
+ rStartValue: rStartValue,
602
+ rEndValue: rEndValue,
603
+ };
604
+ };
551
605
  _this_1._getChartTitle = function () {
552
606
  var _a = _this_1.props.data, chartTitle = _a.chartTitle, lineChartData = _a.lineChartData;
553
607
  return (chartTitle ? "".concat(chartTitle, ". ") : '') + "Line chart with ".concat((lineChartData === null || lineChartData === void 0 ? void 0 : lineChartData.length) || 0, " lines. ");
@@ -583,6 +637,7 @@ var LineChartBase = /** @class */ (function (_super) {
583
637
  _this_1._firstRenderOptimization = true;
584
638
  _this_1._emptyChartId = getId('_LineChart_empty');
585
639
  _this_1._cartesianChartRef = React.createRef();
640
+ _this_1._legendsRef = React.createRef();
586
641
  props.eventAnnotationProps &&
587
642
  props.eventAnnotationProps.labelHeight &&
588
643
  (_this_1.eventLabelHeight = props.eventAnnotationProps.labelHeight);
@@ -632,7 +687,7 @@ var LineChartBase = /** @class */ (function (_super) {
632
687
  tickValues: tickValues,
633
688
  tickFormat: tickFormat,
634
689
  };
635
- return !this._isChartEmpty() ? (React.createElement(CartesianChart, __assign({}, this.props, { chartTitle: this._getChartTitle(), points: points, chartType: ChartTypes.LineChart, isCalloutForStack: true, calloutProps: calloutProps, tickParams: tickParams, legendBars: legendBars, createYAxis: createNumericYAxis, getmargins: this._getMargins, getMinMaxOfYAxis: findNumericMinMaxOfY, getGraphData: this._initializeLineChartData, xAxisType: isXAxisDateType ? XAxisTypes.DateAxis : XAxisTypes.NumericAxis, customizedCallout: this._getCustomizedCallout(), getDomainNRangeValues: this._getDomainNRangeValues, createStringYAxis: createStringYAxis, onChartMouseLeave: this._handleChartMouseLeave, enableFirstRenderOptimization: this.props.enablePerfOptimization && this._firstRenderOptimization, ref: this._cartesianChartRef,
690
+ return !this._isChartEmpty() ? (React.createElement(CartesianChart, __assign({}, this.props, { chartTitle: this._getChartTitle(), points: points, chartType: ChartTypes.LineChart, isCalloutForStack: true, calloutProps: calloutProps, tickParams: tickParams, legendBars: legendBars, createYAxis: createNumericYAxis, getmargins: this._getMargins, getMinMaxOfYAxis: this._getNumericMinMaxOfY, getGraphData: this._initializeLineChartData, xAxisType: isXAxisDateType ? XAxisTypes.DateAxis : XAxisTypes.NumericAxis, customizedCallout: this._getCustomizedCallout(), getDomainNRangeValues: this._getDomainNRangeValues, createStringYAxis: createStringYAxis, onChartMouseLeave: this._handleChartMouseLeave, enableFirstRenderOptimization: this.props.enablePerfOptimization && this._firstRenderOptimization, ref: this._cartesianChartRef,
636
691
  /* eslint-disable react/jsx-no-bind */
637
692
  // eslint-disable-next-line react/no-children-prop
638
693
  children: function (props) {
@@ -712,7 +767,14 @@ var LineChartBase = /** @class */ (function (_super) {
712
767
  return legend;
713
768
  })
714
769
  : [];
715
- return (React.createElement(Legends, __assign({ legends: __spreadArray(__spreadArray([], legendDataItems, true), colorFillBarsLegendDataItems, true), enabledWrapLines: this.props.enabledLegendsWrapLines, overflowProps: this.props.legendsOverflowProps, focusZonePropsInHoverCard: this.props.focusZonePropsForLegendsInHoverCard, overflowText: this.props.legendsOverflowText }, (isLegendMultiSelectEnabled && { onLegendHoverCardLeave: this._onHoverCardHide }), this.props.legendProps)));
770
+ return (React.createElement(Legends, __assign({ legends: __spreadArray(__spreadArray([], legendDataItems, true), colorFillBarsLegendDataItems, true), enabledWrapLines: this.props.enabledLegendsWrapLines, overflowProps: this.props.legendsOverflowProps, focusZonePropsInHoverCard: this.props.focusZonePropsForLegendsInHoverCard, overflowText: this.props.legendsOverflowText }, (isLegendMultiSelectEnabled && { onLegendHoverCardLeave: this._onHoverCardHide }), this.props.legendProps, { ref: this._legendsRef })));
771
+ };
772
+ LineChartBase.prototype._getRangeForScatterMarkerSize = function () {
773
+ var extraXPixels = this._isRTL
774
+ ? this._xAxisScale(this._xMax - this._xPadding) - this._xAxisScale(this._xMax)
775
+ : this._xAxisScale(this._xMin + this._xPadding) - this._xAxisScale(this._xMin);
776
+ var extraYPixels = this._yAxisScale(this._yMin) - this._yAxisScale(this._yMin + this._yPadding);
777
+ return Math.min(extraXPixels, extraYPixels);
716
778
  };
717
779
  LineChartBase.prototype._createLines = function (xElement, containerHeight) {
718
780
  var _this_1 = this;
@@ -724,6 +786,12 @@ var LineChartBase = /** @class */ (function (_super) {
724
786
  else {
725
787
  this._points = this._injectIndexPropertyInLineChartData(this.props.data.lineChartData);
726
788
  }
789
+ var extraMaxPixels = this.props.lineMode === 'scatter' ? this._getRangeForScatterMarkerSize() : 0;
790
+ var maxMarkerSize = d3Max(this._points, function (point) {
791
+ return d3Max(point.data, function (item) {
792
+ return item.markerSize;
793
+ });
794
+ });
727
795
  var _loop_1 = function (i) {
728
796
  var linesForLine = [];
729
797
  var bordersForLine = [];
@@ -737,7 +805,12 @@ var LineChartBase = /** @class */ (function (_super) {
737
805
  var _2 = this_1._points[i].data[0], x1_1 = _2.x, y1 = _2.y, xAxisCalloutData_1 = _2.xAxisCalloutData, xAxisCalloutAccessibilityData_1 = _2.xAxisCalloutAccessibilityData;
738
806
  var circleId_1 = "".concat(this_1._circleId, "_").concat(i);
739
807
  var isLegendSelected = this_1._legendHighlighted(legendVal) || this_1._noLegendHighlighted() || this_1.state.isSelectedLegend;
740
- pointsForLine.push(React.createElement("circle", __assign({ id: circleId_1, key: circleId_1, r: activePoint === circleId_1 ? 5.5 : 3.5, cx: this_1._xAxisScale(x1_1), cy: this_1._yAxisScale(y1), fill: activePoint === circleId_1 ? theme.semanticColors.bodyBackground : lineColor, opacity: isLegendSelected ? 1 : 0.1, onMouseOver: this_1._handleHover.bind(this_1, x1_1, y1, verticaLineHeight, xAxisCalloutData_1, circleId_1, xAxisCalloutAccessibilityData_1), onMouseMove: this_1._handleHover.bind(this_1, x1_1, y1, verticaLineHeight, xAxisCalloutData_1, circleId_1, xAxisCalloutAccessibilityData_1), onMouseOut: this_1._handleMouseOut, strokeWidth: activePoint === circleId_1 ? DEFAULT_LINE_STROKE_SIZE : 0, stroke: activePoint === circleId_1 ? lineColor : '', role: "img", "aria-label": this_1._getAriaLabel(i, 0), "data-is-focusable": isLegendSelected, ref: function (e) {
808
+ var currentMarkerSize = this_1._points[i].data[0].markerSize;
809
+ pointsForLine.push(React.createElement("circle", __assign({ id: circleId_1, key: circleId_1, r: currentMarkerSize
810
+ ? (currentMarkerSize * extraMaxPixels) / maxMarkerSize
811
+ : activePoint === circleId_1
812
+ ? 5.5
813
+ : 3.5, cx: this_1._xAxisScale(x1_1), cy: this_1._yAxisScale(y1), fill: activePoint === circleId_1 ? theme.semanticColors.bodyBackground : lineColor, opacity: isLegendSelected ? 1 : 0.1, onMouseOver: this_1._handleHover.bind(this_1, x1_1, y1, verticaLineHeight, xAxisCalloutData_1, circleId_1, xAxisCalloutAccessibilityData_1), onMouseMove: this_1._handleHover.bind(this_1, x1_1, y1, verticaLineHeight, xAxisCalloutData_1, circleId_1, xAxisCalloutAccessibilityData_1), onMouseOut: this_1._handleMouseOut, strokeWidth: activePoint === circleId_1 ? DEFAULT_LINE_STROKE_SIZE : 0, stroke: activePoint === circleId_1 ? lineColor : '', role: "img", "aria-label": this_1._getAriaLabel(i, 0), "data-is-focusable": isLegendSelected, ref: function (e) {
741
814
  _this_1._refCallback(e, circleId_1);
742
815
  }, onFocus: function () { return _this_1._handleFocus(circleId_1, x1_1, xAxisCalloutData_1, circleId_1, xAxisCalloutAccessibilityData_1); }, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[0].onDataPointClick))));
743
816
  }
@@ -793,7 +866,8 @@ var LineChartBase = /** @class */ (function (_super) {
793
866
  var strokeWidth = ((_p = this_1._points[i].lineOptions) === null || _p === void 0 ? void 0 : _p.strokeWidth) || this_1.props.strokeWidth || DEFAULT_LINE_STROKE_SIZE;
794
867
  var isLegendSelected = this_1._legendHighlighted(legendVal) || this_1._noLegendHighlighted() || this_1.state.isSelectedLegend;
795
868
  var currentPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== circleId;
796
- pointsForLine.push(React.createElement("path", __assign({ id: circleId, key: circleId, d: path, "data-is-focusable": isLegendSelected, onMouseOver: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this_1._handleMouseOut, onFocus: function () { return _this_1._handleFocus(lineId, x1, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData); }, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[j - 1].onDataPointClick), { opacity: isLegendSelected && !currentPointHidden ? 1 : 0.01, fill: this_1._getPointFill(lineColor, circleId, j, false), stroke: lineColor, strokeWidth: strokeWidth, role: "img", "aria-label": this_1._getAriaLabel(i, j - 1) })));
869
+ var currentMarkerSize = this_1._points[i].data[j - 1].markerSize;
870
+ pointsForLine.push(this_1.props.lineMode === 'scatter' ? (React.createElement("circle", __assign({ id: circleId, key: circleId, r: currentMarkerSize ? (currentMarkerSize * extraMaxPixels) / maxMarkerSize : 4, cx: this_1._xAxisScale(x1), cy: this_1._yAxisScale(y1), "data-is-focusable": isLegendSelected, onMouseOver: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this_1._handleMouseOut, onFocus: function () { return _this_1._handleFocus(lineId, x1, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData); }, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[j - 1].onDataPointClick), { opacity: isLegendSelected && !currentPointHidden ? 1 : 0.01, fill: this_1._getPointFill(lineColor, circleId, j, false), stroke: lineColor, strokeWidth: strokeWidth, role: "img", "aria-label": this_1._getAriaLabel(i, j - 1) }))) : (React.createElement("path", __assign({ id: circleId, key: circleId, d: path, "data-is-focusable": isLegendSelected, onMouseOver: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this_1._handleMouseOut, onFocus: function () { return _this_1._handleFocus(lineId, x1, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData); }, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[j - 1].onDataPointClick), { opacity: isLegendSelected && !currentPointHidden ? 1 : 0.01, fill: this_1._getPointFill(lineColor, circleId, j, false), stroke: lineColor, strokeWidth: strokeWidth, role: "img", "aria-label": this_1._getAriaLabel(i, j - 1) }))));
797
871
  if (j + 1 === this_1._points[i].data.length) {
798
872
  // If this is last point of the line segment.
799
873
  var lastCircleId_1 = "".concat(circleId).concat(j, "L");
@@ -801,30 +875,34 @@ var LineChartBase = /** @class */ (function (_super) {
801
875
  var lastPointHidden = this_1._points[i].hideNonActiveDots && activePoint !== lastCircleId_1;
802
876
  path = this_1._getPath(this_1._xAxisScale(x2), this_1._yAxisScale(y2), lastCircleId_1, j, true, this_1._points[i].index);
803
877
  var _5 = this_1._points[i].data[j], lastCirlceXCallout_1 = _5.xAxisCalloutData, lastCirlceXCalloutAccessibilityData_1 = _5.xAxisCalloutAccessibilityData;
878
+ currentMarkerSize = this_1._points[i].data[j].markerSize;
804
879
  pointsForLine.push(React.createElement(React.Fragment, { key: "".concat(lastCircleId_1, "_container") },
805
- React.createElement("path", __assign({ id: lastCircleId_1, key: lastCircleId_1, d: path, "data-is-focusable": isLegendSelected, onMouseOver: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseMove: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseOut: this_1._handleMouseOut, onFocus: function () {
880
+ this_1.props.lineMode === 'scatter' ? (React.createElement("circle", __assign({ id: lastCircleId_1, key: lastCircleId_1, r: currentMarkerSize ? (currentMarkerSize * extraMaxPixels) / maxMarkerSize : 4, cx: this_1._xAxisScale(x2), cy: this_1._yAxisScale(y2), "data-is-focusable": isLegendSelected, onMouseOver: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseMove: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseOut: this_1._handleMouseOut, onFocus: function () {
881
+ return _this_1._handleFocus(lineId, x2, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1);
882
+ }, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[j].onDataPointClick), { opacity: isLegendSelected && !lastPointHidden ? 1 : 0.01, fill: this_1._getPointFill(lineColor, lastCircleId_1, j, true), stroke: lineColor, strokeWidth: strokeWidth, role: "img", "aria-label": this_1._getAriaLabel(i, j) }))) : (React.createElement("path", __assign({ id: lastCircleId_1, key: lastCircleId_1, d: path, "data-is-focusable": isLegendSelected, onMouseOver: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseMove: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseOut: this_1._handleMouseOut, onFocus: function () {
806
883
  return _this_1._handleFocus(lineId, x2, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1);
807
- }, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[j].onDataPointClick), { opacity: isLegendSelected && !lastPointHidden ? 1 : 0.01, fill: this_1._getPointFill(lineColor, lastCircleId_1, j, true), stroke: lineColor, strokeWidth: strokeWidth, role: "img", "aria-label": this_1._getAriaLabel(i, j) })),
884
+ }, onBlur: this_1._handleMouseOut }, this_1._getClickHandler(this_1._points[i].data[j].onDataPointClick), { opacity: isLegendSelected && !lastPointHidden ? 1 : 0.01, fill: this_1._getPointFill(lineColor, lastCircleId_1, j, true), stroke: lineColor, strokeWidth: strokeWidth, role: "img", "aria-label": this_1._getAriaLabel(i, j) }))),
808
885
  React.createElement("circle", { id: hiddenHoverCircleId, key: hiddenHoverCircleId, r: 8, cx: this_1._xAxisScale(x2), cy: this_1._yAxisScale(y2), opacity: 0, width: 0, onMouseOver: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseMove: this_1._handleHover.bind(this_1, x2, y2, verticaLineHeight, lastCirlceXCallout_1, lastCircleId_1, lastCirlceXCalloutAccessibilityData_1), onMouseOut: this_1._handleMouseOut, strokeWidth: 0, focusable: false, onBlur: this_1._handleMouseOut })));
809
- /* eslint-enable react/jsx-no-bind */
810
886
  }
811
- if (isLegendSelected) {
812
- // don't draw line if it is in a gap
813
- if (!isInGap) {
814
- var lineBorderWidth = ((_q = this_1._points[i].lineOptions) === null || _q === void 0 ? void 0 : _q.lineBorderWidth)
815
- ? Number.parseFloat(this_1._points[i].lineOptions.lineBorderWidth.toString())
816
- : 0;
817
- if (lineBorderWidth > 0) {
818
- bordersForLine.push(React.createElement("line", { id: borderId, key: borderId, x1: this_1._xAxisScale(x1), y1: this_1._yAxisScale(y1), x2: this_1._xAxisScale(x2), y2: this_1._yAxisScale(y2), strokeLinecap: (_s = (_r = this_1._points[i].lineOptions) === null || _r === void 0 ? void 0 : _r.strokeLinecap) !== null && _s !== void 0 ? _s : 'round', strokeWidth: Number.parseFloat(strokeWidth.toString()) + lineBorderWidth, stroke: ((_t = this_1._points[i].lineOptions) === null || _t === void 0 ? void 0 : _t.lineBorderColor) || theme.semanticColors.bodyBackground, opacity: 1 }));
887
+ if (this_1.props.lineMode !== 'scatter') {
888
+ if (isLegendSelected) {
889
+ // don't draw line if it is in a gap
890
+ if (!isInGap) {
891
+ var lineBorderWidth = ((_q = this_1._points[i].lineOptions) === null || _q === void 0 ? void 0 : _q.lineBorderWidth)
892
+ ? Number.parseFloat(this_1._points[i].lineOptions.lineBorderWidth.toString())
893
+ : 0;
894
+ if (lineBorderWidth > 0) {
895
+ bordersForLine.push(React.createElement("line", { id: borderId, key: borderId, x1: this_1._xAxisScale(x1), y1: this_1._yAxisScale(y1), x2: this_1._xAxisScale(x2), y2: this_1._yAxisScale(y2), strokeLinecap: (_s = (_r = this_1._points[i].lineOptions) === null || _r === void 0 ? void 0 : _r.strokeLinecap) !== null && _s !== void 0 ? _s : 'round', strokeWidth: Number.parseFloat(strokeWidth.toString()) + lineBorderWidth, stroke: ((_t = this_1._points[i].lineOptions) === null || _t === void 0 ? void 0 : _t.lineBorderColor) || theme.semanticColors.bodyBackground, opacity: 1 }));
896
+ }
897
+ linesForLine.push(React.createElement("line", __assign({ id: lineId, key: lineId, x1: this_1._xAxisScale(x1), y1: this_1._yAxisScale(y1), x2: this_1._xAxisScale(x2), y2: this_1._yAxisScale(y2), strokeWidth: strokeWidth, ref: function (e) {
898
+ _this_1._refCallback(e, lineId);
899
+ }, onMouseOver: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this_1._handleMouseOut, stroke: lineColor, strokeLinecap: (_v = (_u = this_1._points[i].lineOptions) === null || _u === void 0 ? void 0 : _u.strokeLinecap) !== null && _v !== void 0 ? _v : 'round', strokeDasharray: (_w = this_1._points[i].lineOptions) === null || _w === void 0 ? void 0 : _w.strokeDasharray, strokeDashoffset: (_x = this_1._points[i].lineOptions) === null || _x === void 0 ? void 0 : _x.strokeDashoffset, opacity: 1 }, this_1._getClickHandler(this_1._points[i].onLineClick))));
819
900
  }
820
- linesForLine.push(React.createElement("line", __assign({ id: lineId, key: lineId, x1: this_1._xAxisScale(x1), y1: this_1._yAxisScale(y1), x2: this_1._xAxisScale(x2), y2: this_1._yAxisScale(y2), strokeWidth: strokeWidth, ref: function (e) {
821
- _this_1._refCallback(e, lineId);
822
- }, onMouseOver: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseMove: this_1._handleHover.bind(this_1, x1, y1, verticaLineHeight, xAxisCalloutData, circleId, xAxisCalloutAccessibilityData), onMouseOut: this_1._handleMouseOut, stroke: lineColor, strokeLinecap: (_v = (_u = this_1._points[i].lineOptions) === null || _u === void 0 ? void 0 : _u.strokeLinecap) !== null && _v !== void 0 ? _v : 'round', strokeDasharray: (_w = this_1._points[i].lineOptions) === null || _w === void 0 ? void 0 : _w.strokeDasharray, strokeDashoffset: (_x = this_1._points[i].lineOptions) === null || _x === void 0 ? void 0 : _x.strokeDashoffset, opacity: 1 }, this_1._getClickHandler(this_1._points[i].onLineClick))));
823
901
  }
824
- }
825
- else {
826
- if (!isInGap) {
827
- linesForLine.push(React.createElement("line", { id: lineId, key: lineId, x1: this_1._xAxisScale(x1), y1: this_1._yAxisScale(y1), x2: this_1._xAxisScale(x2), y2: this_1._yAxisScale(y2), strokeWidth: strokeWidth, stroke: lineColor, strokeLinecap: (_z = (_y = this_1._points[i].lineOptions) === null || _y === void 0 ? void 0 : _y.strokeLinecap) !== null && _z !== void 0 ? _z : 'round', strokeDasharray: (_0 = this_1._points[i].lineOptions) === null || _0 === void 0 ? void 0 : _0.strokeDasharray, strokeDashoffset: (_1 = this_1._points[i].lineOptions) === null || _1 === void 0 ? void 0 : _1.strokeDashoffset, opacity: 0.1 }));
902
+ else {
903
+ if (!isInGap) {
904
+ linesForLine.push(React.createElement("line", { id: lineId, key: lineId, x1: this_1._xAxisScale(x1), y1: this_1._yAxisScale(y1), x2: this_1._xAxisScale(x2), y2: this_1._yAxisScale(y2), strokeWidth: strokeWidth, stroke: lineColor, strokeLinecap: (_z = (_y = this_1._points[i].lineOptions) === null || _y === void 0 ? void 0 : _y.strokeLinecap) !== null && _z !== void 0 ? _z : 'round', strokeDasharray: (_0 = this_1._points[i].lineOptions) === null || _0 === void 0 ? void 0 : _0.strokeDasharray, strokeDashoffset: (_1 = this_1._points[i].lineOptions) === null || _1 === void 0 ? void 0 : _1.strokeDashoffset, opacity: 0.1 }));
905
+ }
828
906
  }
829
907
  }
830
908
  };