@fluentui/react-charting 5.24.2 → 5.24.3

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 (129) hide show
  1. package/CHANGELOG.json +34 -1
  2. package/CHANGELOG.md +14 -2
  3. package/dist/react-charting.d.ts +170 -37
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +58 -11
  7. package/lib/ScatterChart.d.ts +1 -0
  8. package/lib/ScatterChart.js +2 -0
  9. package/lib/ScatterChart.js.map +1 -0
  10. package/lib/components/CommonComponents/CartesianChart.base.js +45 -9
  11. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  12. package/lib/components/CommonComponents/CartesianChart.styles.js +48 -26
  13. package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  14. package/lib/components/CommonComponents/CartesianChart.types.d.ts +21 -1
  15. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  16. package/lib/components/DeclarativeChart/DeclarativeChart.js +157 -78
  17. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  18. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
  19. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +252 -62
  20. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  21. package/lib/components/ScatterChart/ScatterChart.base.d.ts +7 -0
  22. package/lib/components/ScatterChart/ScatterChart.base.js +453 -0
  23. package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -0
  24. package/lib/components/ScatterChart/ScatterChart.d.ts +7 -0
  25. package/lib/components/ScatterChart/ScatterChart.js +10 -0
  26. package/lib/components/ScatterChart/ScatterChart.js.map +1 -0
  27. package/lib/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
  28. package/lib/components/ScatterChart/ScatterChart.styles.js +7 -0
  29. package/lib/components/ScatterChart/ScatterChart.styles.js.map +1 -0
  30. package/lib/components/ScatterChart/ScatterChart.types.d.ts +42 -0
  31. package/lib/components/ScatterChart/ScatterChart.types.js +2 -0
  32. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -0
  33. package/lib/components/ScatterChart/index.d.ts +2 -0
  34. package/lib/components/ScatterChart/index.js +3 -0
  35. package/lib/components/ScatterChart/index.js.map +1 -0
  36. package/lib/index.d.ts +3 -1
  37. package/lib/index.js +1 -0
  38. package/lib/index.js.map +1 -1
  39. package/lib/types/IDataPoint.d.ts +73 -11
  40. package/lib/types/IDataPoint.js.map +1 -1
  41. package/lib/utilities/SVGTooltipText.d.ts +4 -0
  42. package/lib/utilities/SVGTooltipText.js +1 -2
  43. package/lib/utilities/SVGTooltipText.js.map +1 -1
  44. package/lib/utilities/utilities.d.ts +27 -3
  45. package/lib/utilities/utilities.js +102 -1
  46. package/lib/utilities/utilities.js.map +1 -1
  47. package/lib-amd/ScatterChart.d.ts +1 -0
  48. package/lib-amd/ScatterChart.js +6 -0
  49. package/lib-amd/ScatterChart.js.map +1 -0
  50. package/lib-amd/components/CommonComponents/CartesianChart.base.js +45 -9
  51. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  52. package/lib-amd/components/CommonComponents/CartesianChart.styles.js +48 -26
  53. package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  54. package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +21 -1
  55. package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
  56. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +155 -78
  57. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  58. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
  59. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +264 -71
  60. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  61. package/lib-amd/components/ScatterChart/ScatterChart.base.d.ts +7 -0
  62. package/lib-amd/components/ScatterChart/ScatterChart.base.js +447 -0
  63. package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -0
  64. package/lib-amd/components/ScatterChart/ScatterChart.d.ts +7 -0
  65. package/lib-amd/components/ScatterChart/ScatterChart.js +12 -0
  66. package/lib-amd/components/ScatterChart/ScatterChart.js.map +1 -0
  67. package/lib-amd/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
  68. package/lib-amd/components/ScatterChart/ScatterChart.styles.js +12 -0
  69. package/lib-amd/components/ScatterChart/ScatterChart.styles.js.map +1 -0
  70. package/lib-amd/components/ScatterChart/ScatterChart.types.d.ts +42 -0
  71. package/lib-amd/components/ScatterChart/ScatterChart.types.js +5 -0
  72. package/lib-amd/components/ScatterChart/ScatterChart.types.js.map +1 -0
  73. package/lib-amd/components/ScatterChart/index.d.ts +2 -0
  74. package/lib-amd/components/ScatterChart/index.js +7 -0
  75. package/lib-amd/components/ScatterChart/index.js.map +1 -0
  76. package/lib-amd/index.d.ts +3 -1
  77. package/lib-amd/index.js +3 -2
  78. package/lib-amd/index.js.map +1 -1
  79. package/lib-amd/types/IDataPoint.d.ts +73 -11
  80. package/lib-amd/types/IDataPoint.js.map +1 -1
  81. package/lib-amd/utilities/SVGTooltipText.d.ts +4 -0
  82. package/lib-amd/utilities/SVGTooltipText.js +1 -2
  83. package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
  84. package/lib-amd/utilities/utilities.d.ts +27 -3
  85. package/lib-amd/utilities/utilities.js +106 -2
  86. package/lib-amd/utilities/utilities.js.map +1 -1
  87. package/lib-commonjs/ScatterChart.d.ts +1 -0
  88. package/lib-commonjs/ScatterChart.js +5 -0
  89. package/lib-commonjs/ScatterChart.js.map +1 -0
  90. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +45 -9
  91. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  92. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +48 -26
  93. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  94. package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +21 -1
  95. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  96. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +157 -78
  97. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  98. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
  99. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +263 -71
  100. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  101. package/lib-commonjs/components/ScatterChart/ScatterChart.base.d.ts +7 -0
  102. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +456 -0
  103. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -0
  104. package/lib-commonjs/components/ScatterChart/ScatterChart.d.ts +7 -0
  105. package/lib-commonjs/components/ScatterChart/ScatterChart.js +13 -0
  106. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -0
  107. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
  108. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js +11 -0
  109. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js.map +1 -0
  110. package/lib-commonjs/components/ScatterChart/ScatterChart.types.d.ts +42 -0
  111. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js +3 -0
  112. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -0
  113. package/lib-commonjs/components/ScatterChart/index.d.ts +2 -0
  114. package/lib-commonjs/components/ScatterChart/index.js +6 -0
  115. package/lib-commonjs/components/ScatterChart/index.js.map +1 -0
  116. package/lib-commonjs/index.d.ts +3 -1
  117. package/lib-commonjs/index.js +3 -1
  118. package/lib-commonjs/index.js.map +1 -1
  119. package/lib-commonjs/types/IDataPoint.d.ts +73 -11
  120. package/lib-commonjs/types/IDataPoint.js.map +1 -1
  121. package/lib-commonjs/utilities/SVGTooltipText.d.ts +4 -0
  122. package/lib-commonjs/utilities/SVGTooltipText.js +1 -2
  123. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  124. package/lib-commonjs/utilities/utilities.d.ts +27 -3
  125. package/lib-commonjs/utilities/utilities.js +106 -2
  126. package/lib-commonjs/utilities/utilities.js.map +1 -1
  127. package/package.json +2 -2
  128. package/src/components/CommonComponents/CartesianChart.types.ts +25 -1
  129. package/src/components/ScatterChart/ScatterChart.types.ts +61 -0
@@ -1 +1 @@
1
- {"version":3,"file":"CartesianChart.styles.js","sourceRoot":"../src/","sources":["components/CommonComponents/CartesianChart.styles.ts"],"names":[],"mappings":";;;;AACA,uDAA2F;AAC3F,yCAAwD;AAExD,IAAM,SAAS,GAAY,IAAA,cAAM,GAAE,CAAC;AAE7B,IAAM,SAAS,GAAG,UAAC,KAAgC;;IAEtD,IAAA,SAAS,GAQP,KAAK,UARE,EACT,KAAK,GAOH,KAAK,MAPF,EACL,KAAK,GAMH,KAAK,MANF,EACL,eAAe,GAKb,KAAK,gBALQ,EACf,IAAI,GAIF,KAAK,KAJH,EACJ,KAGE,KAAK,UAHkB,EAAzB,SAAS,mBAAG,aAAa,KAAA,EACzB,WAAW,GAET,KAAK,YAFI,EACX,YAAY,GACV,KAAK,aADK,CACJ;IACF,IAAA,KAAK,GAAK,KAAM,MAAX,CAAY;IACzB,OAAO;QACL,IAAI,EAAE;YACJ,KAAK,CAAC,KAAK,CAAC,MAAM;YAClB;gBACE,OAAO,EAAE,MAAM;gBACf,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;gBACd,aAAa,EAAE,QAAQ;gBACvB,QAAQ,EAAE,QAAQ;aACnB;YACD,SAAS;SACV;QACD,YAAY,uBACP,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC9C;QACD,SAAS,EAAE;YACT,KAAK,CAAC,KAAK,CAAC,M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QACD,WAAW,EAAE;YACX,WAAW,EAAE,KAAK;SACnB;QACD,iBAAiB,wCACZ,KAAK,CAAC,KAAK,KACd,UAAU,EAAE,MAAM,EAClB,SAAS;gBACP,GAAC,8BAAoB,IAAG;oBACtB,KAAK,EAAE,YAAY;iBACpB;qBAEH,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,GACxC;QACD,eAAe,EAAE;kDAEV,KAAK,CAAC,UAAU,KACnB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,SAAS;oBACP,GAAC,8BAAoB,IAAG;wBACtB,KAAK,EAAE,YAAY;qBACpB;;SAGN;QACD,kBAAkB,EAAE;YAClB,KAAK,CAAC,KAAK,CAAC,KAAK;YACjB;gBACE,SAAS;oBACP,GAAC,8BAAoB,IAAG;wBACtB,KAAK,EAAE,YAAY;qBACpB;uBACF;gBACD,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ;gBACpC,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,MAAM;gBAClB,SAAS,EAAE,oBAAa,KAAK,CAAC,cAAc,CAAC,WAAW,CAAE;aAC3D;SACF;QACD,OAAO,wCACF,KAAK,CAAC,KAAK,CAAC,MAAM,KACrB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,QAAQ,EACvB,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,UAAU,EACpB,SAAS,EAAE,QAAQ,EACnB,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,EAC/C,YAAY,EAAE,KAAK,EACnB,aAAa,EAAE,MAAM,GACtB;KACF,CAAC;AACJ,CAAC,CAAC;AAhNW,QAAA,SAAS,aAgNpB","sourcesContent":["import { ICartesianChartStyleProps, ICartesianChartStyles } from './CartesianChart.types';\nimport { FontSizes, FontWeights, HighContrastSelector } from '@fluentui/react/lib/Styling';\nimport { NeutralColors, isIE11 } from '@fluentui/react';\n\nconst isIE11Var: boolean = isIE11();\n\nexport const getStyles = (props: ICartesianChartStyleProps): ICartesianChartStyles => {\n const {\n className,\n theme,\n isRtl,\n shouldHighlight,\n href,\n lineColor = 'transparent',\n toDrawShape,\n enableReflow,\n } = props;\n const { fonts } = theme!;\n return {\n root: [\n theme.fonts.medium,\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n flexDirection: 'column',\n overflow: 'hidden',\n },\n className,\n ],\n chartWrapper: {\n ...(enableReflow ? { overflow: 'auto' } : {}),\n },\n axisTitle: [\n theme.fonts.xSmall,\n {\n textAlign: 'center',\n fontWeight: FontWeights.semibold,\n fontStyle: 'normal',\n lineHeight: FontSizes.medium,\n color: NeutralColors.gray160,\n fill: theme.semanticColors.bodyText,\n },\n ],\n xAxis: {\n selectors: {\n text: [\n theme.fonts.tiny,\n {\n fill: theme.semanticColors.bodyText,\n fontWeight: '600',\n selectors: {\n [HighContrastSelector]: {\n fill: 'CanvasText',\n },\n },\n },\n ],\n line: {\n opacity: 0.2,\n stroke: theme.semanticColors.bodyText,\n width: '1px',\n selectors: {\n [HighContrastSelector]: {\n opacity: 0.1,\n stroke: 'CanvasText',\n },\n },\n },\n path: {\n display: 'none',\n },\n },\n },\n yAxis: {\n selectors: {\n text: [\n theme.fonts.tiny,\n {\n fill: theme.semanticColors.bodyText,\n fontWeight: '600',\n selectors: {\n [HighContrastSelector]: {\n fill: 'CanvasText',\n },\n },\n },\n ],\n path: {\n display: 'none',\n },\n line: {\n opacity: 0.2,\n stroke: theme.semanticColors.bodyText,\n selectors: {\n [HighContrastSelector]: {\n opacity: 0.1,\n stroke: 'CanvasText',\n },\n },\n },\n g: [\n isRtl &&\n !isIE11Var && {\n textAnchor: 'end',\n },\n ],\n },\n },\n\n opacityChangeOnHover: {\n opacity: shouldHighlight ? '' : '0.1',\n cursor: href ? 'pointer' : 'default',\n },\n\n legendContainer: [\n {\n marginTop: '8px',\n marginLeft: '20px',\n },\n ],\n calloutContentRoot: [\n {\n display: 'grid',\n overflow: 'hidden',\n padding: '11px 16px 10px 16px',\n backgroundColor: theme.semanticColors.bodyBackground,\n backgroundBlendMode: 'normal, luminosity',\n },\n ],\n calloutDateTimeContainer: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n calloutContentX: [\n {\n ...fonts.small,\n lineHeight: '16px',\n opacity: '0.85',\n color: theme.semanticColors.bodySubtext,\n },\n ],\n calloutBlockContainer: [\n theme.fonts.mediumPlus,\n {\n marginTop: '13px',\n color: theme.semanticColors.bodyText,\n },\n !toDrawShape && {\n selectors: {\n [HighContrastSelector]: {\n forcedColorAdjust: 'none',\n },\n },\n borderLeft: `4px solid ${lineColor}`,\n paddingLeft: '8px',\n },\n toDrawShape && {\n display: 'flex',\n },\n ],\n shapeStyles: {\n marginRight: '8px',\n },\n calloutlegendText: {\n ...fonts.small,\n lineHeight: '16px',\n selectors: {\n [HighContrastSelector]: {\n color: 'CanvasText',\n },\n },\n color: theme.semanticColors.bodySubtext,\n },\n calloutContentY: [\n {\n ...fonts.mediumPlus,\n fontWeight: 'bold',\n lineHeight: '22px',\n selectors: {\n [HighContrastSelector]: {\n color: 'CanvasText',\n },\n },\n },\n ],\n descriptionMessage: [\n theme.fonts.small,\n {\n selectors: {\n [HighContrastSelector]: {\n color: 'CanvasText',\n },\n },\n color: theme.semanticColors.bodyText,\n marginTop: '10px',\n paddingTop: '10px',\n borderTop: `1px solid ${theme.semanticColors.menuDivider}`,\n },\n ],\n tooltip: {\n ...theme.fonts.medium,\n display: 'flex',\n flexDirection: 'column',\n padding: '8px',\n position: 'absolute',\n textAlign: 'center',\n top: '0px',\n background: theme.semanticColors.bodyBackground,\n borderRadius: '2px',\n pointerEvents: 'none',\n },\n };\n};\n"]}
1
+ {"version":3,"file":"CartesianChart.styles.js","sourceRoot":"../src/","sources":["components/CommonComponents/CartesianChart.styles.ts"],"names":[],"mappings":";;;;AACA,uDAA2F;AAC3F,yCAAwD;AAExD,IAAM,SAAS,GAAY,IAAA,cAAM,GAAE,CAAC;AAE7B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AAE,YAAY;iBACpB;qBAEH,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,GACxC;QACD,eAAe,EAAE;kDAEV,KAAK,CAAC,UAAU,KACnB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,SAAS;oBACP,GAAC,8BAAoB,IAAG;wBACtB,KAAK,EAAE,YAAY;qBACpB;;SAGN;QACD,kBAAkB,EAAE;YAClB,KAAK,CAAC,KAAK,CAAC,KAAK;YACjB;gBACE,SAAS;oBACP,GAAC,8BAAoB,IAAG;wBACtB,KAAK,EAAE,YAAY;qBACpB;uBACF;gBACD,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ;gBACpC,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,MAAM;gBAClB,SAAS,EAAE,oBAAa,KAAK,CAAC,cAAc,CAAC,WAAW,CAAE;aAC3D;SACF;QACD,OAAO,wCACF,KAAK,CAAC,KAAK,CAAC,MAAM,KACrB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,QAAQ,EACvB,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,UAAU,EACpB,SAAS,EAAE,QAAQ,EACnB,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,EAC/C,YAAY,EAAE,KAAK,EACnB,aAAa,EAAE,MAAM,GACtB;QACD,UAAU;gBACR,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc;;YACzC,GAAC,8BAAoB,IAAG;gBACtB,IAAI,EAAE,QAAQ;aACf;eACF;KACF,CAAC;AACJ,CAAC,CAAC;AApOW,QAAA,SAAS,aAoOpB","sourcesContent":["import { ICartesianChartStyleProps, ICartesianChartStyles } from './CartesianChart.types';\nimport { FontSizes, FontWeights, HighContrastSelector } from '@fluentui/react/lib/Styling';\nimport { NeutralColors, isIE11 } from '@fluentui/react';\n\nconst isIE11Var: boolean = isIE11();\n\nexport const getStyles = (props: ICartesianChartStyleProps): ICartesianChartStyles => {\n const {\n className,\n theme,\n isRtl,\n shouldHighlight,\n href,\n lineColor = 'transparent',\n toDrawShape,\n enableReflow,\n } = props;\n const { fonts } = theme!;\n return {\n root: [\n theme.fonts.medium,\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n flexDirection: 'column',\n overflow: 'hidden',\n },\n className,\n ],\n chartWrapper: {\n ...(enableReflow ? { overflow: 'auto' } : {}),\n },\n axisTitle: [\n theme.fonts.xSmall,\n {\n textAlign: 'center',\n fontWeight: FontWeights.semibold,\n fontStyle: 'normal',\n lineHeight: FontSizes.medium,\n color: NeutralColors.gray160,\n fill: theme.semanticColors.bodyText,\n [HighContrastSelector]: {\n fill: 'CanvasText',\n },\n },\n ],\n axisAnnotation: [\n theme.fonts.small,\n {\n textAlign: 'center',\n fontWeight: FontWeights.semibold,\n fontStyle: 'normal',\n lineHeight: FontSizes.medium,\n color: NeutralColors.gray160,\n fill: theme.semanticColors.bodyText,\n },\n ],\n xAxis: {\n selectors: {\n text: [\n theme.fonts.tiny,\n {\n fill: theme.semanticColors.bodyText,\n fontWeight: '600',\n selectors: {\n [HighContrastSelector]: {\n fill: 'CanvasText',\n },\n },\n },\n ],\n line: {\n opacity: 0.2,\n stroke: theme.semanticColors.bodyText,\n width: '1px',\n selectors: {\n [HighContrastSelector]: {\n opacity: 0.1,\n stroke: 'CanvasText',\n },\n },\n },\n path: {\n display: 'none',\n },\n },\n },\n yAxis: {\n selectors: {\n text: [\n theme.fonts.tiny,\n {\n fill: theme.semanticColors.bodyText,\n fontWeight: '600',\n selectors: {\n [HighContrastSelector]: {\n fill: 'CanvasText',\n },\n },\n },\n ],\n path: {\n display: 'none',\n },\n line: {\n opacity: 0.2,\n stroke: theme.semanticColors.bodyText,\n selectors: {\n [HighContrastSelector]: {\n opacity: 0.1,\n stroke: 'CanvasText',\n },\n },\n },\n g: [\n isRtl &&\n !isIE11Var && {\n textAnchor: 'end',\n },\n ],\n },\n },\n\n opacityChangeOnHover: {\n opacity: shouldHighlight ? '' : '0.1',\n cursor: href ? 'pointer' : 'default',\n },\n\n legendContainer: [\n {\n marginTop: '8px',\n marginLeft: '20px',\n },\n ],\n calloutContentRoot: [\n {\n display: 'grid',\n overflow: 'hidden',\n padding: '11px 16px 10px 16px',\n backgroundColor: theme.semanticColors.bodyBackground,\n backgroundBlendMode: 'normal, luminosity',\n },\n ],\n calloutDateTimeContainer: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n calloutContentX: [\n {\n ...fonts.small,\n lineHeight: '16px',\n opacity: '0.85',\n color: theme.semanticColors.bodySubtext,\n },\n ],\n calloutBlockContainer: [\n theme.fonts.mediumPlus,\n {\n marginTop: '13px',\n color: theme.semanticColors.bodyText,\n },\n !toDrawShape && {\n selectors: {\n [HighContrastSelector]: {\n forcedColorAdjust: 'none',\n },\n },\n borderLeft: `4px solid ${lineColor}`,\n paddingLeft: '8px',\n },\n toDrawShape && {\n display: 'flex',\n },\n ],\n shapeStyles: {\n marginRight: '8px',\n },\n calloutlegendText: {\n ...fonts.small,\n lineHeight: '16px',\n selectors: {\n [HighContrastSelector]: {\n color: 'CanvasText',\n },\n },\n color: theme.semanticColors.bodySubtext,\n },\n calloutContentY: [\n {\n ...fonts.mediumPlus,\n fontWeight: 'bold',\n lineHeight: '22px',\n selectors: {\n [HighContrastSelector]: {\n color: 'CanvasText',\n },\n },\n },\n ],\n descriptionMessage: [\n theme.fonts.small,\n {\n selectors: {\n [HighContrastSelector]: {\n color: 'CanvasText',\n },\n },\n color: theme.semanticColors.bodyText,\n marginTop: '10px',\n paddingTop: '10px',\n borderTop: `1px solid ${theme.semanticColors.menuDivider}`,\n },\n ],\n tooltip: {\n ...theme.fonts.medium,\n display: 'flex',\n flexDirection: 'column',\n padding: '8px',\n position: 'absolute',\n textAlign: 'center',\n top: '0px',\n background: theme.semanticColors.bodyBackground,\n borderRadius: '2px',\n pointerEvents: 'none',\n },\n svgTooltip: {\n fill: theme.semanticColors.bodyBackground,\n [HighContrastSelector]: {\n fill: 'Canvas',\n },\n },\n };\n};\n"]}
@@ -122,9 +122,13 @@ export interface ICartesianChartStyles {
122
122
  */
123
123
  tooltip?: IStyle;
124
124
  /**
125
- * styles for tooltip
125
+ * styles for axis title
126
126
  */
127
127
  axisTitle?: IStyle;
128
+ /**
129
+ * styles for axis annotation
130
+ */
131
+ axisAnnotation?: IStyle;
128
132
  /**
129
133
  * Style for the chart Title.
130
134
  */
@@ -141,6 +145,10 @@ export interface ICartesianChartStyles {
141
145
  * Styles for the chart wrapper div
142
146
  */
143
147
  chartWrapper?: IStyle;
148
+ /**
149
+ * Styles for the svg tooltip
150
+ */
151
+ svgTooltip?: IStyle;
144
152
  }
145
153
  /**
146
154
  * Cartesian Chart properties
@@ -375,6 +383,18 @@ export interface ICartesianChartProps {
375
383
  * @default false
376
384
  */
377
385
  hideTickOverlap?: boolean;
386
+ /**
387
+ * Prop to set the x axis annotation. Used to display additional information on the x-axis.
388
+ * This is shown on the top of the chart.
389
+ * @default undefined
390
+ */
391
+ xAxisAnnotation?: string;
392
+ /**
393
+ * Prop to set the y axis annotation. Used to display additional information on the y-axis.
394
+ * This is shown on the right side of the chart. Not shown if secondary y-axis is enabled.
395
+ * @default undefined
396
+ */
397
+ yAxisAnnotation?: string;
378
398
  }
379
399
  export interface IYValueHover {
380
400
  legend?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"CartesianChart.types.js","sourceRoot":"../src/","sources":["components/CommonComponents/CartesianChart.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IOverflowSetProps } from '@fluentui/react/lib/OverflowSet';\nimport { IFocusZoneProps, FocusZoneDirection } from '@fluentui/react-focus';\nimport { ICalloutProps } from '@fluentui/react/lib/Callout';\nimport { ILegendsProps } from '../Legends/index';\nimport {\n IAccessibilityProps,\n IChart,\n IDataPoint,\n IGroupedVerticalBarChartData,\n IHeatMapChartDataPoint,\n IHorizontalBarChartWithAxisDataPoint,\n ILineChartPoints,\n IMargins,\n IVerticalBarChartDataPoint,\n IVerticalStackedBarDataPoint,\n} from '../../types/index';\nimport { IChartHoverCardProps } from '../../utilities/index';\nimport { TimeLocaleDefinition } from 'd3-time-format';\nimport { ChartTypes, IAxisData, IDomainNRange, IYAxisParams, XAxisTypes, YAxisType } from '../../utilities/utilities';\nimport { ScaleBand, ScaleLinear } from 'd3-scale';\n\n/**\n * Cartesian Chart style properties\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartStyleProps {\n /**\n * Theme (provided through customization.)\n */\n theme: ITheme;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Width of the chart.\n */\n width?: number;\n\n /**\n * Height of the chart.\n */\n height?: number;\n\n /**\n * Color of the chart.\n */\n color?: string;\n\n /**\n * Link to redirect if click action for graph\n */\n href?: string;\n\n /**\n * prop to check if the chart is selected or hovered upon to determine opacity\n */\n shouldHighlight?: boolean;\n\n /**\n * prop to check if the Page is in Rtl\n */\n isRtl?: boolean;\n\n /**\n * color of the line\n */\n lineColor?: string;\n\n /**\n * boolean flag which determines if shape is drawn in callout\n */\n toDrawShape?: boolean;\n\n /**\n * Prop to disable shrinking of the chart beyond a certain limit and enable scrolling when the chart overflows\n */\n enableReflow?: boolean;\n}\n\n/**\n * Cartesian Chart styles\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartStyles {\n /**\n * Style for the root element.\n */\n root?: IStyle;\n\n /**\n * Style for the element containing the x-axis.\n */\n xAxis?: IStyle;\n\n /**\n * Style for the element containing the y-axis.\n */\n yAxis?: IStyle;\n\n /**\n * Style for legend container\n */\n legendContainer?: IStyle;\n\n /**\n * line hover box css\n */\n hover?: IStyle;\n\n /**\n * styles for callout root-content\n */\n calloutContentRoot?: IStyle;\n\n /**\n * styles for callout x-content\n */\n calloutContentX?: IStyle;\n\n /**\n * styles for callout y-content\n */\n calloutContentY?: IStyle;\n\n /**\n * styles for description message\n */\n descriptionMessage?: IStyle;\n\n /**\n * styles for callout Date time container\n */\n calloutDateTimeContainer?: IStyle;\n\n /**\n * styles for callout info container\n */\n calloutInfoContainer?: IStyle;\n\n /**\n * styles for callout block container\n */\n calloutBlockContainer?: IStyle;\n\n /**\n * styles for callout legend text\n */\n calloutlegendText?: IStyle;\n\n /**\n * styles for tooltip\n */\n tooltip?: IStyle;\n\n /**\n * styles for tooltip\n */\n axisTitle?: IStyle;\n\n /**\n * Style for the chart Title.\n */\n chartTitle?: IStyle;\n\n /**\n * Style to change the opacity of bars in dataviz when we hover on a single bar or legends\n */\n opacityChangeOnHover?: IStyle;\n\n /**\n * styles for the shape object in the callout\n */\n shapeStyles?: IStyle;\n\n /**\n * Styles for the chart wrapper div\n */\n chartWrapper?: IStyle;\n}\n\n/**\n * Cartesian Chart properties\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartProps {\n /**\n * Below height used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n height?: number;\n\n /**\n * Below width used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n width?: number;\n\n /**\n * this prop takes its parent as a HTML element to define the width and height of the chart\n */\n parentRef?: HTMLElement | null;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Theme (provided through customization.)\n */\n theme?: ITheme;\n\n /**\n * Margins for the chart\n * @default `{ top: 20, bottom: 35, left: 40, right: 20 }`\n * To avoid edge cuttings to the chart, we recommend you use default values or greater then default values\n */\n margins?: IMargins;\n\n /** decides wether to show/hide legends\n * @defaultvalue false\n */\n hideLegend?: boolean;\n\n /**\n * Do not show tooltips in chart\n * @default false\n */\n hideTooltip?: boolean;\n\n /**\n * this prop takes values that you want the chart to render on x-axis\n * This is a optional parameter if not specified D3 will decide which values appear on the x-axis for you\n * Please look at https://github.com/d3/d3-scale for more information on how D3 decides what data to appear on the axis of chart\n */\n tickValues?: number[] | Date[] | string[];\n\n /**\n * the format for the data on x-axis. For date object this can be specified to your requirement. Eg: '%m/%d', '%d'\n * Please look at https://github.com/d3/d3-time-format for all the formats supported for date axis\n * Only applicable for date axis. For y-axis format use yAxisTickFormat prop.\n */\n tickFormat?: string;\n\n /**\n * Width of line stroke\n */\n strokeWidth?: number;\n\n /**\n * x Axis labels tick padding. This defines the gap between tick labels and tick lines.\n * @default 10\n */\n xAxisTickPadding?: number;\n\n /**\n * the format in for the data on y-axis. For data object this can be specified to your requirement.\n * Eg: d3.format(\".0%\")(0.123),d3.format(\"+20\")(42);\n * Please look at https://github.com/d3/d3-format for all the formats supported\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yAxisTickFormat?: any;\n\n /**\n * Secondary y-scale options\n * By default this is not defined, meaning there will be no secondary y-scale.\n */\n secondaryYScaleOptions?: {\n /** Minimum value (0 by default) */\n yMinValue?: number;\n /** Maximum value (100 by default) */\n yMaxValue?: number;\n };\n\n /**\n * minimum data value point in y-axis\n */\n yMinValue?: number;\n\n /**\n * maximum data value point in y-axis\n */\n yMaxValue?: number;\n\n /**\n * maximum data value point in x-axis\n */\n xMaxValue?: number;\n\n /**\n * Number of ticks on the y-axis.\n * Tick count should be factor of difference between (yMinValue, yMaxValue)?\n * @default 4\n */\n yAxisTickCount?: number;\n\n /**\n * defines the number of ticks on the x-axis. Tries to match the nearest interval satisfying the count.\n * Does not work for string axis.\n * @default 6\n */\n xAxisTickCount?: number;\n\n /**\n * define the size of the tick lines on the x-axis\n * @default 10\n */\n xAxistickSize?: number;\n\n /**\n * defines the space between the tick line and the data label\n * @default 10\n */\n tickPadding?: number;\n\n /**\n * Url that the data-viz needs to redirect to upon clicking on it\n */\n href?: string;\n\n /**\n * Label to apply to the whole chart.\n * @deprecated - Use your chart label for the chart.\n */\n chartLabel?: string;\n\n /**\n * overflow props for the legends\n */\n legendsOverflowProps?: Partial<IOverflowSetProps>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n legendsOverflowText?: any;\n\n /**\n * focus zone props in hover card for legends\n */\n focusZonePropsForLegendsInHoverCard?: IFocusZoneProps;\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 enabledLegendsWrapLines?: boolean;\n\n /*\n * props for the legends in the chart\n */\n legendProps?: Partial<ILegendsProps>;\n\n /**\n *@default false\n *Used for to elipse x axis labes and show tooltip on x axis labels\n */\n showXAxisLablesTooltip?: boolean;\n\n /**\n * @default 4\n * Used for X axis labels\n * While Giving showXAxisLablesTooltip prop, need to define after how many chars, we need to truncate the word.\n */\n noOfCharsToTruncate?: number;\n\n /**\n * @default false\n * Used to wrap x axis labels values (whole value)\n */\n wrapXAxisLables?: boolean;\n\n /**\n * @default false\n * Used to rotate x axis labels by 45 degrees\n */\n rotateXAxisLables?: boolean;\n\n /**\n * The prop used to define the date time localization options\n */\n dateLocalizeOptions?: Intl.DateTimeFormatOptions;\n\n /**\n * The prop used to define a custom locale for the date time format.\n */\n timeFormatLocale?: TimeLocaleDefinition;\n\n /**\n * The prop used to define a custom datetime formatter for date axis.\n */\n customDateTimeFormatter?: (dateTime: Date) => string;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<ICartesianChartStyleProps, ICartesianChartStyles>;\n\n /**\n * Callout customization props\n */\n calloutProps?: Partial<ICalloutProps>;\n\n /**\n * props for the svg; use this to include aria-* or other attributes on the tag\n */\n svgProps?: React.SVGProps<SVGSVGElement>;\n\n /**\n * Prop to disable shrinking of the chart beyond a certain limit and enable scrolling when the chart overflows\n * @default True for LineChart but False for other charts\n */\n enableReflow?: boolean;\n\n /**\n * Prop to set the x axis title\n * @default undefined\n * Minimum bottom margin required for x axis title is 55px\n */\n\n xAxisTitle?: string;\n\n /**\n * Prop to set the y axis title\n * @default undefined\n * Minimum left margin required for y axis title is 60px and for RTL is 40px\n * Minimum right margin required for y axis title is 40px and for RTL is 60px\n */\n yAxisTitle?: string;\n\n /**\n * Prop to set the secondary y axis title\n * @default undefined\n * If RTL is enabled, minimum left and right margins required for secondary y axis title is 60px\n */\n secondaryYAxistitle?: string;\n\n /**\n * Whether to use UTC time for axis scale, ticks, and the time display in callouts.\n * When set to `true`, time is displayed equally, regardless of the user's timezone settings.\n * @default true\n */\n useUTC?: boolean;\n\n /**\n * @default false\n * Used for enabling negative values in Y axis.\n */\n supportNegativeData?: boolean;\n\n /**\n * @default false\n * The prop used to decide rounded ticks on y axis\n */\n roundedTicks?: boolean;\n\n /**\n * Optional callback to access the IChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IChart>;\n\n /**\n * Determines whether overlapping x-axis tick labels should be hidden.\n * @default false\n */\n hideTickOverlap?: boolean;\n}\n\nexport interface IYValueHover {\n legend?: string;\n y?: number | string;\n color?: string;\n data?: string | number;\n shouldDrawBorderBottom?: boolean;\n yAxisCalloutData?: string | { [id: string]: number };\n index?: number;\n callOutAccessibilityData?: IAccessibilityProps;\n}\n\nexport interface IChildProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xScale?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScalePrimary?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScaleSecondary?: any;\n containerHeight?: number;\n containerWidth?: number;\n}\n\n// Only used for Cartesian chart base\nexport interface IModifiedCartesianChartProps extends ICartesianChartProps {\n /**\n * Define the chart title\n */\n chartTitle?: string;\n\n /**\n * Only used for Area chart\n * Value used to draw y axis of that chart.\n */\n maxOfYVal?: number;\n\n /**\n * Data of the chart\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n points: any;\n\n /**\n * Define type of the chart\n */\n chartType: ChartTypes;\n\n /** X axis type */\n xAxisType: XAxisTypes;\n\n /** Y axis type */\n yAxisType?: YAxisType;\n\n /**\n * Legends of the chart.\n */\n legendBars: JSX.Element | null;\n\n /**\n * Callout props\n */\n calloutProps: Partial<ICalloutProps> & {\n isCalloutVisible: boolean;\n id: string;\n YValueHover?: IYValueHover[];\n hoverXValue?: string | number | null;\n legend?: string;\n color?: string;\n YValue?: string | number;\n XValue?: string;\n descriptionMessage?: string;\n };\n\n /**\n * Callback method used for to get margins to the chart.\n */\n getmargins?: (margins: IMargins) => void;\n\n /**\n * This is a call back method to the chart from cartesian chart.\n * params are xScale, yScale, containerHeight, containerWidth. These values were used to draw the graph.\n * It also contians an optional param xAxisElement - defines as x axis scale element.\n * This param used to enable feature word wrap of Xaxis.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getGraphData?: any;\n\n /**\n * Used for bar chart graphs.\n * To define width of the bar\n */\n barwidth?: number;\n\n /**\n * Used for tick styles of the x axis of the chart\n * Tick params are applicable for date axis only.\n */\n tickParams?: {\n tickValues?: number[] | Date[] | string[];\n tickFormat?: string;\n };\n\n /**\n * it's padding between bar's or lines in the graph\n */\n xAxisPadding?: number;\n\n /**\n * it's padding between bar's or lines in the graph\n */\n yAxisPadding?: number;\n\n /**\n * Children elements specific to derived chart types.\n */\n children(props: IChildProps): React.ReactNode;\n\n /**\n * To enable callout for individualbar or complete stack. Using for only Vertical stacked bar chart.\n * @default false\n * @type \\{boolean \\}\n */\n isCalloutForStack?: boolean;\n\n /** dataset values to find out domain of the String axis\n * Present using for only vertical stacked bar chart and grouped vertical bar chart\n */\n datasetForXAxisDomain?: string[];\n\n /** Own callout design */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n customizedCallout?: any;\n\n /**\n * if the data points for the y-axis is of type string, then we need to give this\n * prop to construct the y-axis\n */\n stringDatasetForYAxisDomain?: string[];\n\n /**\n * Focus zone direction to the chart\n * @default FocusZoneDirection.horizontal\n */\n focusZoneDirection?: FocusZoneDirection;\n\n /**\n * props to send into the chart hover card\n */\n chartHoverProps?: IChartHoverCardProps;\n\n /**\n * props to send to the focuszone\n */\n svgFocusZoneProps?: IFocusZoneProps;\n\n /**\n * The prop used to define the culture to localize the numbers and date\n */\n culture?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getAxisData?: any;\n\n /**\n * Callback method used when mouse leaves the chart boundary.\n */\n onChartMouseLeave?: () => void;\n\n /** Callback method to get extra margins for domain */\n getDomainMargins?: (containerWidth: number) => IMargins;\n\n /** Callback method to get extra margins for Y-axis domain */\n getYDomainMargins?: (containerHeight: number) => IMargins;\n\n /** Padding between each bar/line-point */\n xAxisInnerPadding?: number;\n\n /** Padding before first bar/line-point and after last bar/line-point */\n xAxisOuterPadding?: number;\n\n /**\n *@default false\n *Used for to elipse y axis labes and show tooltip on x axis labels\n */\n showYAxisLablesTooltip?: boolean;\n\n /**\n *@default false\n *Used for showing complete y axis lables */\n showYAxisLables?: boolean;\n\n /**\n * @default false\n * Used to control the first render cycle Performance optimization code.\n */\n enableFirstRenderOptimization?: boolean;\n\n /**\n * Get the min and max values of the y-axis\n */\n getMinMaxOfYAxis: (\n points: ILineChartPoints[] | IHorizontalBarChartWithAxisDataPoint[] | IVerticalBarChartDataPoint[] | IDataPoint[],\n yAxisType: YAxisType | undefined,\n useSecondaryYScale?: boolean,\n ) => { startValue: number; endValue: number };\n\n /**\n * Create the y-axis\n */\n createYAxis: (\n yAxisParams: IYAxisParams,\n isRtl: boolean,\n axisData: IAxisData,\n isIntegralDataset: boolean,\n useSecondaryYScale?: boolean,\n supportNegativeData?: boolean,\n roundedTicks?: boolean,\n ) => ScaleLinear<number, number, never>;\n\n /**\n * Get the domain and range values\n */\n getDomainNRangeValues: (\n points:\n | ILineChartPoints[]\n | IVerticalBarChartDataPoint[]\n | IVerticalStackedBarDataPoint[]\n | IHorizontalBarChartWithAxisDataPoint[]\n | IGroupedVerticalBarChartData[]\n | IHeatMapChartDataPoint[],\n margins: IMargins,\n width: number,\n chartType: ChartTypes,\n isRTL: boolean,\n xAxisType: XAxisTypes,\n barWidth: number,\n tickValues: Date[] | number[] | string[] | undefined,\n shiftX: number,\n ) => IDomainNRange;\n\n /**\n * Create the string y-axis\n */\n createStringYAxis: (\n yAxisParams: IYAxisParams,\n dataPoints: string[],\n isRtl: boolean,\n barWidth: number | undefined,\n chartType?: ChartTypes,\n ) => ScaleBand<string>;\n\n /**\n * Callback to access the public methods and properties of the component.\n */\n ref?: IRefObject<IChart>;\n\n /**\n * Controls whether the numeric x-axis domain should be extended to start and end at nice rounded values.\n * @default true\n */\n showRoundOffXTickValues?: boolean;\n}\n"]}
1
+ {"version":3,"file":"CartesianChart.types.js","sourceRoot":"../src/","sources":["components/CommonComponents/CartesianChart.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IOverflowSetProps } from '@fluentui/react/lib/OverflowSet';\nimport { IFocusZoneProps, FocusZoneDirection } from '@fluentui/react-focus';\nimport { ICalloutProps } from '@fluentui/react/lib/Callout';\nimport { ILegendsProps } from '../Legends/index';\nimport {\n IAccessibilityProps,\n IChart,\n IDataPoint,\n IGroupedVerticalBarChartData,\n IHeatMapChartDataPoint,\n IHorizontalBarChartWithAxisDataPoint,\n ILineChartPoints,\n IMargins,\n IVerticalBarChartDataPoint,\n IVerticalStackedBarDataPoint,\n} from '../../types/index';\nimport { IChartHoverCardProps } from '../../utilities/index';\nimport { TimeLocaleDefinition } from 'd3-time-format';\nimport { ChartTypes, IAxisData, IDomainNRange, IYAxisParams, XAxisTypes, YAxisType } from '../../utilities/utilities';\nimport { ScaleBand, ScaleLinear } from 'd3-scale';\n\n/**\n * Cartesian Chart style properties\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartStyleProps {\n /**\n * Theme (provided through customization.)\n */\n theme: ITheme;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Width of the chart.\n */\n width?: number;\n\n /**\n * Height of the chart.\n */\n height?: number;\n\n /**\n * Color of the chart.\n */\n color?: string;\n\n /**\n * Link to redirect if click action for graph\n */\n href?: string;\n\n /**\n * prop to check if the chart is selected or hovered upon to determine opacity\n */\n shouldHighlight?: boolean;\n\n /**\n * prop to check if the Page is in Rtl\n */\n isRtl?: boolean;\n\n /**\n * color of the line\n */\n lineColor?: string;\n\n /**\n * boolean flag which determines if shape is drawn in callout\n */\n toDrawShape?: boolean;\n\n /**\n * Prop to disable shrinking of the chart beyond a certain limit and enable scrolling when the chart overflows\n */\n enableReflow?: boolean;\n}\n\n/**\n * Cartesian Chart styles\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartStyles {\n /**\n * Style for the root element.\n */\n root?: IStyle;\n\n /**\n * Style for the element containing the x-axis.\n */\n xAxis?: IStyle;\n\n /**\n * Style for the element containing the y-axis.\n */\n yAxis?: IStyle;\n\n /**\n * Style for legend container\n */\n legendContainer?: IStyle;\n\n /**\n * line hover box css\n */\n hover?: IStyle;\n\n /**\n * styles for callout root-content\n */\n calloutContentRoot?: IStyle;\n\n /**\n * styles for callout x-content\n */\n calloutContentX?: IStyle;\n\n /**\n * styles for callout y-content\n */\n calloutContentY?: IStyle;\n\n /**\n * styles for description message\n */\n descriptionMessage?: IStyle;\n\n /**\n * styles for callout Date time container\n */\n calloutDateTimeContainer?: IStyle;\n\n /**\n * styles for callout info container\n */\n calloutInfoContainer?: IStyle;\n\n /**\n * styles for callout block container\n */\n calloutBlockContainer?: IStyle;\n\n /**\n * styles for callout legend text\n */\n calloutlegendText?: IStyle;\n\n /**\n * styles for tooltip\n */\n tooltip?: IStyle;\n\n /**\n * styles for axis title\n */\n axisTitle?: IStyle;\n\n /**\n * styles for axis annotation\n */\n axisAnnotation?: IStyle;\n\n /**\n * Style for the chart Title.\n */\n chartTitle?: IStyle;\n\n /**\n * Style to change the opacity of bars in dataviz when we hover on a single bar or legends\n */\n opacityChangeOnHover?: IStyle;\n\n /**\n * styles for the shape object in the callout\n */\n shapeStyles?: IStyle;\n\n /**\n * Styles for the chart wrapper div\n */\n chartWrapper?: IStyle;\n\n /**\n * Styles for the svg tooltip\n */\n svgTooltip?: IStyle;\n}\n\n/**\n * Cartesian Chart properties\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartProps {\n /**\n * Below height used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n height?: number;\n\n /**\n * Below width used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n width?: number;\n\n /**\n * this prop takes its parent as a HTML element to define the width and height of the chart\n */\n parentRef?: HTMLElement | null;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Theme (provided through customization.)\n */\n theme?: ITheme;\n\n /**\n * Margins for the chart\n * @default `{ top: 20, bottom: 35, left: 40, right: 20 }`\n * To avoid edge cuttings to the chart, we recommend you use default values or greater then default values\n */\n margins?: IMargins;\n\n /** decides wether to show/hide legends\n * @defaultvalue false\n */\n hideLegend?: boolean;\n\n /**\n * Do not show tooltips in chart\n * @default false\n */\n hideTooltip?: boolean;\n\n /**\n * this prop takes values that you want the chart to render on x-axis\n * This is a optional parameter if not specified D3 will decide which values appear on the x-axis for you\n * Please look at https://github.com/d3/d3-scale for more information on how D3 decides what data to appear on the axis of chart\n */\n tickValues?: number[] | Date[] | string[];\n\n /**\n * the format for the data on x-axis. For date object this can be specified to your requirement. Eg: '%m/%d', '%d'\n * Please look at https://github.com/d3/d3-time-format for all the formats supported for date axis\n * Only applicable for date axis. For y-axis format use yAxisTickFormat prop.\n */\n tickFormat?: string;\n\n /**\n * Width of line stroke\n */\n strokeWidth?: number;\n\n /**\n * x Axis labels tick padding. This defines the gap between tick labels and tick lines.\n * @default 10\n */\n xAxisTickPadding?: number;\n\n /**\n * the format in for the data on y-axis. For data object this can be specified to your requirement.\n * Eg: d3.format(\".0%\")(0.123),d3.format(\"+20\")(42);\n * Please look at https://github.com/d3/d3-format for all the formats supported\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yAxisTickFormat?: any;\n\n /**\n * Secondary y-scale options\n * By default this is not defined, meaning there will be no secondary y-scale.\n */\n secondaryYScaleOptions?: {\n /** Minimum value (0 by default) */\n yMinValue?: number;\n /** Maximum value (100 by default) */\n yMaxValue?: number;\n };\n\n /**\n * minimum data value point in y-axis\n */\n yMinValue?: number;\n\n /**\n * maximum data value point in y-axis\n */\n yMaxValue?: number;\n\n /**\n * maximum data value point in x-axis\n */\n xMaxValue?: number;\n\n /**\n * Number of ticks on the y-axis.\n * Tick count should be factor of difference between (yMinValue, yMaxValue)?\n * @default 4\n */\n yAxisTickCount?: number;\n\n /**\n * defines the number of ticks on the x-axis. Tries to match the nearest interval satisfying the count.\n * Does not work for string axis.\n * @default 6\n */\n xAxisTickCount?: number;\n\n /**\n * define the size of the tick lines on the x-axis\n * @default 10\n */\n xAxistickSize?: number;\n\n /**\n * defines the space between the tick line and the data label\n * @default 10\n */\n tickPadding?: number;\n\n /**\n * Url that the data-viz needs to redirect to upon clicking on it\n */\n href?: string;\n\n /**\n * Label to apply to the whole chart.\n * @deprecated - Use your chart label for the chart.\n */\n chartLabel?: string;\n\n /**\n * overflow props for the legends\n */\n legendsOverflowProps?: Partial<IOverflowSetProps>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n legendsOverflowText?: any;\n\n /**\n * focus zone props in hover card for legends\n */\n focusZonePropsForLegendsInHoverCard?: IFocusZoneProps;\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 enabledLegendsWrapLines?: boolean;\n\n /*\n * props for the legends in the chart\n */\n legendProps?: Partial<ILegendsProps>;\n\n /**\n *@default false\n *Used for to elipse x axis labes and show tooltip on x axis labels\n */\n showXAxisLablesTooltip?: boolean;\n\n /**\n * @default 4\n * Used for X axis labels\n * While Giving showXAxisLablesTooltip prop, need to define after how many chars, we need to truncate the word.\n */\n noOfCharsToTruncate?: number;\n\n /**\n * @default false\n * Used to wrap x axis labels values (whole value)\n */\n wrapXAxisLables?: boolean;\n\n /**\n * @default false\n * Used to rotate x axis labels by 45 degrees\n */\n rotateXAxisLables?: boolean;\n\n /**\n * The prop used to define the date time localization options\n */\n dateLocalizeOptions?: Intl.DateTimeFormatOptions;\n\n /**\n * The prop used to define a custom locale for the date time format.\n */\n timeFormatLocale?: TimeLocaleDefinition;\n\n /**\n * The prop used to define a custom datetime formatter for date axis.\n */\n customDateTimeFormatter?: (dateTime: Date) => string;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<ICartesianChartStyleProps, ICartesianChartStyles>;\n\n /**\n * Callout customization props\n */\n calloutProps?: Partial<ICalloutProps>;\n\n /**\n * props for the svg; use this to include aria-* or other attributes on the tag\n */\n svgProps?: React.SVGProps<SVGSVGElement>;\n\n /**\n * Prop to disable shrinking of the chart beyond a certain limit and enable scrolling when the chart overflows\n * @default True for LineChart but False for other charts\n */\n enableReflow?: boolean;\n\n /**\n * Prop to set the x axis title\n * @default undefined\n * Minimum bottom margin required for x axis title is 55px\n */\n\n xAxisTitle?: string;\n\n /**\n * Prop to set the y axis title\n * @default undefined\n * Minimum left margin required for y axis title is 60px and for RTL is 40px\n * Minimum right margin required for y axis title is 40px and for RTL is 60px\n */\n yAxisTitle?: string;\n\n /**\n * Prop to set the secondary y axis title\n * @default undefined\n * If RTL is enabled, minimum left and right margins required for secondary y axis title is 60px\n */\n secondaryYAxistitle?: string;\n\n /**\n * Whether to use UTC time for axis scale, ticks, and the time display in callouts.\n * When set to `true`, time is displayed equally, regardless of the user's timezone settings.\n * @default true\n */\n useUTC?: boolean;\n\n /**\n * @default false\n * Used for enabling negative values in Y axis.\n */\n supportNegativeData?: boolean;\n\n /**\n * @default false\n * The prop used to decide rounded ticks on y axis\n */\n roundedTicks?: boolean;\n\n /**\n * Optional callback to access the IChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IChart>;\n\n /**\n * Determines whether overlapping x-axis tick labels should be hidden.\n * @default false\n */\n hideTickOverlap?: boolean;\n\n /**\n * Prop to set the x axis annotation. Used to display additional information on the x-axis.\n * This is shown on the top of the chart.\n * @default undefined\n */\n xAxisAnnotation?: string;\n\n /**\n * Prop to set the y axis annotation. Used to display additional information on the y-axis.\n * This is shown on the right side of the chart. Not shown if secondary y-axis is enabled.\n * @default undefined\n */\n yAxisAnnotation?: string;\n}\n\nexport interface IYValueHover {\n legend?: string;\n y?: number | string;\n color?: string;\n data?: string | number;\n shouldDrawBorderBottom?: boolean;\n yAxisCalloutData?: string | { [id: string]: number };\n index?: number;\n callOutAccessibilityData?: IAccessibilityProps;\n}\n\nexport interface IChildProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xScale?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScalePrimary?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScaleSecondary?: any;\n containerHeight?: number;\n containerWidth?: number;\n}\n\n// Only used for Cartesian chart base\nexport interface IModifiedCartesianChartProps extends ICartesianChartProps {\n /**\n * Define the chart title\n */\n chartTitle?: string;\n\n /**\n * Only used for Area chart\n * Value used to draw y axis of that chart.\n */\n maxOfYVal?: number;\n\n /**\n * Data of the chart\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n points: any;\n\n /**\n * Define type of the chart\n */\n chartType: ChartTypes;\n\n /** X axis type */\n xAxisType: XAxisTypes;\n\n /** Y axis type */\n yAxisType?: YAxisType;\n\n /**\n * Legends of the chart.\n */\n legendBars: JSX.Element | null;\n\n /**\n * Callout props\n */\n calloutProps: Partial<ICalloutProps> & {\n isCalloutVisible: boolean;\n id: string;\n YValueHover?: IYValueHover[];\n hoverXValue?: string | number | null;\n legend?: string;\n color?: string;\n YValue?: string | number;\n XValue?: string;\n descriptionMessage?: string;\n };\n\n /**\n * Callback method used for to get margins to the chart.\n */\n getmargins?: (margins: IMargins) => void;\n\n /**\n * This is a call back method to the chart from cartesian chart.\n * params are xScale, yScale, containerHeight, containerWidth. These values were used to draw the graph.\n * It also contians an optional param xAxisElement - defines as x axis scale element.\n * This param used to enable feature word wrap of Xaxis.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getGraphData?: any;\n\n /**\n * Used for bar chart graphs.\n * To define width of the bar\n */\n barwidth?: number;\n\n /**\n * Used for tick styles of the x axis of the chart\n * Tick params are applicable for date axis only.\n */\n tickParams?: {\n tickValues?: number[] | Date[] | string[];\n tickFormat?: string;\n };\n\n /**\n * it's padding between bar's or lines in the graph\n */\n xAxisPadding?: number;\n\n /**\n * it's padding between bar's or lines in the graph\n */\n yAxisPadding?: number;\n\n /**\n * Children elements specific to derived chart types.\n */\n children(props: IChildProps): React.ReactNode;\n\n /**\n * To enable callout for individualbar or complete stack. Using for only Vertical stacked bar chart.\n * @default false\n * @type \\{boolean \\}\n */\n isCalloutForStack?: boolean;\n\n /** dataset values to find out domain of the String axis\n * Present using for only vertical stacked bar chart and grouped vertical bar chart\n */\n datasetForXAxisDomain?: string[];\n\n /** Own callout design */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n customizedCallout?: any;\n\n /**\n * if the data points for the y-axis is of type string, then we need to give this\n * prop to construct the y-axis\n */\n stringDatasetForYAxisDomain?: string[];\n\n /**\n * Focus zone direction to the chart\n * @default FocusZoneDirection.horizontal\n */\n focusZoneDirection?: FocusZoneDirection;\n\n /**\n * props to send into the chart hover card\n */\n chartHoverProps?: IChartHoverCardProps;\n\n /**\n * props to send to the focuszone\n */\n svgFocusZoneProps?: IFocusZoneProps;\n\n /**\n * The prop used to define the culture to localize the numbers and date\n */\n culture?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getAxisData?: any;\n\n /**\n * Callback method used when mouse leaves the chart boundary.\n */\n onChartMouseLeave?: () => void;\n\n /** Callback method to get extra margins for domain */\n getDomainMargins?: (containerWidth: number) => IMargins;\n\n /** Callback method to get extra margins for Y-axis domain */\n getYDomainMargins?: (containerHeight: number) => IMargins;\n\n /** Padding between each bar/line-point */\n xAxisInnerPadding?: number;\n\n /** Padding before first bar/line-point and after last bar/line-point */\n xAxisOuterPadding?: number;\n\n /**\n *@default false\n *Used for to elipse y axis labes and show tooltip on x axis labels\n */\n showYAxisLablesTooltip?: boolean;\n\n /**\n *@default false\n *Used for showing complete y axis lables */\n showYAxisLables?: boolean;\n\n /**\n * @default false\n * Used to control the first render cycle Performance optimization code.\n */\n enableFirstRenderOptimization?: boolean;\n\n /**\n * Get the min and max values of the y-axis\n */\n getMinMaxOfYAxis: (\n points: ILineChartPoints[] | IHorizontalBarChartWithAxisDataPoint[] | IVerticalBarChartDataPoint[] | IDataPoint[],\n yAxisType: YAxisType | undefined,\n useSecondaryYScale?: boolean,\n ) => { startValue: number; endValue: number };\n\n /**\n * Create the y-axis\n */\n createYAxis: (\n yAxisParams: IYAxisParams,\n isRtl: boolean,\n axisData: IAxisData,\n isIntegralDataset: boolean,\n useSecondaryYScale?: boolean,\n supportNegativeData?: boolean,\n roundedTicks?: boolean,\n ) => ScaleLinear<number, number, never>;\n\n /**\n * Get the domain and range values\n */\n getDomainNRangeValues: (\n points:\n | ILineChartPoints[]\n | IVerticalBarChartDataPoint[]\n | IVerticalStackedBarDataPoint[]\n | IHorizontalBarChartWithAxisDataPoint[]\n | IGroupedVerticalBarChartData[]\n | IHeatMapChartDataPoint[],\n margins: IMargins,\n width: number,\n chartType: ChartTypes,\n isRTL: boolean,\n xAxisType: XAxisTypes,\n barWidth: number,\n tickValues: Date[] | number[] | string[] | undefined,\n shiftX: number,\n ) => IDomainNRange;\n\n /**\n * Create the string y-axis\n */\n createStringYAxis: (\n yAxisParams: IYAxisParams,\n dataPoints: string[],\n isRtl: boolean,\n barWidth: number | undefined,\n chartType?: ChartTypes,\n ) => ScaleBand<string>;\n\n /**\n * Callback to access the public methods and properties of the component.\n */\n ref?: IRefObject<IChart>;\n\n /**\n * Controls whether the numeric x-axis domain should be extended to start and end at nice rounded values.\n * @default true\n */\n showRoundOffXTickValues?: boolean;\n}\n"]}
@@ -19,7 +19,9 @@ var index_7 = require("../GaugeChart/index");
19
19
  var index_8 = require("../GroupedVerticalBarChart/index");
20
20
  var index_9 = require("../VerticalBarChart/index");
21
21
  var withResponsiveContainer_1 = require("../ResponsiveContainer/withResponsiveContainer");
22
- var index_10 = require("../ChartTable/index");
22
+ var index_10 = require("../ScatterChart/index");
23
+ var index_11 = require("../ChartTable/index");
24
+ var index_12 = require("../Legends/index");
23
25
  var ResponsiveDonutChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_1.DonutChart);
24
26
  var ResponsiveVerticalStackedBarChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_2.VerticalStackedBarChart);
25
27
  var ResponsiveLineChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_3.LineChart);
@@ -30,17 +32,105 @@ var ResponsiveSankeyChart = (0, withResponsiveContainer_1.withResponsiveContaine
30
32
  var ResponsiveGaugeChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_7.GaugeChart);
31
33
  var ResponsiveGroupedVerticalBarChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_8.GroupedVerticalBarChart);
32
34
  var ResponsiveVerticalBarChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_9.VerticalBarChart);
33
- var ResponsiveChartTable = (0, withResponsiveContainer_1.withResponsiveContainer)(index_10.ChartTable);
35
+ var ResponsiveScatterChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_10.ScatterChart);
36
+ var ResponsiveChartTable = (0, withResponsiveContainer_1.withResponsiveContainer)(index_11.ChartTable);
37
+ // Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.
38
+ var DEFAULT_XAXIS = 'x';
39
+ var FALLBACK_TYPE = 'fallback';
34
40
  var useColorMapping = function () {
35
41
  var colorMap = React.useRef(new Map());
36
42
  return colorMap;
37
43
  };
44
+ function renderChart(Renderer,
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
+ transformer,
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ transformerArgs, commonProps, cellRow, cellColumn) {
49
+ var chartProps = transformer.apply(void 0, transformerArgs);
50
+ return (React.createElement("div", { key: "".concat(cellRow, "_").concat(cellColumn), style: {
51
+ gridRowStart: cellRow,
52
+ gridRowEnd: cellRow + 1,
53
+ gridColumnStart: cellColumn,
54
+ gridColumnEnd: cellColumn + 1,
55
+ } },
56
+ React.createElement(Renderer, tslib_1.__assign({}, chartProps, commonProps))));
57
+ }
58
+ var LineAreaPreTransformOp = function (plotlyInput) {
59
+ var xValues = plotlyInput.data[0].x;
60
+ var isXMonth = (0, chart_utilities_2.isMonthArray)(xValues);
61
+ var renderData = plotlyInput.data;
62
+ if (isXMonth) {
63
+ renderData = plotlyInput.data.map(function (dataPoint) { return (tslib_1.__assign(tslib_1.__assign({}, dataPoint), { x: (0, PlotlySchemaAdapter_1.correctYearMonth)(dataPoint.x) })); });
64
+ }
65
+ return { data: renderData, layout: plotlyInput.layout };
66
+ };
67
+ var chartMap = {
68
+ // PieData category charts
69
+ donut: {
70
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToDonutProps,
71
+ renderer: ResponsiveDonutChart,
72
+ },
73
+ // SankeyData category charts
74
+ sankey: {
75
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToSankeyProps,
76
+ renderer: ResponsiveSankeyChart,
77
+ },
78
+ // TableData category charts
79
+ table: {
80
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToChartTableProps,
81
+ renderer: ResponsiveChartTable,
82
+ },
83
+ // PlotData category charts
84
+ horizontalbar: {
85
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToHorizontalBarWithAxisProps,
86
+ renderer: ResponsiveHorizontalBarChartWithAxis,
87
+ },
88
+ groupedverticalbar: {
89
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToGVBCProps,
90
+ renderer: ResponsiveGroupedVerticalBarChart,
91
+ },
92
+ verticalstackedbar: {
93
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps,
94
+ renderer: ResponsiveVerticalStackedBarChart,
95
+ },
96
+ heatmap: {
97
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToHeatmapProps,
98
+ renderer: ResponsiveHeatMapChart,
99
+ },
100
+ gauge: {
101
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToGaugeProps,
102
+ renderer: ResponsiveGaugeChart,
103
+ },
104
+ verticalbar: {
105
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToVBCProps,
106
+ renderer: ResponsiveVerticalBarChart,
107
+ },
108
+ area: {
109
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToAreaChartProps,
110
+ renderer: ResponsiveAreaChart,
111
+ preTransformOperation: LineAreaPreTransformOp,
112
+ },
113
+ line: {
114
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToLineChartProps,
115
+ renderer: ResponsiveLineChart,
116
+ preTransformOperation: LineAreaPreTransformOp,
117
+ },
118
+ scatter: {
119
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps,
120
+ renderer: ResponsiveScatterChart,
121
+ preTransformOperation: LineAreaPreTransformOp,
122
+ },
123
+ fallback: {
124
+ transformer: PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps,
125
+ renderer: ResponsiveVerticalStackedBarChart,
126
+ },
127
+ };
38
128
  /**
39
129
  * DeclarativeChart component.
40
130
  * {@docCategory DeclarativeChart}
41
131
  */
42
132
  exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
43
- var _a, _b;
133
+ var _a;
44
134
  var plotlySchema = (0, chart_utilities_2.sanitizeJson)(props.chartSchema).plotlySchema;
45
135
  var chart = (0, chart_utilities_2.mapFluentChart)(plotlySchema);
46
136
  if (!chart.isValid) {
@@ -54,15 +144,17 @@ exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
54
144
  throw new Error("Failed to decode plotly schema: ".concat(error));
55
145
  }
56
146
  var plotlyInputWithValidData = tslib_1.__assign(tslib_1.__assign({}, plotlyInput), { data: chart.validTracesInfo.map(function (trace) { return plotlyInput.data[trace[0]]; }) });
147
+ var validTracesFilteredIndex = chart.validTracesInfo.map(function (trace, index) { return [index, trace[1]]; });
57
148
  var selectedLegends = plotlySchema.selectedLegends;
58
149
  var colorMap = useColorMapping();
59
150
  var theme = (0, react_1.useTheme)();
60
151
  var isDarkTheme = (_a = theme === null || theme === void 0 ? void 0 : theme.isInverted) !== null && _a !== void 0 ? _a : false;
61
152
  var chartRef = React.useRef(null);
153
+ var isMultiPlot = React.useRef(false);
62
154
  if (!(0, chart_utilities_2.isArrayOrTypedArray)(selectedLegends)) {
63
155
  selectedLegends = [];
64
156
  }
65
- var _c = React.useState(selectedLegends), activeLegends = _c[0], setActiveLegends = _c[1];
157
+ var _b = React.useState(selectedLegends), activeLegends = _b[0], setActiveLegends = _b[1];
66
158
  var onActiveLegendsChange = function (keys) {
67
159
  setActiveLegends(keys);
68
160
  if (props.onSchemaChange) {
@@ -86,51 +178,15 @@ exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
86
178
  componentRef: chartRef,
87
179
  calloutProps: { layerProps: { eventBubblingEnabled: true } },
88
180
  };
89
- var renderLineArea = function (plotlyData, isAreaChart) {
90
- var _a;
91
- var isScatterMarkers = [
92
- 'markers',
93
- 'text+markers',
94
- 'markers+text',
95
- 'lines+markers',
96
- 'markers+line',
97
- 'text+lines+markers',
98
- ].includes((_a = plotlyData[0]) === null || _a === void 0 ? void 0 : _a.mode);
99
- var chartProps = tslib_1.__assign(tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)({ data: plotlyData, layout: plotlyInput.layout }, isAreaChart, isScatterMarkers, colorMap, props.colorwayType, isDarkTheme)), commonProps);
100
- if (isAreaChart) {
101
- return React.createElement(ResponsiveAreaChart, tslib_1.__assign({}, chartProps));
102
- }
103
- return React.createElement(ResponsiveLineChart, tslib_1.__assign({}, chartProps));
104
- };
105
- var checkAndRenderChart = function (isAreaChart) {
106
- if (isAreaChart === void 0) { isAreaChart = false; }
107
- var fallbackVSBC = false;
108
- var xValues = plotlyInputWithValidData.data[0].x;
109
- var isXDate = (0, chart_utilities_2.isDateArray)(xValues);
110
- var isXNumber = (0, chart_utilities_2.isNumberArray)(xValues);
111
- var isXMonth = (0, PlotlySchemaAdapter_1.isMonthArray)(xValues);
112
- var isYString = (0, PlotlySchemaAdapter_1.isStringArray)(plotlyInputWithValidData.data[0].y);
113
- // Consider year as categorical variable not numeric continuous variable
114
- // Also year is not considered a date variable as it is represented as a point
115
- // in time and brings additional complexity of handling timezone and locale
116
- // formatting given the current design of the charting library
117
- var isXYear = (0, chart_utilities_2.isYearArray)(xValues);
118
- if ((isXDate || isXNumber) && !isXYear && !isYString) {
119
- return renderLineArea(plotlyInputWithValidData.data, isAreaChart);
120
- }
121
- else if (isXMonth) {
122
- var updatedData = plotlyInputWithValidData.data.map(function (dataPoint) { return (tslib_1.__assign(tslib_1.__assign({}, dataPoint), { x: (0, PlotlySchemaAdapter_1.correctYearMonth)(dataPoint.x) })); });
123
- return renderLineArea(updatedData, isAreaChart);
124
- }
125
- // Unsupported schema, render as VerticalStackedBarChart
126
- fallbackVSBC = true;
127
- if (isAreaChart) {
128
- throw new Error('Fallback to VerticalStackedBarChart is not allowed for Area Charts.');
129
- }
130
- return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme, fallbackVSBC), commonProps)));
131
- };
181
+ function createLegends(legendProps) {
182
+ // eslint-disable-next-line react/jsx-no-bind
183
+ return React.createElement(index_12.Legends, tslib_1.__assign({}, legendProps, { selectedLegends: activeLegends, onChange: onActiveLegendsChange }));
184
+ }
132
185
  var exportAsImage = React.useCallback(function (opts) {
133
186
  return new Promise(function (resolve, reject) {
187
+ if (isMultiPlot.current) {
188
+ return reject(Error('Exporting multi plot charts as image is not supported'));
189
+ }
134
190
  if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {
135
191
  return reject(Error('Chart cannot be exported as image'));
136
192
  }
@@ -143,39 +199,62 @@ exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
143
199
  React.useImperativeHandle(props.componentRef, function () { return ({
144
200
  exportAsImage: exportAsImage,
145
201
  }); }, [exportAsImage]);
146
- switch (chart.type) {
147
- case 'donut':
148
- return (React.createElement(ResponsiveDonutChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToDonutProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
149
- case 'horizontalbar':
150
- return (React.createElement(ResponsiveHorizontalBarChartWithAxis, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHorizontalBarWithAxisProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
151
- case 'groupedverticalbar':
152
- return (React.createElement(ResponsiveGroupedVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGVBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
153
- case 'verticalstackedbar':
154
- return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
155
- case 'heatmap':
156
- return (React.createElement(ResponsiveHeatMapChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHeatmapProps)(plotlyInputWithValidData), commonProps, { legendProps: {} })));
157
- case 'sankey':
158
- return (React.createElement(ResponsiveSankeyChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToSankeyProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
159
- case 'gauge':
160
- return (React.createElement(ResponsiveGaugeChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGaugeProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
161
- case 'verticalbar':
162
- return (React.createElement(ResponsiveVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
163
- case 'table':
164
- return (React.createElement(ResponsiveChartTable, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToChartTableProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
165
- case 'area':
166
- case 'line':
167
- case 'fallback':
168
- case 'scatterpolar':
169
- if (chart.type === 'scatterpolar') {
170
- var cartesianProjection = (0, PlotlySchemaAdapter_1.projectPolarToCartesian)(plotlyInputWithValidData);
171
- plotlyInputWithValidData.data = cartesianProjection.data;
202
+ if (chart.type === 'scatterpolar') {
203
+ var cartesianProjection = (0, PlotlySchemaAdapter_1.projectPolarToCartesian)(plotlyInputWithValidData);
204
+ plotlyInputWithValidData.data = cartesianProjection.data;
205
+ validTracesFilteredIndex.forEach(function (trace, index) {
206
+ if (trace[1] === 'scatterpolar') {
207
+ validTracesFilteredIndex[index][1] = 'line'; // Change type to line for rendering
172
208
  }
173
- // Need recheck for area chart as we don't have ability to check for valid months in previous step
174
- var isAreaChart = plotlyInputWithValidData.data.some(function (series) { return series.fill === 'tonexty' || series.fill === 'tozeroy' || !!series.stackgroup; });
175
- return checkAndRenderChart(isAreaChart);
176
- default:
177
- throw new Error("Unsupported chart type :".concat((_b = plotlyInputWithValidData.data[0]) === null || _b === void 0 ? void 0 : _b.type));
209
+ });
178
210
  }
211
+ var groupedTraces = {};
212
+ plotlyInputWithValidData.data.forEach(function (trace, index) {
213
+ var _a;
214
+ var xAxisKey = (_a = trace.xaxis) !== null && _a !== void 0 ? _a : DEFAULT_XAXIS;
215
+ if (!groupedTraces[xAxisKey]) {
216
+ groupedTraces[xAxisKey] = [];
217
+ }
218
+ groupedTraces[xAxisKey].push(index);
219
+ });
220
+ isMultiPlot.current = Object.keys(groupedTraces).length > 1;
221
+ var gridProperties = (0, PlotlySchemaAdapter_1.getGridProperties)(plotlyInputWithValidData.layout, isMultiPlot.current);
222
+ var allupLegendsProps = (0, PlotlySchemaAdapter_1.getAllupLegendsProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme);
223
+ // map through the grouped traces and render the appropriate chart
224
+ return (React.createElement(React.Fragment, null,
225
+ React.createElement("div", { style: {
226
+ display: 'grid',
227
+ gridTemplateRows: gridProperties.templateRows,
228
+ gridTemplateColumns: gridProperties.templateColumns,
229
+ } }, Object.entries(groupedTraces).map(function (_a) {
230
+ var _b, _c, _d;
231
+ var xAxisKey = _a[0], index = _a[1];
232
+ var plotlyInputForGroup = tslib_1.__assign(tslib_1.__assign({}, plotlyInputWithValidData), { data: index.map(function (idx) { return plotlyInputWithValidData.data[idx]; }) });
233
+ var filteredTracesInfo = validTracesFilteredIndex.filter(function (trace) { return index.includes(trace[0]); });
234
+ var chartType = validTracesFilteredIndex.some(function (trace) { return trace[1] === FALLBACK_TYPE; }) || chart.type === FALLBACK_TYPE
235
+ ? FALLBACK_TYPE
236
+ : filteredTracesInfo[0][1];
237
+ if (validTracesFilteredIndex.some(function (trace) { return trace[1] === 'line'; }) &&
238
+ validTracesFilteredIndex.some(function (trace) { return trace[1] === 'scatter'; })) {
239
+ chartType = 'line';
240
+ }
241
+ var chartEntry = chartMap[chartType];
242
+ if (chartEntry) {
243
+ var transformer = chartEntry.transformer, renderer = chartEntry.renderer, preTransformCondition = chartEntry.preTransformCondition, preTransformOperation = chartEntry.preTransformOperation;
244
+ if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {
245
+ var transformedInput = preTransformOperation
246
+ ? preTransformOperation(plotlyInputForGroup)
247
+ : plotlyInputForGroup;
248
+ var cellProperties = gridProperties.layout[xAxisKey];
249
+ return renderChart(renderer, transformer, [transformedInput, isMultiPlot.current, colorMap, props.colorwayType, isDarkTheme], tslib_1.__assign(tslib_1.__assign({}, commonProps), { xAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.xAnnotation, yAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.yAnnotation }), (_b = cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.row) !== null && _b !== void 0 ? _b : 1, (_c = cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.column) !== null && _c !== void 0 ? _c : 1);
250
+ }
251
+ return React.createElement(React.Fragment, null);
252
+ }
253
+ else {
254
+ throw new Error("Unsupported chart type :".concat((_d = plotlyInputForGroup.data[0]) === null || _d === void 0 ? void 0 : _d.type));
255
+ }
256
+ })),
257
+ isMultiPlot.current && createLegends(allupLegendsProps)));
179
258
  });
180
259
  exports.DeclarativeChart.displayName = 'DeclarativeChart';
181
260
  exports.DeclarativeChart.defaultProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";;;;AAAA,yDAAyD;AACzD,6BAA+B;AAC/B,yCAA2C;AAE3C,6CAAiD;AACjD,0DAA2E;AAC3E,6DAA+D;AAE/D,6DAOmC;AAEnC,6DAe+B;AAE/B,4CAAgE;AAChE,6DAAiF;AACjF,4CAAgE;AAChE,+CAAqD;AACrD,0DAAyD;AACzD,6CAAiD;AACjD,0DAA2E;AAC3E,mDAA6D;AAE7D,0FAAyF;AACzF,8CAAiD;AAEjD,IAAM,oBAAoB,GAAG,IAAA,iDAAuB,EAAC,kBAAU,CAAC,CAAC;AACjE,IAAM,iCAAiC,GAAG,IAAA,iDAAuB,EAAC,+BAAuB,CAAC,CAAC;AAC3F,IAAM,mBAAmB,GAAG,IAAA,iDAAuB,EAAC,iBAAS,CAAC,CAAC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AW,GAAG,wBAAwB,CAAC,IAAI,CAAC,IAAI,CACpD,UAAC,MAAgB,IAAK,OAAA,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,EAA7E,CAA6E,CACpG,CAAC;YACF,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC;QAC1C;YACE,MAAM,IAAI,KAAK,CAAC,kCAA2B,MAAA,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAE,CAAC,CAAC;IACzF,CAAC;AACH,CAAC,CAAC,CAAC;AACH,wBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAClD,wBAAgB,CAAC,YAAY,GAAG;IAC9B,YAAY,EAAE,SAAS;CACxB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport * as React from 'react';\nimport { useTheme } from '@fluentui/react';\nimport { IRefObject } from '@fluentui/react/lib/Utilities';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport { decodeBase64Fields } from '@fluentui/chart-utilities';\nimport type { Data, PlotData, PlotlySchema, OutputChartType } from '@fluentui/chart-utilities';\nimport {\n isArrayOrTypedArray,\n isDateArray,\n isNumberArray,\n isYearArray,\n mapFluentChart,\n sanitizeJson,\n} from '@fluentui/chart-utilities';\n\nimport {\n isMonthArray,\n correctYearMonth,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n transformPlotlyJsonToChartTableProps,\n projectPolarToCartesian,\n isStringArray,\n} from './PlotlySchemaAdapter';\nimport type { ColorwayType } from './PlotlyColorAdapter';\nimport { LineChart, ILineChartProps } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart, IAreaChartProps } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { IChart, IImageExportOptions } from '../../types/index';\nimport { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';\nimport { ChartTable } from '../ChartTable/index';\n\nconst ResponsiveDonutChart = withResponsiveContainer(DonutChart);\nconst ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);\nconst ResponsiveLineChart = withResponsiveContainer(LineChart);\nconst ResponsiveHorizontalBarChartWithAxis = withResponsiveContainer(HorizontalBarChartWithAxis);\nconst ResponsiveAreaChart = withResponsiveContainer(AreaChart);\nconst ResponsiveHeatMapChart = withResponsiveContainer(HeatMapChart);\nconst ResponsiveSankeyChart = withResponsiveContainer(SankeyChart);\nconst ResponsiveGaugeChart = withResponsiveContainer(GaugeChart);\nconst ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVerticalBarChart);\nconst ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);\nconst ResponsiveChartTable = withResponsiveContainer(ChartTable);\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IDeclarativeChart>;\n\n /**\n * Optional prop to specify the colorway type of the chart.\n * - 'default': Use Fluent UI color palette aligning with plotly colorway.\n * - 'builtin': Use Fluent UI colorway.\n * - 'others': Reserved for future colorways.\n * @default 'default'\n */\n colorwayType?: ColorwayType;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: IImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const chart: OutputChartType = mapFluentChart(plotlySchema);\n if (!chart.isValid) {\n throw new Error(`Invalid chart schema: ${chart.errorMessage}`);\n }\n let plotlyInput = plotlySchema as PlotlySchema;\n try {\n plotlyInput = decodeBase64Fields(plotlyInput);\n } catch (error) {\n throw new Error(`Failed to decode plotly schema: ${error}`);\n }\n const plotlyInputWithValidData: PlotlySchema = {\n ...plotlyInput,\n data: chart.validTracesInfo!.map(trace => plotlyInput.data[trace[0]]),\n };\n\n let { selectedLegends } = plotlySchema;\n const colorMap = useColorMapping();\n const theme = useTheme();\n const isDarkTheme = theme?.isInverted ?? false;\n const chartRef = React.useRef<IChart>(null);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { plotlyInput, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const multiSelectLegendProps = {\n canSelectMultipleLegends: true,\n onChange: onActiveLegendsChange,\n selectedLegends: activeLegends,\n };\n\n const commonProps = {\n legendProps: multiSelectLegendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n\n const renderLineArea = (plotlyData: Data[], isAreaChart: boolean): JSX.Element => {\n const isScatterMarkers = [\n 'markers',\n 'text+markers',\n 'markers+text',\n 'lines+markers',\n 'markers+line',\n 'text+lines+markers',\n ].includes((plotlyData[0] as PlotData)?.mode);\n const chartProps: ILineChartProps | IAreaChartProps = {\n ...transformPlotlyJsonToScatterChartProps(\n { data: plotlyData, layout: plotlyInput.layout },\n isAreaChart,\n isScatterMarkers,\n colorMap,\n props.colorwayType,\n isDarkTheme,\n ),\n ...commonProps,\n };\n if (isAreaChart) {\n return <ResponsiveAreaChart {...chartProps} />;\n }\n return <ResponsiveLineChart {...chartProps} />;\n };\n\n const checkAndRenderChart = (isAreaChart: boolean = false) => {\n let fallbackVSBC = false;\n const xValues = (plotlyInputWithValidData.data[0] as PlotData).x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const isXMonth = isMonthArray(xValues);\n const isYString = isStringArray((plotlyInputWithValidData.data[0] as Partial<PlotData>).y);\n\n // Consider year as categorical variable not numeric continuous variable\n // Also year is not considered a date variable as it is represented as a point\n // in time and brings additional complexity of handling timezone and locale\n // formatting given the current design of the charting library\n const isXYear = isYearArray(xValues);\n\n if ((isXDate || isXNumber) && !isXYear && !isYString) {\n return renderLineArea(plotlyInputWithValidData.data, isAreaChart);\n } else if (isXMonth) {\n const updatedData = plotlyInputWithValidData.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n return renderLineArea(updatedData, isAreaChart);\n }\n // Unsupported schema, render as VerticalStackedBarChart\n fallbackVSBC = true;\n if (isAreaChart) {\n throw new Error('Fallback to VerticalStackedBarChart is not allowed for Area Charts.');\n }\n return (\n <ResponsiveVerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(\n plotlyInputWithValidData,\n colorMap,\n props.colorwayType,\n isDarkTheme,\n fallbackVSBC,\n )}\n {...commonProps}\n />\n );\n };\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions): Promise<string> => {\n return new Promise((resolve, reject) => {\n if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {\n return reject(Error('Chart cannot be exported as image'));\n }\n\n chartRef.current\n .toImage({\n background: theme.semanticColors.bodyBackground,\n scale: 5,\n ...opts,\n })\n .then(resolve)\n .catch(reject);\n });\n },\n [theme],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n switch (chart.type) {\n case 'donut':\n return (\n <ResponsiveDonutChart\n {...transformPlotlyJsonToDonutProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'horizontalbar':\n return (\n <ResponsiveHorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(\n plotlyInputWithValidData,\n colorMap,\n props.colorwayType,\n isDarkTheme,\n )}\n {...commonProps}\n />\n );\n case 'groupedverticalbar':\n return (\n <ResponsiveGroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'verticalstackedbar':\n return (\n <ResponsiveVerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'heatmap':\n return (\n <ResponsiveHeatMapChart\n {...transformPlotlyJsonToHeatmapProps(plotlyInputWithValidData)}\n {...commonProps}\n legendProps={{}}\n />\n );\n case 'sankey':\n return (\n <ResponsiveSankeyChart\n {...transformPlotlyJsonToSankeyProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'gauge':\n return (\n <ResponsiveGaugeChart\n {...transformPlotlyJsonToGaugeProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'verticalbar':\n return (\n <ResponsiveVerticalBarChart\n {...transformPlotlyJsonToVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'table':\n return (\n <ResponsiveChartTable\n {...transformPlotlyJsonToChartTableProps(plotlyInputWithValidData, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'area':\n case 'line':\n case 'fallback':\n case 'scatterpolar':\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n }\n // Need recheck for area chart as we don't have ability to check for valid months in previous step\n const isAreaChart = plotlyInputWithValidData.data.some(\n (series: PlotData) => series.fill === 'tonexty' || series.fill === 'tozeroy' || !!series.stackgroup,\n );\n return checkAndRenderChart(isAreaChart);\n default:\n throw new Error(`Unsupported chart type :${plotlyInputWithValidData.data[0]?.type}`);\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\nDeclarativeChart.defaultProps = {\n colorwayType: 'default',\n};\n"]}
1
+ {"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";;;;AAAA,yDAAyD;AACzD,6BAA+B;AAC/B,yCAA2C;AAE3C,6CAAiD;AACjD,0DAA2E;AAC3E,6DAA+D;AAE/D,6DAA4G;AAG5G,6DAiB+B;AAE/B,4CAA+C;AAC/C,6DAAiF;AACjF,4CAA+C;AAC/C,+CAAqD;AACrD,0DAAyD;AACzD,6CAA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c,CAAE,WAAW,KAE9C,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,mCAAI,CAAC,EACxB,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,mCAAI,CAAC,CAC5B,CAAC;gBACJ,CAAC;gBACD,OAAO,yCAAK,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,kCAA2B,MAAA,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAE,CAAC,CAAC;YAClF,CAAC;QACH,CAAC,CAAC,CACE;QACL,WAAW,CAAC,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CACvD,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,wBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAClD,wBAAgB,CAAC,YAAY,GAAG;IAC9B,YAAY,EAAE,SAAS;CACxB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport * as React from 'react';\nimport { useTheme } from '@fluentui/react';\nimport { IRefObject } from '@fluentui/react/lib/Utilities';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport { decodeBase64Fields } from '@fluentui/chart-utilities';\nimport type { PlotData, PlotlySchema, OutputChartType } from '@fluentui/chart-utilities';\nimport { isArrayOrTypedArray, isMonthArray, mapFluentChart, sanitizeJson } from '@fluentui/chart-utilities';\n\nimport type { GridProperties } from './PlotlySchemaAdapter';\nimport {\n correctYearMonth,\n getGridProperties,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToAreaChartProps,\n transformPlotlyJsonToLineChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n transformPlotlyJsonToChartTableProps,\n transformPlotlyJsonToScatterChartProps,\n projectPolarToCartesian,\n getAllupLegendsProps,\n} from './PlotlySchemaAdapter';\nimport type { ColorwayType } from './PlotlyColorAdapter';\nimport { LineChart } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { IChart, IImageExportOptions } from '../../types/index';\nimport { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';\nimport { ScatterChart } from '../ScatterChart/index';\nimport { ChartTable } from '../ChartTable/index';\nimport { ILegendsProps, Legends } from '../Legends/index';\n\nconst ResponsiveDonutChart = withResponsiveContainer(DonutChart);\nconst ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);\nconst ResponsiveLineChart = withResponsiveContainer(LineChart);\nconst ResponsiveHorizontalBarChartWithAxis = withResponsiveContainer(HorizontalBarChartWithAxis);\nconst ResponsiveAreaChart = withResponsiveContainer(AreaChart);\nconst ResponsiveHeatMapChart = withResponsiveContainer(HeatMapChart);\nconst ResponsiveSankeyChart = withResponsiveContainer(SankeyChart);\nconst ResponsiveGaugeChart = withResponsiveContainer(GaugeChart);\nconst ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVerticalBarChart);\nconst ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);\nconst ResponsiveScatterChart = withResponsiveContainer(ScatterChart);\nconst ResponsiveChartTable = withResponsiveContainer(ChartTable);\n\n// Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.\nconst DEFAULT_XAXIS = 'x';\nconst FALLBACK_TYPE = 'fallback';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IDeclarativeChart>;\n\n /**\n * Optional prop to specify the colorway type of the chart.\n * - 'default': Use Fluent UI color palette aligning with plotly colorway.\n * - 'builtin': Use Fluent UI colorway.\n * - 'others': Reserved for future colorways.\n * @default 'default'\n */\n colorwayType?: ColorwayType;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: IImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\nfunction renderChart<TProps>(\n Renderer: React.ComponentType<TProps>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformer: (...args: any[]) => TProps,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformerArgs: any[],\n commonProps: Partial<TProps>,\n cellRow: number,\n cellColumn: number,\n): JSX.Element {\n const chartProps = transformer(...transformerArgs);\n return (\n <div\n key={`${cellRow}_${cellColumn}`}\n style={{\n gridRowStart: cellRow,\n gridRowEnd: cellRow + 1,\n gridColumnStart: cellColumn,\n gridColumnEnd: cellColumn + 1,\n }}\n >\n <Renderer {...chartProps} {...commonProps} />\n </div>\n );\n}\n\ntype PreTransformHooks = {\n preTransformCondition?: (plotlySchema: PlotlySchema) => boolean;\n preTransformOperation?: (plotlySchema: PlotlySchema) => PlotlySchema;\n};\n\nconst LineAreaPreTransformOp = (plotlyInput: PlotlySchema) => {\n const xValues = (plotlyInput.data[0] as PlotData).x;\n const isXMonth = isMonthArray(xValues);\n let renderData = plotlyInput.data;\n if (isXMonth) {\n renderData = plotlyInput.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n }\n return { data: renderData, layout: plotlyInput.layout };\n};\n\ntype ChartTypeMap = {\n donut: {\n transformer: typeof transformPlotlyJsonToDonutProps;\n renderer: typeof ResponsiveDonutChart;\n } & PreTransformHooks;\n sankey: {\n transformer: typeof transformPlotlyJsonToSankeyProps;\n renderer: typeof ResponsiveSankeyChart;\n } & PreTransformHooks;\n table: {\n transformer: typeof transformPlotlyJsonToChartTableProps;\n renderer: typeof ResponsiveChartTable;\n } & PreTransformHooks;\n horizontalbar: {\n transformer: typeof transformPlotlyJsonToHorizontalBarWithAxisProps;\n renderer: typeof ResponsiveHorizontalBarChartWithAxis;\n } & PreTransformHooks;\n groupedverticalbar: {\n transformer: typeof transformPlotlyJsonToGVBCProps;\n renderer: typeof ResponsiveGroupedVerticalBarChart;\n } & PreTransformHooks;\n verticalstackedbar: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n heatmap: {\n transformer: typeof transformPlotlyJsonToHeatmapProps;\n renderer: typeof ResponsiveHeatMapChart;\n } & PreTransformHooks;\n gauge: {\n transformer: typeof transformPlotlyJsonToGaugeProps;\n renderer: typeof ResponsiveGaugeChart;\n } & PreTransformHooks;\n verticalbar: {\n transformer: typeof transformPlotlyJsonToVBCProps;\n renderer: typeof ResponsiveVerticalBarChart;\n } & PreTransformHooks;\n area: {\n transformer: typeof transformPlotlyJsonToAreaChartProps;\n renderer: typeof ResponsiveAreaChart;\n } & PreTransformHooks;\n line: {\n transformer: typeof transformPlotlyJsonToLineChartProps;\n renderer: typeof ResponsiveLineChart;\n } & PreTransformHooks;\n scatter: {\n transformer: typeof transformPlotlyJsonToScatterChartProps;\n renderer: typeof ResponsiveScatterChart;\n } & PreTransformHooks;\n fallback: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n};\n\nconst chartMap: ChartTypeMap = {\n // PieData category charts\n donut: {\n transformer: transformPlotlyJsonToDonutProps,\n renderer: ResponsiveDonutChart,\n },\n // SankeyData category charts\n sankey: {\n transformer: transformPlotlyJsonToSankeyProps,\n renderer: ResponsiveSankeyChart,\n },\n // TableData category charts\n table: {\n transformer: transformPlotlyJsonToChartTableProps,\n renderer: ResponsiveChartTable,\n },\n // PlotData category charts\n horizontalbar: {\n transformer: transformPlotlyJsonToHorizontalBarWithAxisProps,\n renderer: ResponsiveHorizontalBarChartWithAxis,\n },\n groupedverticalbar: {\n transformer: transformPlotlyJsonToGVBCProps,\n renderer: ResponsiveGroupedVerticalBarChart,\n },\n verticalstackedbar: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n heatmap: {\n transformer: transformPlotlyJsonToHeatmapProps,\n renderer: ResponsiveHeatMapChart,\n },\n gauge: {\n transformer: transformPlotlyJsonToGaugeProps,\n renderer: ResponsiveGaugeChart,\n },\n verticalbar: {\n transformer: transformPlotlyJsonToVBCProps,\n renderer: ResponsiveVerticalBarChart,\n },\n area: {\n transformer: transformPlotlyJsonToAreaChartProps,\n renderer: ResponsiveAreaChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n line: {\n transformer: transformPlotlyJsonToLineChartProps,\n renderer: ResponsiveLineChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n scatter: {\n transformer: transformPlotlyJsonToScatterChartProps,\n renderer: ResponsiveScatterChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n fallback: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const chart: OutputChartType = mapFluentChart(plotlySchema);\n if (!chart.isValid) {\n throw new Error(`Invalid chart schema: ${chart.errorMessage}`);\n }\n let plotlyInput = plotlySchema as PlotlySchema;\n try {\n plotlyInput = decodeBase64Fields(plotlyInput);\n } catch (error) {\n throw new Error(`Failed to decode plotly schema: ${error}`);\n }\n const plotlyInputWithValidData: PlotlySchema = {\n ...plotlyInput,\n data: chart.validTracesInfo!.map(trace => plotlyInput.data[trace[0]]),\n };\n\n const validTracesFilteredIndex: [number, string][] = chart.validTracesInfo!.map((trace, index) => [index, trace[1]]);\n\n let { selectedLegends } = plotlySchema;\n const colorMap = useColorMapping();\n const theme = useTheme();\n const isDarkTheme = theme?.isInverted ?? false;\n const chartRef = React.useRef<IChart>(null);\n const isMultiPlot = React.useRef(false);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { plotlyInput, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const multiSelectLegendProps = {\n canSelectMultipleLegends: true,\n onChange: onActiveLegendsChange,\n selectedLegends: activeLegends,\n };\n\n const commonProps = {\n legendProps: multiSelectLegendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n\n function createLegends(legendProps: ILegendsProps): JSX.Element {\n // eslint-disable-next-line react/jsx-no-bind\n return <Legends {...legendProps} selectedLegends={activeLegends} onChange={onActiveLegendsChange} />;\n }\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions): Promise<string> => {\n return new Promise((resolve, reject) => {\n if (isMultiPlot.current) {\n return reject(Error('Exporting multi plot charts as image is not supported'));\n }\n if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {\n return reject(Error('Chart cannot be exported as image'));\n }\n\n chartRef.current\n .toImage({\n background: theme.semanticColors.bodyBackground,\n scale: 5,\n ...opts,\n })\n .then(resolve)\n .catch(reject);\n });\n },\n [theme],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n validTracesFilteredIndex.forEach((trace, index) => {\n if (trace[1] === 'scatterpolar') {\n validTracesFilteredIndex[index][1] = 'line'; // Change type to line for rendering\n }\n });\n }\n\n const groupedTraces: Record<string, number[]> = {};\n plotlyInputWithValidData.data.forEach((trace: Partial<PlotData>, index) => {\n const xAxisKey = trace.xaxis ?? DEFAULT_XAXIS;\n if (!groupedTraces[xAxisKey]) {\n groupedTraces[xAxisKey] = [];\n }\n groupedTraces[xAxisKey].push(index);\n });\n\n isMultiPlot.current = Object.keys(groupedTraces).length > 1;\n const gridProperties: GridProperties = getGridProperties(plotlyInputWithValidData.layout, isMultiPlot.current);\n\n const allupLegendsProps = getAllupLegendsProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme);\n\n type ChartType = keyof ChartTypeMap;\n // map through the grouped traces and render the appropriate chart\n return (\n <>\n <div\n style={{\n display: 'grid',\n gridTemplateRows: gridProperties.templateRows,\n gridTemplateColumns: gridProperties.templateColumns,\n }}\n >\n {Object.entries(groupedTraces).map(([xAxisKey, index]) => {\n const plotlyInputForGroup: PlotlySchema = {\n ...plotlyInputWithValidData,\n data: index.map(idx => plotlyInputWithValidData.data[idx]),\n };\n\n const filteredTracesInfo = validTracesFilteredIndex.filter(trace => index.includes(trace[0]));\n let chartType =\n validTracesFilteredIndex.some(trace => trace[1] === FALLBACK_TYPE) || chart.type === FALLBACK_TYPE\n ? FALLBACK_TYPE\n : filteredTracesInfo[0][1];\n\n if (\n validTracesFilteredIndex.some(trace => trace[1] === 'line') &&\n validTracesFilteredIndex.some(trace => trace[1] === 'scatter')\n ) {\n chartType = 'line';\n }\n\n const chartEntry = chartMap[chartType as ChartType];\n if (chartEntry) {\n const { transformer, renderer, preTransformCondition, preTransformOperation } = chartEntry;\n if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {\n const transformedInput = preTransformOperation\n ? preTransformOperation(plotlyInputForGroup)\n : plotlyInputForGroup;\n const cellProperties = gridProperties.layout[xAxisKey];\n\n return renderChart<ReturnType<typeof transformer>>(\n renderer,\n transformer,\n [transformedInput, isMultiPlot.current, colorMap, props.colorwayType, isDarkTheme],\n {\n ...commonProps,\n xAxisAnnotation: cellProperties?.xAnnotation,\n yAxisAnnotation: cellProperties?.yAnnotation,\n },\n cellProperties?.row ?? 1,\n cellProperties?.column ?? 1,\n );\n }\n return <></>;\n } else {\n throw new Error(`Unsupported chart type :${plotlyInputForGroup.data[0]?.type}`);\n }\n })}\n </div>\n {isMultiPlot.current && createLegends(allupLegendsProps)}\n </>\n );\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\nDeclarativeChart.defaultProps = {\n colorwayType: 'default',\n};\n"]}