@fluentui/react-charting 5.23.88 → 5.23.90

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 (110) hide show
  1. package/CHANGELOG.json +67 -1
  2. package/CHANGELOG.md +26 -2
  3. package/dist/react-charting.d.ts +72 -6
  4. package/dist/react-charting.js +1 -1
  5. package/dist/react-charting.min.js +1 -1
  6. package/etc/react-charting.api.md +37 -1
  7. package/lib/ChartTable.d.ts +1 -0
  8. package/lib/ChartTable.js +2 -0
  9. package/lib/ChartTable.js.map +1 -0
  10. package/lib/components/ChartTable/ChartTable.base.d.ts +10 -0
  11. package/lib/components/ChartTable/ChartTable.base.js +44 -0
  12. package/lib/components/ChartTable/ChartTable.base.js.map +1 -0
  13. package/lib/components/ChartTable/ChartTable.d.ts +7 -0
  14. package/lib/components/ChartTable/ChartTable.js +9 -0
  15. package/lib/components/ChartTable/ChartTable.js.map +1 -0
  16. package/lib/components/ChartTable/ChartTable.styles.d.ts +2 -0
  17. package/lib/components/ChartTable/ChartTable.styles.js +28 -0
  18. package/lib/components/ChartTable/ChartTable.styles.js.map +1 -0
  19. package/lib/components/ChartTable/ChartTable.types.d.ts +58 -0
  20. package/lib/components/ChartTable/ChartTable.types.js +2 -0
  21. package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
  22. package/lib/components/ChartTable/index.d.ts +2 -0
  23. package/lib/components/ChartTable/index.js +3 -0
  24. package/lib/components/ChartTable/index.js.map +1 -0
  25. package/lib/components/DeclarativeChart/DeclarativeChart.d.ts +7 -6
  26. package/lib/components/DeclarativeChart/DeclarativeChart.js +15 -12
  27. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  28. package/lib/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
  29. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +103 -0
  30. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  31. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -13
  32. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +141 -120
  33. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  34. package/lib/components/LineChart/LineChart.base.js +19 -9
  35. package/lib/components/LineChart/LineChart.base.js.map +1 -1
  36. package/lib/index.d.ts +2 -0
  37. package/lib/index.js +1 -0
  38. package/lib/index.js.map +1 -1
  39. package/lib/utilities/image-export-utils.js +25 -3
  40. package/lib/utilities/image-export-utils.js.map +1 -1
  41. package/lib-amd/ChartTable.d.ts +1 -0
  42. package/lib-amd/ChartTable.js +6 -0
  43. package/lib-amd/ChartTable.js.map +1 -0
  44. package/lib-amd/components/ChartTable/ChartTable.base.d.ts +10 -0
  45. package/lib-amd/components/ChartTable/ChartTable.base.js +45 -0
  46. package/lib-amd/components/ChartTable/ChartTable.base.js.map +1 -0
  47. package/lib-amd/components/ChartTable/ChartTable.d.ts +7 -0
  48. package/lib-amd/components/ChartTable/ChartTable.js +11 -0
  49. package/lib-amd/components/ChartTable/ChartTable.js.map +1 -0
  50. package/lib-amd/components/ChartTable/ChartTable.styles.d.ts +2 -0
  51. package/lib-amd/components/ChartTable/ChartTable.styles.js +32 -0
  52. package/lib-amd/components/ChartTable/ChartTable.styles.js.map +1 -0
  53. package/lib-amd/components/ChartTable/ChartTable.types.d.ts +58 -0
  54. package/lib-amd/components/ChartTable/ChartTable.types.js +5 -0
  55. package/lib-amd/components/ChartTable/ChartTable.types.js.map +1 -0
  56. package/lib-amd/components/ChartTable/index.d.ts +2 -0
  57. package/lib-amd/components/ChartTable/index.js +7 -0
  58. package/lib-amd/components/ChartTable/index.js.map +1 -0
  59. package/lib-amd/components/DeclarativeChart/DeclarativeChart.d.ts +7 -6
  60. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +14 -12
  61. package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  62. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
  63. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +108 -0
  64. package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  65. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -13
  66. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +143 -124
  67. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  68. package/lib-amd/components/LineChart/LineChart.base.js +19 -9
  69. package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
  70. package/lib-amd/index.d.ts +2 -0
  71. package/lib-amd/index.js +3 -2
  72. package/lib-amd/index.js.map +1 -1
  73. package/lib-amd/utilities/image-export-utils.js +25 -3
  74. package/lib-amd/utilities/image-export-utils.js.map +1 -1
  75. package/lib-commonjs/ChartTable.d.ts +1 -0
  76. package/lib-commonjs/ChartTable.js +5 -0
  77. package/lib-commonjs/ChartTable.js.map +1 -0
  78. package/lib-commonjs/components/ChartTable/ChartTable.base.d.ts +10 -0
  79. package/lib-commonjs/components/ChartTable/ChartTable.base.js +47 -0
  80. package/lib-commonjs/components/ChartTable/ChartTable.base.js.map +1 -0
  81. package/lib-commonjs/components/ChartTable/ChartTable.d.ts +7 -0
  82. package/lib-commonjs/components/ChartTable/ChartTable.js +12 -0
  83. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
  84. package/lib-commonjs/components/ChartTable/ChartTable.styles.d.ts +2 -0
  85. package/lib-commonjs/components/ChartTable/ChartTable.styles.js +32 -0
  86. package/lib-commonjs/components/ChartTable/ChartTable.styles.js.map +1 -0
  87. package/lib-commonjs/components/ChartTable/ChartTable.types.d.ts +58 -0
  88. package/lib-commonjs/components/ChartTable/ChartTable.types.js +3 -0
  89. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
  90. package/lib-commonjs/components/ChartTable/index.d.ts +2 -0
  91. package/lib-commonjs/components/ChartTable/index.js +6 -0
  92. package/lib-commonjs/components/ChartTable/index.js.map +1 -0
  93. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.d.ts +7 -6
  94. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +14 -11
  95. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  96. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.d.ts +7 -0
  97. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +110 -0
  98. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  99. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -13
  100. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +143 -124
  101. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  102. package/lib-commonjs/components/LineChart/LineChart.base.js +19 -9
  103. package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
  104. package/lib-commonjs/index.d.ts +2 -0
  105. package/lib-commonjs/index.js +3 -1
  106. package/lib-commonjs/index.js.map +1 -1
  107. package/lib-commonjs/utilities/image-export-utils.js +25 -3
  108. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  109. package/package.json +4 -4
  110. package/src/components/ChartTable/ChartTable.types.ts +68 -0
package/lib-amd/index.js CHANGED
@@ -1,7 +1,7 @@
1
- define(["require", "exports", "./HorizontalBarChart", "./DonutChart", "./Legends", "./LineChart", "./AreaChart", "./PieChart", "./StackedBarChart", "./VerticalBarChart", "./VerticalStackedBarChart", "./GroupedVerticalBarChart", "./CartesianChart", "./utilities/ChartHoverCard/index", "./HeatMapChart", "./SankeyChart", "./TreeChart", "./Sparkline", "./HorizontalBarChartWithAxis", "./utilities/colors", "./utilities/gradients", "./GaugeChart", "./DeclarativeChart", "./ResponsiveContainer", "./version"], function (require, exports, HorizontalBarChart_1, DonutChart_1, Legends_1, LineChart_1, AreaChart_1, PieChart_1, StackedBarChart_1, VerticalBarChart_1, VerticalStackedBarChart_1, GroupedVerticalBarChart_1, CartesianChart_1, index_1, HeatMapChart_1, SankeyChart_1, TreeChart_1, Sparkline_1, HorizontalBarChartWithAxis_1, colors_1, gradients_1, GaugeChart_1, DeclarativeChart_1, ResponsiveContainer_1) {
1
+ define(["require", "exports", "./HorizontalBarChart", "./DonutChart", "./Legends", "./LineChart", "./AreaChart", "./PieChart", "./StackedBarChart", "./VerticalBarChart", "./VerticalStackedBarChart", "./GroupedVerticalBarChart", "./CartesianChart", "./utilities/ChartHoverCard/index", "./HeatMapChart", "./SankeyChart", "./TreeChart", "./Sparkline", "./ChartTable", "./HorizontalBarChartWithAxis", "./utilities/colors", "./utilities/gradients", "./GaugeChart", "./DeclarativeChart", "./ResponsiveContainer", "./version"], function (require, exports, HorizontalBarChart_1, DonutChart_1, Legends_1, LineChart_1, AreaChart_1, PieChart_1, StackedBarChart_1, VerticalBarChart_1, VerticalStackedBarChart_1, GroupedVerticalBarChart_1, CartesianChart_1, index_1, HeatMapChart_1, SankeyChart_1, TreeChart_1, Sparkline_1, ChartTable_1, HorizontalBarChartWithAxis_1, colors_1, gradients_1, GaugeChart_1, DeclarativeChart_1, ResponsiveContainer_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.withResponsiveContainer = exports.ResponsiveContainer = exports.DeclarativeChart = exports.GaugeValueFormat = exports.GaugeChartVariant = exports.GaugeChart = exports.getNextGradient = exports.getGradientFromToken = exports.DataVizGradientPalette = exports.getNextColor = exports.getColorFromToken = exports.DataVizPalette = exports.HorizontalBarChartWithAxis = exports.Sparkline = exports.TreeTraverse = exports.TreeChart = exports.NodesComposition = exports.SankeyChart = exports.HeatMapChart = exports.getChartHoverCardStyles = exports.ChartHoverCard = exports.CartesianChart = exports.GroupedVerticalBarChart = exports.VerticalStackedBarChart = exports.VerticalBarChart = exports.StackedBarChart = exports.MultiStackedBarChartVariant = exports.MultiStackedBarChart = exports.PieChart = exports.AreaChart = exports.Textbox = exports.LineChart = exports.Shape = exports.Legends = exports.DonutChart = exports.HorizontalBarChartVariant = exports.HorizontalBarChart = void 0;
4
+ exports.withResponsiveContainer = exports.ResponsiveContainer = exports.DeclarativeChart = exports.GaugeValueFormat = exports.GaugeChartVariant = exports.GaugeChart = exports.getNextGradient = exports.getGradientFromToken = exports.DataVizGradientPalette = exports.getNextColor = exports.getColorFromToken = exports.DataVizPalette = exports.HorizontalBarChartWithAxis = exports.ChartTable = exports.Sparkline = exports.TreeTraverse = exports.TreeChart = exports.NodesComposition = exports.SankeyChart = exports.HeatMapChart = exports.getChartHoverCardStyles = exports.ChartHoverCard = exports.CartesianChart = exports.GroupedVerticalBarChart = exports.VerticalStackedBarChart = exports.VerticalBarChart = exports.StackedBarChart = exports.MultiStackedBarChartVariant = exports.MultiStackedBarChart = exports.PieChart = exports.AreaChart = exports.Textbox = exports.LineChart = exports.Shape = exports.Legends = exports.DonutChart = exports.HorizontalBarChartVariant = exports.HorizontalBarChart = void 0;
5
5
  Object.defineProperty(exports, "HorizontalBarChart", { enumerable: true, get: function () { return HorizontalBarChart_1.HorizontalBarChart; } });
6
6
  Object.defineProperty(exports, "HorizontalBarChartVariant", { enumerable: true, get: function () { return HorizontalBarChart_1.HorizontalBarChartVariant; } });
7
7
  Object.defineProperty(exports, "DonutChart", { enumerable: true, get: function () { return DonutChart_1.DonutChart; } });
@@ -26,6 +26,7 @@ define(["require", "exports", "./HorizontalBarChart", "./DonutChart", "./Legends
26
26
  Object.defineProperty(exports, "TreeChart", { enumerable: true, get: function () { return TreeChart_1.TreeChart; } });
27
27
  Object.defineProperty(exports, "TreeTraverse", { enumerable: true, get: function () { return TreeChart_1.TreeTraverse; } });
28
28
  Object.defineProperty(exports, "Sparkline", { enumerable: true, get: function () { return Sparkline_1.Sparkline; } });
29
+ Object.defineProperty(exports, "ChartTable", { enumerable: true, get: function () { return ChartTable_1.ChartTable; } });
29
30
  Object.defineProperty(exports, "HorizontalBarChartWithAxis", { enumerable: true, get: function () { return HorizontalBarChartWithAxis_1.HorizontalBarChartWithAxis; } });
30
31
  Object.defineProperty(exports, "DataVizPalette", { enumerable: true, get: function () { return colors_1.DataVizPalette; } });
31
32
  Object.defineProperty(exports, "getColorFromToken", { enumerable: true, get: function () { return colors_1.getColorFromToken; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;;IAMS,wHAAA,kBAAkB,OAAA;IAAE,+HAAA,yBAAyB,OAAA;IAE7C,wGAAA,UAAU,OAAA;IAWV,kGAAA,OAAO,OAAA;IAAE,gGAAA,KAAK,OAAA;IASd,sGAAA,SAAS,OAAA;IAAE,oGAAA,OAAO,OAAA;IAElB,sGAAA,SAAS,OAAA;IAET,oGAAA,QAAQ,OAAA;IAUR,uHAAA,oBAAoB,OAAA;IAAE,8HAAA,2BAA2B,OAAA;IAAE,kHAAA,eAAe,OAAA;IAElE,oHAAA,gBAAgB,OAAA;IAMhB,kIAAA,uBAAuB,OAAA;IAMvB,kIAAA,uBAAuB,OAAA;IASvB,gHAAA,cAAc,OAAA;IA0Cd,uGAAA,cAAc,OAAA;IAAE,gHAAA,uBAAuB,OAAA;IAEvC,4GAAA,YAAY,OAAA;IAQZ,0GAAA,WAAW,OAAA;IASX,6GAAA,gBAAgB,OAAA;IAAE,sGAAA,SAAS,OAAA;IAAE,yGAAA,YAAY,OAAA;IAEzC,sGAAA,SAAS,OAAA;IAMT,wIAAA,0BAA0B,OAAA;IAC1B,wGAAA,cAAc,OAAA;IAAE,2GAAA,iBAAiB,OAAA;IAAE,sGAAA,YAAY,OAAA;IAC/C,mHAAA,sBAAsB,OAAA;IAAE,iHAAA,oBAAoB,OAAA;IAAE,4GAAA,eAAe,OAAA;IAE7D,wGAAA,UAAU,OAAA;IAAE,+GAAA,iBAAiB,OAAA;IAAE,8GAAA,gBAAgB,OAAA;IAE/C,oHAAA,gBAAgB,OAAA;IAEhB,0HAAA,mBAAmB,OAAA;IAAE,8HAAA,uBAAuB,OAAA","sourcesContent":["export type {\n ChartDataMode,\n IHorizontalBarChartProps,\n IHorizontalBarChartStyleProps,\n IHorizontalBarChartStyles,\n} from './HorizontalBarChart';\nexport { HorizontalBarChart, HorizontalBarChartVariant } from './HorizontalBarChart';\nexport type { IDonutChart, IDonutChartProps, IDonutChartStyleProps, IDonutChartStyles } from './DonutChart';\nexport { DonutChart } from './DonutChart';\nexport type {\n ILegend,\n ILegendOverflowData,\n ILegendStyleProps,\n ILegendSubComponentStyles,\n ILegendsProps,\n ILegendsStyles,\n IShapeProps,\n LegendShape,\n} from './Legends';\nexport { Legends, Shape } from './Legends';\nexport type {\n IColorFillBarData,\n IColorFillBarsProps,\n IEventsAnnotationProps,\n ILineChartProps,\n ILineChartStyleProps,\n ILineChartStyles,\n} from './LineChart';\nexport { LineChart, Textbox } from './LineChart';\nexport type { IAreaChartProps, IAreaChartStyleProps, IAreaChartStyles } from './AreaChart';\nexport { AreaChart } from './AreaChart';\nexport type { IPieChart, IPieChartProps, IPieChartStyleProps, IPieChartStyles } from './PieChart';\nexport { PieChart } from './PieChart';\nexport type {\n IMultiStackedBarChartProps,\n IMultiStackedBarChartStyleProps,\n IMultiStackedBarChartStyles,\n IStackedBarChart,\n IStackedBarChartProps,\n IStackedBarChartStyleProps,\n IStackedBarChartStyles,\n} from './StackedBarChart';\nexport { MultiStackedBarChart, MultiStackedBarChartVariant, StackedBarChart } from './StackedBarChart';\nexport type { IVerticalBarChartProps, IVerticalBarChartStyleProps, IVerticalBarChartStyles } from './VerticalBarChart';\nexport { VerticalBarChart } from './VerticalBarChart';\nexport type {\n IVerticalStackedBarChartProps,\n IVerticalStackedBarChartStyleProps,\n IVerticalStackedBarChartStyles,\n} from './VerticalStackedBarChart';\nexport { VerticalStackedBarChart } from './VerticalStackedBarChart';\nexport type {\n IGroupedVerticalBarChartProps,\n IGroupedVerticalBarChartStyleProps,\n IGroupedVerticalBarChartStyles,\n} from './GroupedVerticalBarChart';\nexport { GroupedVerticalBarChart } from './GroupedVerticalBarChart';\nexport type {\n ICartesianChartProps,\n ICartesianChartStyleProps,\n ICartesianChartStyles,\n IChildProps,\n IModifiedCartesianChartProps,\n IYValueHover,\n} from './CartesianChart';\nexport { CartesianChart } from './CartesianChart';\nexport type {\n IAccessibilityProps,\n IBasestate,\n IChartDataPoint,\n IChartProps,\n ICustomizedCalloutData,\n ICustomizedCalloutDataPoint,\n IDataPoint,\n IGVBarChartSeriesPoint,\n IGVDataPoint,\n IGVForBarChart,\n IGVSingleDataPoint,\n IGroupedVerticalBarChartData,\n IHeatMapChartData,\n IHeatMapChartDataPoint,\n IHorizontalBarChartWithAxisDataPoint,\n IHorizontalDataPoint,\n ILegendDataItem,\n ILineChartDataPoint,\n ILineChartGap,\n ILineChartLineOptions,\n ILineChartPoints,\n ILineDataInVerticalBarChart,\n ILineDataInVerticalStackedBarChart,\n IMargins,\n IRefArrayData,\n ISankeyChartData,\n IVSChartDataPoint,\n IVerticalBarChartDataPoint,\n IVerticalStackedBarDataPoint,\n IVerticalStackedChartProps,\n SLink,\n SNode,\n IChart,\n IImageExportOptions,\n} from './types/index';\nexport type {\n IChartHoverCardProps,\n IChartHoverCardStyleProps,\n IChartHoverCardStyles,\n} from './utilities/ChartHoverCard/index';\nexport { ChartHoverCard, getChartHoverCardStyles } from './utilities/ChartHoverCard/index';\nexport type { IHeatMapChartProps, IHeatMapChartStyleProps, IHeatMapChartStyles } from './HeatMapChart';\nexport { HeatMapChart } from './HeatMapChart';\nexport type {\n ISankeyChartAccessibilityProps,\n ISankeyChartProps,\n ISankeyChartStrings,\n ISankeyChartStyleProps,\n ISankeyChartStyles,\n} from './SankeyChart';\nexport { SankeyChart } from './SankeyChart';\nexport type {\n ITreeChartDataPoint,\n ITreeDataStructure,\n ITreeProps,\n ITreeState,\n ITreeStyleProps,\n ITreeStyles,\n} from './TreeChart';\nexport { NodesComposition, TreeChart, TreeTraverse } from './TreeChart';\nexport type { ISparklineProps, ISparklineStyleProps, ISparklineStyles } from './Sparkline';\nexport { Sparkline } from './Sparkline';\nexport type {\n IHorizontalBarChartWithAxisProps,\n IHorizontalBarChartWithAxisStyleProps,\n IHorizontalBarChartWithAxisStyles,\n} from './HorizontalBarChartWithAxis';\nexport { HorizontalBarChartWithAxis } from './HorizontalBarChartWithAxis';\nexport { DataVizPalette, getColorFromToken, getNextColor } from './utilities/colors';\nexport { DataVizGradientPalette, getGradientFromToken, getNextGradient } from './utilities/gradients';\nexport type { IGaugeChartProps, IGaugeChartSegment, IGaugeChartStyleProps, IGaugeChartStyles } from './GaugeChart';\nexport { GaugeChart, GaugeChartVariant, GaugeValueFormat } from './GaugeChart';\nexport type { DeclarativeChartProps, Schema, IDeclarativeChart } from './DeclarativeChart';\nexport { DeclarativeChart } from './DeclarativeChart';\nexport type { IResponsiveContainerProps, IResponsiveChildProps } from './ResponsiveContainer';\nexport { ResponsiveContainer, withResponsiveContainer } from './ResponsiveContainer';\n\nimport './version';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;;IAMS,wHAAA,kBAAkB,OAAA;IAAE,+HAAA,yBAAyB,OAAA;IAE7C,wGAAA,UAAU,OAAA;IAWV,kGAAA,OAAO,OAAA;IAAE,gGAAA,KAAK,OAAA;IASd,sGAAA,SAAS,OAAA;IAAE,oGAAA,OAAO,OAAA;IAElB,sGAAA,SAAS,OAAA;IAET,oGAAA,QAAQ,OAAA;IAUR,uHAAA,oBAAoB,OAAA;IAAE,8HAAA,2BAA2B,OAAA;IAAE,kHAAA,eAAe,OAAA;IAElE,oHAAA,gBAAgB,OAAA;IAMhB,kIAAA,uBAAuB,OAAA;IAMvB,kIAAA,uBAAuB,OAAA;IASvB,gHAAA,cAAc,OAAA;IA0Cd,uGAAA,cAAc,OAAA;IAAE,gHAAA,uBAAuB,OAAA;IAEvC,4GAAA,YAAY,OAAA;IAQZ,0GAAA,WAAW,OAAA;IASX,6GAAA,gBAAgB,OAAA;IAAE,sGAAA,SAAS,OAAA;IAAE,yGAAA,YAAY,OAAA;IAEzC,sGAAA,SAAS,OAAA;IAET,wGAAA,UAAU,OAAA;IAMV,wIAAA,0BAA0B,OAAA;IAC1B,wGAAA,cAAc,OAAA;IAAE,2GAAA,iBAAiB,OAAA;IAAE,sGAAA,YAAY,OAAA;IAC/C,mHAAA,sBAAsB,OAAA;IAAE,iHAAA,oBAAoB,OAAA;IAAE,4GAAA,eAAe,OAAA;IAE7D,wGAAA,UAAU,OAAA;IAAE,+GAAA,iBAAiB,OAAA;IAAE,8GAAA,gBAAgB,OAAA;IAE/C,oHAAA,gBAAgB,OAAA;IAEhB,0HAAA,mBAAmB,OAAA;IAAE,8HAAA,uBAAuB,OAAA","sourcesContent":["export type {\n ChartDataMode,\n IHorizontalBarChartProps,\n IHorizontalBarChartStyleProps,\n IHorizontalBarChartStyles,\n} from './HorizontalBarChart';\nexport { HorizontalBarChart, HorizontalBarChartVariant } from './HorizontalBarChart';\nexport type { IDonutChart, IDonutChartProps, IDonutChartStyleProps, IDonutChartStyles } from './DonutChart';\nexport { DonutChart } from './DonutChart';\nexport type {\n ILegend,\n ILegendOverflowData,\n ILegendStyleProps,\n ILegendSubComponentStyles,\n ILegendsProps,\n ILegendsStyles,\n IShapeProps,\n LegendShape,\n} from './Legends';\nexport { Legends, Shape } from './Legends';\nexport type {\n IColorFillBarData,\n IColorFillBarsProps,\n IEventsAnnotationProps,\n ILineChartProps,\n ILineChartStyleProps,\n ILineChartStyles,\n} from './LineChart';\nexport { LineChart, Textbox } from './LineChart';\nexport type { IAreaChartProps, IAreaChartStyleProps, IAreaChartStyles } from './AreaChart';\nexport { AreaChart } from './AreaChart';\nexport type { IPieChart, IPieChartProps, IPieChartStyleProps, IPieChartStyles } from './PieChart';\nexport { PieChart } from './PieChart';\nexport type {\n IMultiStackedBarChartProps,\n IMultiStackedBarChartStyleProps,\n IMultiStackedBarChartStyles,\n IStackedBarChart,\n IStackedBarChartProps,\n IStackedBarChartStyleProps,\n IStackedBarChartStyles,\n} from './StackedBarChart';\nexport { MultiStackedBarChart, MultiStackedBarChartVariant, StackedBarChart } from './StackedBarChart';\nexport type { IVerticalBarChartProps, IVerticalBarChartStyleProps, IVerticalBarChartStyles } from './VerticalBarChart';\nexport { VerticalBarChart } from './VerticalBarChart';\nexport type {\n IVerticalStackedBarChartProps,\n IVerticalStackedBarChartStyleProps,\n IVerticalStackedBarChartStyles,\n} from './VerticalStackedBarChart';\nexport { VerticalStackedBarChart } from './VerticalStackedBarChart';\nexport type {\n IGroupedVerticalBarChartProps,\n IGroupedVerticalBarChartStyleProps,\n IGroupedVerticalBarChartStyles,\n} from './GroupedVerticalBarChart';\nexport { GroupedVerticalBarChart } from './GroupedVerticalBarChart';\nexport type {\n ICartesianChartProps,\n ICartesianChartStyleProps,\n ICartesianChartStyles,\n IChildProps,\n IModifiedCartesianChartProps,\n IYValueHover,\n} from './CartesianChart';\nexport { CartesianChart } from './CartesianChart';\nexport type {\n IAccessibilityProps,\n IBasestate,\n IChartDataPoint,\n IChartProps,\n ICustomizedCalloutData,\n ICustomizedCalloutDataPoint,\n IDataPoint,\n IGVBarChartSeriesPoint,\n IGVDataPoint,\n IGVForBarChart,\n IGVSingleDataPoint,\n IGroupedVerticalBarChartData,\n IHeatMapChartData,\n IHeatMapChartDataPoint,\n IHorizontalBarChartWithAxisDataPoint,\n IHorizontalDataPoint,\n ILegendDataItem,\n ILineChartDataPoint,\n ILineChartGap,\n ILineChartLineOptions,\n ILineChartPoints,\n ILineDataInVerticalBarChart,\n ILineDataInVerticalStackedBarChart,\n IMargins,\n IRefArrayData,\n ISankeyChartData,\n IVSChartDataPoint,\n IVerticalBarChartDataPoint,\n IVerticalStackedBarDataPoint,\n IVerticalStackedChartProps,\n SLink,\n SNode,\n IChart,\n IImageExportOptions,\n} from './types/index';\nexport type {\n IChartHoverCardProps,\n IChartHoverCardStyleProps,\n IChartHoverCardStyles,\n} from './utilities/ChartHoverCard/index';\nexport { ChartHoverCard, getChartHoverCardStyles } from './utilities/ChartHoverCard/index';\nexport type { IHeatMapChartProps, IHeatMapChartStyleProps, IHeatMapChartStyles } from './HeatMapChart';\nexport { HeatMapChart } from './HeatMapChart';\nexport type {\n ISankeyChartAccessibilityProps,\n ISankeyChartProps,\n ISankeyChartStrings,\n ISankeyChartStyleProps,\n ISankeyChartStyles,\n} from './SankeyChart';\nexport { SankeyChart } from './SankeyChart';\nexport type {\n ITreeChartDataPoint,\n ITreeDataStructure,\n ITreeProps,\n ITreeState,\n ITreeStyleProps,\n ITreeStyles,\n} from './TreeChart';\nexport { NodesComposition, TreeChart, TreeTraverse } from './TreeChart';\nexport type { ISparklineProps, ISparklineStyleProps, ISparklineStyles } from './Sparkline';\nexport { Sparkline } from './Sparkline';\nexport type { IChartTableProps, IChartTableStyleProps, IChartTableStyles } from './ChartTable';\nexport { ChartTable } from './ChartTable';\nexport type {\n IHorizontalBarChartWithAxisProps,\n IHorizontalBarChartWithAxisStyleProps,\n IHorizontalBarChartWithAxisStyles,\n} from './HorizontalBarChartWithAxis';\nexport { HorizontalBarChartWithAxis } from './HorizontalBarChartWithAxis';\nexport { DataVizPalette, getColorFromToken, getNextColor } from './utilities/colors';\nexport { DataVizGradientPalette, getGradientFromToken, getNextGradient } from './utilities/gradients';\nexport type { IGaugeChartProps, IGaugeChartSegment, IGaugeChartStyleProps, IGaugeChartStyles } from './GaugeChart';\nexport { GaugeChart, GaugeChartVariant, GaugeValueFormat } from './GaugeChart';\nexport type { DeclarativeChartProps, Schema, IDeclarativeChart } from './DeclarativeChart';\nexport { DeclarativeChart } from './DeclarativeChart';\nexport type { IResponsiveContainerProps, IResponsiveChildProps } from './ResponsiveContainer';\nexport { ResponsiveContainer, withResponsiveContainer } from './ResponsiveContainer';\n\nimport './version';\n"]}
@@ -28,8 +28,27 @@ define(["require", "exports", "tslib", "d3-selection", "./index", "../components
28
28
  });
29
29
  }
30
30
  exports.toImage = toImage;
31
- var SVG_STYLE_PROPERTIES = ['display', 'fill', 'fill-opacity', 'opacity', 'stroke', 'stroke-width', 'transform'];
32
- var SVG_TEXT_STYLE_PROPERTIES = ['font-family', 'font-size', 'font-weight', 'text-anchor'];
31
+ var SVG_STYLE_PROPERTIES = [
32
+ 'display',
33
+ 'fill',
34
+ 'fill-opacity',
35
+ 'opacity',
36
+ 'stroke',
37
+ 'stroke-width',
38
+ 'transform',
39
+ 'border-collapse',
40
+ ];
41
+ var SVG_TEXT_STYLE_PROPERTIES = [
42
+ 'font-family',
43
+ 'font-size',
44
+ 'font-weight',
45
+ 'text-anchor',
46
+ 'background-color',
47
+ 'color',
48
+ 'padding',
49
+ 'text-align',
50
+ 'border',
51
+ ];
33
52
  function toSVG(chartContainer, legendsToSvgCallback, isRTL, background) {
34
53
  var svg = chartContainer.querySelector('svg');
35
54
  if (!svg) {
@@ -41,8 +60,11 @@ define(["require", "exports", "tslib", "d3-selection", "./index", "../components
41
60
  .attr('viewBox', null);
42
61
  var svgElements = svg.getElementsByTagName('*');
43
62
  var clonedSvgElements = clonedSvg.node().getElementsByTagName('*');
63
+ var TEXT_ELEMENTS = ['text'];
64
+ var TABLE_ELEMENTS = ['table', 'thead', 'tbody', 'tr', 'th', 'td'];
44
65
  for (var i = 0; i < svgElements.length; i++) {
45
- if (svgElements[i].tagName.toLowerCase() === 'text') {
66
+ var tag = svgElements[i].tagName.toLowerCase();
67
+ if (TEXT_ELEMENTS.includes(tag) || TABLE_ELEMENTS.includes(tag)) {
46
68
  (0, index_1.copyStyle)(tslib_1.__spreadArray(tslib_1.__spreadArray([], SVG_STYLE_PROPERTIES, true), SVG_TEXT_STYLE_PROPERTIES, true), svgElements[i], clonedSvgElements[i]);
47
69
  }
48
70
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"image-export-utils.js","sourceRoot":"../src/","sources":["utilities/image-export-utils.ts"],"names":[],"mappings":";;;;IAeA,SAAgB,OAAO,CACrB,cAA8C,EAC9C,oBAAgD,EAChD,KAAsB,EACtB,IAA8B;QAD9B,sBAAA,EAAA,aAAsB;QACtB,qBAAA,EAAA,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ACH,CAAC;YACH,CAAC;YACD,MAAM,IAAI,GAAG,CAAC;QAChB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC","sourcesContent":["import { create as d3Create, select as d3Select, Selection } from 'd3-selection';\nimport { copyStyle, createMeasurementSpan, resolveCSSVariables } from './index';\nimport { IImageExportOptions } from '../types/index';\nimport { ILegend, ILegendContainer } from '../Legends';\nimport {\n LEGEND_CONTAINER_MARGIN_TOP,\n LEGEND_CONTAINER_MARGIN_START,\n LEGEND_PADDING,\n LEGEND_HEIGHT,\n LEGEND_SHAPE_BORDER,\n LEGEND_SHAPE_SIZE,\n LEGEND_SHAPE_MARGIN_END,\n INACTIVE_LEGEND_TEXT_OPACITY,\n} from '../components/Legends/Legends.styles';\n\nexport function toImage(\n chartContainer: HTMLElement | null | undefined,\n legendsToSvgCallback?: ILegendContainer['toSVG'],\n isRTL: boolean = false,\n opts: IImageExportOptions = {},\n): Promise<string> {\n return new Promise((resolve, reject) => {\n if (!chartContainer) {\n return reject(new Error('Chart container is not defined'));\n }\n\n try {\n const background =\n typeof opts.background === 'string' ? resolveCSSVariables(chartContainer, opts.background) : 'transparent';\n const svg = toSVG(chartContainer, legendsToSvgCallback, isRTL, background);\n\n const svgData = new XMLSerializer().serializeToString(svg.node);\n const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescapePonyfill(encodeURIComponent(svgData)));\n\n svgToPng(svgDataUrl, {\n width: opts.width || svg.width,\n height: opts.height || svg.height,\n scale: opts.scale,\n })\n .then(resolve)\n .catch(reject);\n } catch (err) {\n return reject(err);\n }\n });\n}\n\nconst SVG_STYLE_PROPERTIES = ['display', 'fill', 'fill-opacity', 'opacity', 'stroke', 'stroke-width', 'transform'];\nconst SVG_TEXT_STYLE_PROPERTIES = ['font-family', 'font-size', 'font-weight', 'text-anchor'];\n\nfunction toSVG(\n chartContainer: HTMLElement,\n legendsToSvgCallback: ILegendContainer['toSVG'] | undefined,\n isRTL: boolean,\n background: string,\n) {\n const svg = chartContainer.querySelector<SVGSVGElement>('svg');\n if (!svg) {\n throw new Error('SVG not found');\n }\n\n const clonedSvg = d3Select(svg.cloneNode(true) as SVGSVGElement)\n .attr('width', null)\n .attr('height', null)\n .attr('viewBox', null);\n const svgElements = svg.getElementsByTagName('*');\n const clonedSvgElements = clonedSvg.node()!.getElementsByTagName('*');\n\n for (let i = 0; i < svgElements.length; i++) {\n if (svgElements[i].tagName.toLowerCase() === 'text') {\n copyStyle([...SVG_STYLE_PROPERTIES, ...SVG_TEXT_STYLE_PROPERTIES], svgElements[i], clonedSvgElements[i]);\n } else {\n copyStyle(SVG_STYLE_PROPERTIES, svgElements[i], clonedSvgElements[i]);\n }\n }\n\n const { width: svgWidth, height: svgHeight } = svg.getBoundingClientRect();\n const legendGroup =\n typeof legendsToSvgCallback === 'function'\n ? legendsToSvgCallback(svgWidth, isRTL)\n : { node: null, width: 0, height: 0 };\n const w1 = Math.max(svgWidth, legendGroup.width);\n const h1 = svgHeight + legendGroup.height;\n\n if (legendGroup.node) {\n d3Select(legendGroup.node).attr('transform', `translate(0, ${svgHeight})`);\n clonedSvg.append(() => legendGroup.node);\n }\n clonedSvg\n .insert('rect', ':first-child')\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', w1)\n .attr('height', h1)\n .attr('fill', background);\n clonedSvg\n .attr('width', w1)\n .attr('height', h1)\n .attr('viewBox', `0 0 ${w1} ${h1}`)\n .attr('direction', isRTL ? 'rtl' : 'ltr');\n\n return {\n node: clonedSvg.node()!,\n width: w1,\n height: h1,\n };\n}\n\nconst LEGEND_TEXT_STYLE_PROPERTIES_MAP = {\n color: 'fill',\n 'font-family': 'font-family',\n 'font-size': 'font-size',\n 'font-weight': 'font-weight',\n};\n\nexport function cloneLegendsToSVG(\n legends: ILegend[],\n svgWidth: number,\n config: {\n selectedLegends: Record<string, boolean>;\n centerLegends: boolean;\n textClassName: string;\n isRTL: boolean;\n },\n legendContainer?: HTMLElement | null,\n) {\n if (legends.length === 0) {\n return {\n node: null,\n width: 0,\n height: 0,\n };\n }\n\n const { selectedLegends, centerLegends, textClassName, isRTL } = config;\n const legendGroup = d3Create<SVGGElement>('svg:g');\n let legendX = centerLegends ? 0 : LEGEND_CONTAINER_MARGIN_START;\n let legendY = LEGEND_CONTAINER_MARGIN_TOP;\n let legendLine: { elem: Selection<SVGGElement, unknown, null, undefined>; width: number }[] = [];\n const legendLines: (typeof legendLine)[] = [];\n const legendLineWidths: number[] = [];\n const noLegendsSelected = Object.keys(selectedLegends).length === 0;\n\n for (let i = 0; i < legends.length; i++) {\n const textOffset = LEGEND_PADDING + LEGEND_SHAPE_SIZE + LEGEND_SHAPE_MARGIN_END;\n const legendText = createMeasurementSpan(legends[i].title, textClassName, legendContainer);\n const legendWidth = textOffset + legendText.getBoundingClientRect().width + LEGEND_PADDING;\n const legendItem = legendGroup.append('g');\n\n legendLine.push({ elem: legendItem, width: legendWidth });\n if (legendX + legendWidth > svgWidth && legendLine.length > 1) {\n legendLine.pop();\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n\n legendLine = [{ elem: legendItem, width: legendWidth }];\n legendX = centerLegends ? 0 : LEGEND_CONTAINER_MARGIN_START;\n legendY += LEGEND_HEIGHT;\n }\n\n const isLegendActive = selectedLegends[legends[i].title] || noLegendsSelected;\n\n legendItem\n .append('rect')\n .attr('x', legendX + (isRTL ? legendWidth - LEGEND_PADDING - LEGEND_SHAPE_SIZE : LEGEND_PADDING))\n .attr('y', legendY + LEGEND_PADDING)\n .attr('width', LEGEND_SHAPE_SIZE)\n .attr('height', LEGEND_SHAPE_SIZE)\n .style('fill', isLegendActive ? legends[i].color : 'transparent')\n .style('stroke-width', LEGEND_SHAPE_BORDER)\n .style('stroke', legends[i].color);\n\n legendItem\n .append('text')\n .attr('x', legendX + (isRTL ? legendWidth - textOffset : textOffset))\n .attr('y', legendY + LEGEND_PADDING)\n .attr('dominant-baseline', 'hanging')\n .style('opacity', isLegendActive ? 1 : INACTIVE_LEGEND_TEXT_OPACITY)\n .text(legends[i].title)\n .call(selection => copyStyle(LEGEND_TEXT_STYLE_PROPERTIES_MAP, legendText, selection.node()!));\n\n legendX += legendWidth;\n }\n\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n legendY += LEGEND_HEIGHT;\n\n if (centerLegends) {\n legendLines.forEach((ln, idx) => {\n const lineOffsetX = Math.max((svgWidth - legendLineWidths[idx]) / 2, 0);\n let remLineWidth = legendLineWidths[idx];\n let itemOffsetX = 0;\n ln.forEach(item => {\n const newOffsetX = lineOffsetX + (isRTL ? remLineWidth - item.width - itemOffsetX : 0);\n item.elem.attr('transform', `translate(${newOffsetX}, 0)`);\n remLineWidth -= item.width;\n itemOffsetX += item.width;\n });\n });\n } else if (isRTL) {\n const w1 = Math.max(svgWidth, ...legendLineWidths);\n legendLines.forEach(ln => {\n let remLineWidth = w1 - LEGEND_CONTAINER_MARGIN_START;\n let itemOffsetX = LEGEND_CONTAINER_MARGIN_START;\n ln.forEach(item => {\n const newOffsetX = remLineWidth - item.width - itemOffsetX;\n item.elem.attr('transform', `translate(${newOffsetX}, 0)`);\n remLineWidth -= item.width;\n itemOffsetX += item.width;\n });\n });\n }\n\n return {\n node: legendGroup.node(),\n width: Math.max(...legendLineWidths),\n height: legendY,\n };\n}\n\nfunction svgToPng(svgDataUrl: string, opts: IImageExportOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n const scale = opts.scale || 1;\n const w0 = opts.width || 300;\n const h0 = opts.height || 150;\n const w1 = scale * w0;\n const h1 = scale * h0;\n\n const canvas = document.createElement('canvas');\n const img = new Image();\n\n canvas.width = w1;\n canvas.height = h1;\n\n img.onload = function () {\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return reject(new Error('Canvas context is null'));\n }\n\n ctx.clearRect(0, 0, w1, h1);\n ctx.drawImage(img, 0, 0, w1, h1);\n\n const imgData = canvas.toDataURL('image/png');\n resolve(imgData);\n };\n\n img.onerror = function (err) {\n reject(err);\n };\n\n img.src = svgDataUrl;\n });\n}\n\nconst hex2 = /^[\\da-f]{2}$/i;\nconst hex4 = /^[\\da-f]{4}$/i;\n\n/**\n * A ponyfill for the deprecated `unescape` method, taken from the `core-js` library.\n *\n * Source: {@link https://github.com/zloirock/core-js/blob/167136f479d3b8519953f2e4c534ecdd1031d3cf/packages/core-js/modules/es.unescape.js core-js/packages/core-js/modules/es.unescape.js}\n */\nfunction unescapePonyfill(str: string) {\n let result = '';\n const length = str.length;\n let index = 0;\n let chr;\n let part;\n while (index < length) {\n chr = str.charAt(index++);\n if (chr === '%') {\n if (str.charAt(index) === 'u') {\n part = str.slice(index + 1, index + 5);\n if (hex4.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 5;\n continue;\n }\n } else {\n part = str.slice(index, index + 2);\n if (hex2.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 2;\n continue;\n }\n }\n }\n result += chr;\n }\n return result;\n}\n"]}
1
+ {"version":3,"file":"image-export-utils.js","sourceRoot":"../src/","sources":["utilities/image-export-utils.ts"],"names":[],"mappings":";;;;IAeA,SAAgB,OAAO,CACrB,cAA8C,EAC9C,oBAAgD,EAChD,KAAsB,EACtB,IAA8B;QAD9B,sBAAA,EAAA,aAAsB;QACtB,qBAAA,EAAA,SAA8B;QAE9B,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC,CAAC;YAC7D,CAAC;YAED,IAAI,CAAC;gBACH,IAAM,UAAU,GACd,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,2BAAmB,EAAC,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;gBAC7G,IAAM,GAAG,GAAG,KAAK,CAAC,cAAc,EAAE,oBAAoB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;gBA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port { copyStyle, createMeasurementSpan, resolveCSSVariables } from './index';\nimport { IImageExportOptions } from '../types/index';\nimport { ILegend, ILegendContainer } from '../Legends';\nimport {\n LEGEND_CONTAINER_MARGIN_TOP,\n LEGEND_CONTAINER_MARGIN_START,\n LEGEND_PADDING,\n LEGEND_HEIGHT,\n LEGEND_SHAPE_BORDER,\n LEGEND_SHAPE_SIZE,\n LEGEND_SHAPE_MARGIN_END,\n INACTIVE_LEGEND_TEXT_OPACITY,\n} from '../components/Legends/Legends.styles';\n\nexport function toImage(\n chartContainer: HTMLElement | null | undefined,\n legendsToSvgCallback?: ILegendContainer['toSVG'],\n isRTL: boolean = false,\n opts: IImageExportOptions = {},\n): Promise<string> {\n return new Promise((resolve, reject) => {\n if (!chartContainer) {\n return reject(new Error('Chart container is not defined'));\n }\n\n try {\n const background =\n typeof opts.background === 'string' ? resolveCSSVariables(chartContainer, opts.background) : 'transparent';\n const svg = toSVG(chartContainer, legendsToSvgCallback, isRTL, background);\n\n const svgData = new XMLSerializer().serializeToString(svg.node);\n const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescapePonyfill(encodeURIComponent(svgData)));\n\n svgToPng(svgDataUrl, {\n width: opts.width || svg.width,\n height: opts.height || svg.height,\n scale: opts.scale,\n })\n .then(resolve)\n .catch(reject);\n } catch (err) {\n return reject(err);\n }\n });\n}\n\nconst SVG_STYLE_PROPERTIES = [\n 'display',\n 'fill',\n 'fill-opacity',\n 'opacity',\n 'stroke',\n 'stroke-width',\n 'transform',\n 'border-collapse',\n];\nconst SVG_TEXT_STYLE_PROPERTIES = [\n 'font-family',\n 'font-size',\n 'font-weight',\n 'text-anchor',\n 'background-color',\n 'color',\n 'padding',\n 'text-align',\n 'border',\n];\n\nfunction toSVG(\n chartContainer: HTMLElement,\n legendsToSvgCallback: ILegendContainer['toSVG'] | undefined,\n isRTL: boolean,\n background: string,\n) {\n const svg = chartContainer.querySelector<SVGSVGElement>('svg');\n if (!svg) {\n throw new Error('SVG not found');\n }\n\n const clonedSvg = d3Select(svg.cloneNode(true) as SVGSVGElement)\n .attr('width', null)\n .attr('height', null)\n .attr('viewBox', null);\n const svgElements = svg.getElementsByTagName('*');\n const clonedSvgElements = clonedSvg.node()!.getElementsByTagName('*');\n\n const TEXT_ELEMENTS = ['text'];\n const TABLE_ELEMENTS = ['table', 'thead', 'tbody', 'tr', 'th', 'td'];\n\n for (let i = 0; i < svgElements.length; i++) {\n const tag = svgElements[i].tagName.toLowerCase();\n\n if (TEXT_ELEMENTS.includes(tag) || TABLE_ELEMENTS.includes(tag)) {\n copyStyle([...SVG_STYLE_PROPERTIES, ...SVG_TEXT_STYLE_PROPERTIES], svgElements[i], clonedSvgElements[i]);\n } else {\n copyStyle(SVG_STYLE_PROPERTIES, svgElements[i], clonedSvgElements[i]);\n }\n }\n\n const { width: svgWidth, height: svgHeight } = svg.getBoundingClientRect();\n const legendGroup =\n typeof legendsToSvgCallback === 'function'\n ? legendsToSvgCallback(svgWidth, isRTL)\n : { node: null, width: 0, height: 0 };\n const w1 = Math.max(svgWidth, legendGroup.width);\n const h1 = svgHeight + legendGroup.height;\n\n if (legendGroup.node) {\n d3Select(legendGroup.node).attr('transform', `translate(0, ${svgHeight})`);\n clonedSvg.append(() => legendGroup.node);\n }\n clonedSvg\n .insert('rect', ':first-child')\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', w1)\n .attr('height', h1)\n .attr('fill', background);\n clonedSvg\n .attr('width', w1)\n .attr('height', h1)\n .attr('viewBox', `0 0 ${w1} ${h1}`)\n .attr('direction', isRTL ? 'rtl' : 'ltr');\n\n return {\n node: clonedSvg.node()!,\n width: w1,\n height: h1,\n };\n}\n\nconst LEGEND_TEXT_STYLE_PROPERTIES_MAP = {\n color: 'fill',\n 'font-family': 'font-family',\n 'font-size': 'font-size',\n 'font-weight': 'font-weight',\n};\n\nexport function cloneLegendsToSVG(\n legends: ILegend[],\n svgWidth: number,\n config: {\n selectedLegends: Record<string, boolean>;\n centerLegends: boolean;\n textClassName: string;\n isRTL: boolean;\n },\n legendContainer?: HTMLElement | null,\n) {\n if (legends.length === 0) {\n return {\n node: null,\n width: 0,\n height: 0,\n };\n }\n\n const { selectedLegends, centerLegends, textClassName, isRTL } = config;\n const legendGroup = d3Create<SVGGElement>('svg:g');\n let legendX = centerLegends ? 0 : LEGEND_CONTAINER_MARGIN_START;\n let legendY = LEGEND_CONTAINER_MARGIN_TOP;\n let legendLine: { elem: Selection<SVGGElement, unknown, null, undefined>; width: number }[] = [];\n const legendLines: (typeof legendLine)[] = [];\n const legendLineWidths: number[] = [];\n const noLegendsSelected = Object.keys(selectedLegends).length === 0;\n\n for (let i = 0; i < legends.length; i++) {\n const textOffset = LEGEND_PADDING + LEGEND_SHAPE_SIZE + LEGEND_SHAPE_MARGIN_END;\n const legendText = createMeasurementSpan(legends[i].title, textClassName, legendContainer);\n const legendWidth = textOffset + legendText.getBoundingClientRect().width + LEGEND_PADDING;\n const legendItem = legendGroup.append('g');\n\n legendLine.push({ elem: legendItem, width: legendWidth });\n if (legendX + legendWidth > svgWidth && legendLine.length > 1) {\n legendLine.pop();\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n\n legendLine = [{ elem: legendItem, width: legendWidth }];\n legendX = centerLegends ? 0 : LEGEND_CONTAINER_MARGIN_START;\n legendY += LEGEND_HEIGHT;\n }\n\n const isLegendActive = selectedLegends[legends[i].title] || noLegendsSelected;\n\n legendItem\n .append('rect')\n .attr('x', legendX + (isRTL ? legendWidth - LEGEND_PADDING - LEGEND_SHAPE_SIZE : LEGEND_PADDING))\n .attr('y', legendY + LEGEND_PADDING)\n .attr('width', LEGEND_SHAPE_SIZE)\n .attr('height', LEGEND_SHAPE_SIZE)\n .style('fill', isLegendActive ? legends[i].color : 'transparent')\n .style('stroke-width', LEGEND_SHAPE_BORDER)\n .style('stroke', legends[i].color);\n\n legendItem\n .append('text')\n .attr('x', legendX + (isRTL ? legendWidth - textOffset : textOffset))\n .attr('y', legendY + LEGEND_PADDING)\n .attr('dominant-baseline', 'hanging')\n .style('opacity', isLegendActive ? 1 : INACTIVE_LEGEND_TEXT_OPACITY)\n .text(legends[i].title)\n .call(selection => copyStyle(LEGEND_TEXT_STYLE_PROPERTIES_MAP, legendText, selection.node()!));\n\n legendX += legendWidth;\n }\n\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n legendY += LEGEND_HEIGHT;\n\n if (centerLegends) {\n legendLines.forEach((ln, idx) => {\n const lineOffsetX = Math.max((svgWidth - legendLineWidths[idx]) / 2, 0);\n let remLineWidth = legendLineWidths[idx];\n let itemOffsetX = 0;\n ln.forEach(item => {\n const newOffsetX = lineOffsetX + (isRTL ? remLineWidth - item.width - itemOffsetX : 0);\n item.elem.attr('transform', `translate(${newOffsetX}, 0)`);\n remLineWidth -= item.width;\n itemOffsetX += item.width;\n });\n });\n } else if (isRTL) {\n const w1 = Math.max(svgWidth, ...legendLineWidths);\n legendLines.forEach(ln => {\n let remLineWidth = w1 - LEGEND_CONTAINER_MARGIN_START;\n let itemOffsetX = LEGEND_CONTAINER_MARGIN_START;\n ln.forEach(item => {\n const newOffsetX = remLineWidth - item.width - itemOffsetX;\n item.elem.attr('transform', `translate(${newOffsetX}, 0)`);\n remLineWidth -= item.width;\n itemOffsetX += item.width;\n });\n });\n }\n\n return {\n node: legendGroup.node(),\n width: Math.max(...legendLineWidths),\n height: legendY,\n };\n}\n\nfunction svgToPng(svgDataUrl: string, opts: IImageExportOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n const scale = opts.scale || 1;\n const w0 = opts.width || 300;\n const h0 = opts.height || 150;\n const w1 = scale * w0;\n const h1 = scale * h0;\n\n const canvas = document.createElement('canvas');\n const img = new Image();\n\n canvas.width = w1;\n canvas.height = h1;\n\n img.onload = function () {\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return reject(new Error('Canvas context is null'));\n }\n\n ctx.clearRect(0, 0, w1, h1);\n ctx.drawImage(img, 0, 0, w1, h1);\n\n const imgData = canvas.toDataURL('image/png');\n resolve(imgData);\n };\n\n img.onerror = function (err) {\n reject(err);\n };\n\n img.src = svgDataUrl;\n });\n}\n\nconst hex2 = /^[\\da-f]{2}$/i;\nconst hex4 = /^[\\da-f]{4}$/i;\n\n/**\n * A ponyfill for the deprecated `unescape` method, taken from the `core-js` library.\n *\n * Source: {@link https://github.com/zloirock/core-js/blob/167136f479d3b8519953f2e4c534ecdd1031d3cf/packages/core-js/modules/es.unescape.js core-js/packages/core-js/modules/es.unescape.js}\n */\nfunction unescapePonyfill(str: string) {\n let result = '';\n const length = str.length;\n let index = 0;\n let chr;\n let part;\n while (index < length) {\n chr = str.charAt(index++);\n if (chr === '%') {\n if (str.charAt(index) === 'u') {\n part = str.slice(index + 1, index + 5);\n if (hex4.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 5;\n continue;\n }\n } else {\n part = str.slice(index, index + 2);\n if (hex2.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 2;\n continue;\n }\n }\n }\n result += chr;\n }\n return result;\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from './components/ChartTable/index';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./components/ChartTable/index"), exports);
5
+ //# sourceMappingURL=ChartTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTable.js","sourceRoot":"../src/","sources":["ChartTable.ts"],"names":[],"mappings":";;;AAAA,wEAA8C","sourcesContent":["export * from './components/ChartTable/index';\n"]}
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { IChartTableProps } from './ChartTable.types';
3
+ import { IImageExportOptions } from '../../types/index';
4
+ export declare class ChartTableBase extends React.Component<IChartTableProps> {
5
+ private _isRTL;
6
+ private _rootElem;
7
+ constructor(props: IChartTableProps);
8
+ toImage: (opts?: IImageExportOptions) => Promise<string>;
9
+ render(): JSX.Element;
10
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChartTableBase = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var React = require("react");
6
+ var Utilities_1 = require("@fluentui/react/lib/Utilities");
7
+ var image_export_utils_1 = require("../../utilities/image-export-utils");
8
+ var getClassNames = (0, Utilities_1.classNamesFunction)();
9
+ var ChartTableBase = /** @class */ (function (_super) {
10
+ tslib_1.__extends(ChartTableBase, _super);
11
+ function ChartTableBase(props) {
12
+ var _this = _super.call(this, props) || this;
13
+ _this.toImage = function (opts) {
14
+ return (0, image_export_utils_1.toImage)(_this._rootElem, undefined, _this._isRTL, opts);
15
+ };
16
+ (0, Utilities_1.initializeComponentRef)(_this);
17
+ _this._isRTL = (0, Utilities_1.getRTL)(props.theme);
18
+ return _this;
19
+ }
20
+ ChartTableBase.prototype.render = function () {
21
+ var _this = this;
22
+ var _a = this.props, headers = _a.headers, rows = _a.rows, width = _a.width, height = _a.height, styles = _a.styles, theme = _a.theme;
23
+ var classNames = getClassNames(styles, {
24
+ theme: theme,
25
+ });
26
+ if (!headers || headers.length === 0) {
27
+ return React.createElement("div", null, "No data available");
28
+ }
29
+ return (React.createElement("div", { ref: function (el) { return (_this._rootElem = el); }, className: classNames.root, style: { height: height ? "".concat(height, "px") : '650px', overflow: 'hidden' } },
30
+ React.createElement("svg", { width: width !== null && width !== void 0 ? width : '100%', height: height !== null && height !== void 0 ? height : '650px' },
31
+ React.createElement("foreignObject", { x: "0", y: "0", width: "100%", height: "100%" },
32
+ React.createElement("div", { style: {
33
+ maxHeight: height ? "".concat(height, "px") : '650px',
34
+ overflowY: 'auto',
35
+ overflowX: 'auto',
36
+ } },
37
+ React.createElement("table", { className: classNames.table, style: {
38
+ width: width ? "".concat(width, "px") : '100%',
39
+ } },
40
+ React.createElement("thead", null,
41
+ React.createElement("tr", null, headers.map(function (header, idx) { return (React.createElement("th", { key: idx, className: classNames.headerCell }, header)); }))),
42
+ rows && rows.length > 0 && (React.createElement("tbody", null, rows.map(function (row, rowIdx) { return (React.createElement("tr", { key: rowIdx }, row.map(function (cell, colIdx) { return (React.createElement("td", { key: colIdx, className: classNames.bodyCell }, cell)); }))); })))))))));
43
+ };
44
+ return ChartTableBase;
45
+ }(React.Component));
46
+ exports.ChartTableBase = ChartTableBase;
47
+ //# sourceMappingURL=ChartTable.base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTable.base.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.base.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAG/B,2DAAmG;AAEnG,yEAA6D;AAE7D,IAAM,aAAa,GAAG,IAAA,8BAAkB,GAA4C,CAAC;AAErF;IAAoC,0CAAiC;IAInE,wBAAY,KAAuB;QACjC,YAAA,MAAK,YAAC,KAAK,CAAC,SAAC;QAIR,aAAO,GAAG,UAAC,IAA0B;YAC1C,OAAO,IAAA,4BAAO,EAAC,KAAI,CAAC,SAAS,EAAE,SAAS,EAAE,KAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC/D,CAAC,CAAC;QALA,IAAA,kCAAsB,EAAC,KAAI,CAAC,CAAC;QAC7B,KAAI,CAAC,MAAM,GAAG,IAAA,kBAAM,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;;IACpC,CAAC;IAKM,+BAAM,GAAb;QAAA,iBA4DC;QA3DO,IAAA,KAAkD,IAAI,CAAC,KAAK,EAA1D,OAAO,aAAA,EAAE,IAAI,UAAA,EAAE,KAAK,WAAA,EAAE,MAAM,YAAA,EAAE,MAAM,YAAA,EAAE,KAAK,WAAe,CAAC;QAEnE,IAAM,UAAU,GAAG,aAAa,CAAC,MAAO,EAAE;YACxC,KAAK,EAAE,KAAM;SACd,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,qDAA4B,CAAC;QACtC,CAAC;QAED,OAAO,CACL,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,MAAM,IAAK,OAAA,CACzB,4BAAI,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,IAC5C,IAAI,CACF,CACN,EAJ0B,CAI1B,CAAC,CACC,CACN,EAR0B,CAQ1B,CAAC,CACI,CACT,CACK,CACJ,CACQ,CACZ,CACF,CACP,CAAC;IACJ,CAAC;IACH,qBAAC;AAAD,CAAC,AA1ED,CAAoC,KAAK,CAAC,SAAS,GA0ElD;AA1EY,wCAAc","sourcesContent":["import * as React from 'react';\nimport { IChartTableProps } from './ChartTable.types';\nimport { IChartTableStyleProps, IChartTableStyles } from '../../index';\nimport { classNamesFunction, getRTL, initializeComponentRef } from '@fluentui/react/lib/Utilities';\nimport { IImageExportOptions } from '../../types/index';\nimport { toImage } from '../../utilities/image-export-utils';\n\nconst getClassNames = classNamesFunction<IChartTableStyleProps, IChartTableStyles>();\n\nexport class ChartTableBase extends React.Component<IChartTableProps> {\n private _isRTL: boolean;\n private _rootElem: HTMLDivElement | null;\n\n constructor(props: IChartTableProps) {\n super(props);\n initializeComponentRef(this);\n this._isRTL = getRTL(props.theme);\n }\n public toImage = (opts?: IImageExportOptions): Promise<string> => {\n return toImage(this._rootElem, undefined, this._isRTL, opts);\n };\n\n public render(): JSX.Element {\n const { headers, rows, width, height, styles, theme } = this.props;\n\n const classNames = getClassNames(styles!, {\n theme: theme!,\n });\n\n if (!headers || headers.length === 0) {\n return <div>No data available</div>;\n }\n\n return (\n <div\n ref={el => (this._rootElem = el)}\n className={classNames.root}\n style={{ height: height ? `${height}px` : '650px', overflow: 'hidden' }}\n >\n <svg width={width ?? '100%'} height={height ?? '650px'}>\n <foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n <div\n style={{\n maxHeight: height ? `${height}px` : '650px',\n overflowY: 'auto',\n overflowX: 'auto',\n }}\n >\n <table\n className={classNames.table}\n style={{\n width: width ? `${width}px` : '100%',\n }}\n >\n <thead>\n <tr>\n {headers.map((header, idx) => (\n <th key={idx} className={classNames.headerCell}>\n {header}\n </th>\n ))}\n </tr>\n </thead>\n {rows && rows.length > 0 && (\n <tbody>\n {rows.map((row, rowIdx) => (\n <tr key={rowIdx}>\n {row.map((cell, colIdx) => (\n <td key={colIdx} className={classNames.bodyCell}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n )}\n </table>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { IChartTableProps } from '../../index';
3
+ /**
4
+ * ChartTable component
5
+ * {@docCategory ChartTable}
6
+ */
7
+ export declare const ChartTable: React.FunctionComponent<IChartTableProps>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChartTable = void 0;
4
+ var Utilities_1 = require("@fluentui/react/lib/Utilities");
5
+ var ChartTable_base_1 = require("./ChartTable.base");
6
+ var ChartTable_styles_1 = require("./ChartTable.styles");
7
+ /**
8
+ * ChartTable component
9
+ * {@docCategory ChartTable}
10
+ */
11
+ exports.ChartTable = (0, Utilities_1.styled)(ChartTable_base_1.ChartTableBase, ChartTable_styles_1.getStyles);
12
+ //# sourceMappingURL=ChartTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTable.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.tsx"],"names":[],"mappings":";;;AACA,2DAAuD;AAEvD,qDAAmD;AACnD,yDAAgD;AAEhD;;;GAGG;AACU,QAAA,UAAU,GAA8C,IAAA,kBAAM,EAIzE,gCAAc,EAAE,6BAAS,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { styled } from '@fluentui/react/lib/Utilities';\nimport { IChartTableProps, IChartTableStyleProps, IChartTableStyles } from '../../index';\nimport { ChartTableBase } from './ChartTable.base';\nimport { getStyles } from './ChartTable.styles';\n\n/**\n * ChartTable component\n * {@docCategory ChartTable}\n */\nexport const ChartTable: React.FunctionComponent<IChartTableProps> = styled<\n IChartTableProps,\n IChartTableStyleProps,\n IChartTableStyles\n>(ChartTableBase, getStyles);\n"]}
@@ -0,0 +1,2 @@
1
+ import { IChartTableStyleProps, IChartTableStyles } from './ChartTable.types';
2
+ export declare const getStyles: (props: IChartTableStyleProps) => IChartTableStyles;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStyles = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var Styling_1 = require("@fluentui/react/lib/Styling");
6
+ var getStyles = function (props) {
7
+ var _a, _b;
8
+ var theme = props.theme;
9
+ var fonts = theme.fonts;
10
+ return {
11
+ root: {
12
+ width: '100%',
13
+ overflowX: 'auto',
14
+ },
15
+ table: {
16
+ borderCollapse: 'collapse',
17
+ },
18
+ headerCell: tslib_1.__assign(tslib_1.__assign({}, fonts.small), { fontWeight: Styling_1.FontWeights.semibold, backgroundColor: theme.palette.neutralQuaternary, color: theme.semanticColors.bodyText, padding: '8px', textAlign: 'left', border: "2px solid ".concat(theme.palette.neutralLighter), selectors: (_a = {},
19
+ _a[Styling_1.HighContrastSelector] = {
20
+ backgroundColor: 'Window',
21
+ color: 'WindowText',
22
+ },
23
+ _a) }),
24
+ bodyCell: tslib_1.__assign(tslib_1.__assign({}, fonts.small), { padding: '8px', border: "2px solid ".concat(theme.palette.neutralLighter), color: theme.semanticColors.bodyText, textAlign: 'left', selectors: (_b = {},
25
+ _b[Styling_1.HighContrastSelector] = {
26
+ color: 'WindowText',
27
+ },
28
+ _b) }),
29
+ };
30
+ };
31
+ exports.getStyles = getStyles;
32
+ //# sourceMappingURL=ChartTable.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTable.styles.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.styles.ts"],"names":[],"mappings":";;;;AACA,uDAAgF;AAEzE,IAAM,SAAS,GAAG,UAAC,KAA4B;;IAC5C,IAAA,KAAK,GAAK,KAAK,MAAV,CAAW;IAChB,IAAA,KAAK,GAAK,KAAM,MAAX,CAAY;IAEzB,OAAO;QACL,IAAI,EAAE;YACJ,KAAK,EAAE,MAAM;YACb,SAAS,EAAE,MAAM;SAClB;QACD,KAAK,EAAE;YACL,cAAc,EAAE,UAAU;SAC3B;QACD,UAAU,wCACL,KAAK,CAAC,KAAK,KACd,UAAU,EAAE,qBAAW,CAAC,QAAQ,EAChC,eAAe,EAAE,KAAM,CAAC,OAAO,CAAC,iBAAiB,EACjD,KAAK,EAAE,KAAM,CAAC,cAAc,CAAC,QAAQ,EACrC,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,oBAAa,KAAM,CAAC,OAAO,CAAC,cAAc,CAAE,EACpD,SAAS;gBACP,GAAC,8BAAoB,IAAG;oBACtB,eAAe,EAAE,QAAQ;oBACzB,KAAK,EAAE,YAAY;iBACpB;sBAEJ;QACD,QAAQ,wCACH,KAAK,CAAC,KAAK,KACd,OAAO,EAAE,KAAK,EACd,MAAM,EAAE,oBAAa,KAAM,CAAC,OAAO,CAAC,cAAc,CAAE,EACpD,KAAK,EAAE,KAAM,CAAC,cAAc,CAAC,QAAQ,EACrC,SAAS,EAAE,MAAM,EACjB,SAAS;gBACP,GAAC,8BAAoB,IAAG;oBACtB,KAAK,EAAE,YAAY;iBACpB;sBAEJ;KACF,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,SAAS,aAwCpB","sourcesContent":["import { IChartTableStyleProps, IChartTableStyles } from './ChartTable.types';\nimport { FontWeights, HighContrastSelector } from '@fluentui/react/lib/Styling';\n\nexport const getStyles = (props: IChartTableStyleProps): IChartTableStyles => {\n const { theme } = props;\n const { fonts } = theme!;\n\n return {\n root: {\n width: '100%',\n overflowX: 'auto',\n },\n table: {\n borderCollapse: 'collapse',\n },\n headerCell: {\n ...fonts.small,\n fontWeight: FontWeights.semibold,\n backgroundColor: theme!.palette.neutralQuaternary,\n color: theme!.semanticColors.bodyText,\n padding: '8px',\n textAlign: 'left',\n border: `2px solid ${theme!.palette.neutralLighter}`,\n selectors: {\n [HighContrastSelector]: {\n backgroundColor: 'Window',\n color: 'WindowText',\n },\n },\n },\n bodyCell: {\n ...fonts.small,\n padding: '8px',\n border: `2px solid ${theme!.palette.neutralLighter}`,\n color: theme!.semanticColors.bodyText,\n textAlign: 'left',\n selectors: {\n [HighContrastSelector]: {\n color: 'WindowText',\n },\n },\n },\n };\n};\n"]}
@@ -0,0 +1,58 @@
1
+ import { ITheme, IStyle } from '@fluentui/react/lib/Styling';
2
+ import { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
3
+ import { IChart } from '../../types/index';
4
+ export interface IChartTableStyleProps {
5
+ theme: ITheme;
6
+ className?: string;
7
+ }
8
+ /**
9
+ * Chart Table properties
10
+ * {@docCategory ChartTable}
11
+ */
12
+ export interface IChartTableProps {
13
+ /**
14
+ * 1d or 2d Array of header values.
15
+ */
16
+ headers: (string | number | boolean | null)[] | (string | number | boolean | null)[][];
17
+ /**
18
+ * Array of rows. Each row corresponds to one data entry under each column.
19
+ */
20
+ rows: (string | number | boolean | null)[][];
21
+ /**
22
+ * Optional width for the table
23
+ * @default '100%'
24
+ */
25
+ width?: string | number;
26
+ /**
27
+ * Optional height for the table
28
+ * @default '650px'
29
+ */
30
+ height?: string | number;
31
+ /**
32
+ * Theme (provided through customization)
33
+ */
34
+ theme?: ITheme;
35
+ /**
36
+ * Additional class name(s) to apply to the table chart
37
+ */
38
+ className?: string;
39
+ /**
40
+ * Call to provide customized styling that will layer on top of the variant rules.
41
+ */
42
+ styles?: IStyleFunctionOrObject<IChartTableStyleProps, IChartTableStyles>;
43
+ /**
44
+ * Optional callback to access the IChart interface. Use this instead of ref for accessing
45
+ * the public methods and properties of the component.
46
+ */
47
+ componentRef?: IRefObject<IChart>;
48
+ }
49
+ /**
50
+ * Table Chart styles
51
+ * {@docCategory ChartTable}
52
+ */
53
+ export interface IChartTableStyles {
54
+ root?: IStyle;
55
+ table?: IStyle;
56
+ headerCell?: IStyle;
57
+ bodyCell?: IStyle;
58
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ChartTable.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTable.types.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { IChart } from '../../types/index';\n\nexport interface IChartTableStyleProps {\n theme: ITheme;\n className?: string;\n}\n\n/**\n * Chart Table properties\n * {@docCategory ChartTable}\n */\nexport interface IChartTableProps {\n /**\n * 1d or 2d Array of header values.\n */\n headers: (string | number | boolean | null)[] | (string | number | boolean | null)[][];\n\n /**\n * Array of rows. Each row corresponds to one data entry under each column.\n */\n rows: (string | number | boolean | null)[][];\n\n /**\n * Optional width for the table\n * @default '100%'\n */\n width?: string | number;\n\n /**\n * Optional height for the table\n * @default '650px'\n */\n height?: string | number;\n\n /**\n * Theme (provided through customization)\n */\n theme?: ITheme;\n\n /**\n * Additional class name(s) to apply to the table chart\n */\n className?: string;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<IChartTableStyleProps, IChartTableStyles>;\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/**\n * Table Chart styles\n * {@docCategory ChartTable}\n */\nexport interface IChartTableStyles {\n root?: IStyle;\n table?: IStyle;\n headerCell?: IStyle;\n bodyCell?: IStyle;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './ChartTable';
2
+ export * from './ChartTable.types';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./ChartTable"), exports);
5
+ tslib_1.__exportStar(require("./ChartTable.types"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/ChartTable/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,6DAAmC","sourcesContent":["export * from './ChartTable';\nexport * from './ChartTable.types';\n"]}
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { IRefObject } from '@fluentui/react/lib/Utilities';
3
+ import type { ColorwayType } from './PlotlyColorAdapter';
3
4
  import { IImageExportOptions } from '../../types/index';
4
5
  /**
5
6
  * DeclarativeChart schema.
@@ -30,13 +31,13 @@ export interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElemen
30
31
  */
31
32
  componentRef?: IRefObject<IDeclarativeChart>;
32
33
  /**
33
- * Optional prop to specify the color palette for the chart.
34
- * - 'default': Do not use Fluent UI color palette.
35
- * - 'builtin': Use Fluent UI color palette.
36
- * - 'override': Reserved for future use.
37
- * @default 'builtin'
34
+ * Optional prop to specify the colorway type of the chart.
35
+ * - 'default': Use Fluent UI color palette aligning with plotly colorway.
36
+ * - 'builtin': Use Fluent UI colorway.
37
+ * - 'others': Reserved for future colorways.
38
+ * @default 'default'
38
39
  */
39
- fluentDataVizColorPalette?: 'default' | 'builtin' | 'override';
40
+ colorwayType?: ColorwayType;
40
41
  }
41
42
  /**
42
43
  * {@docCategory DeclarativeChart}
@@ -19,6 +19,7 @@ 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
23
  var ResponsiveDonutChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_1.DonutChart);
23
24
  var ResponsiveVerticalStackedBarChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_2.VerticalStackedBarChart);
24
25
  var ResponsiveLineChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_3.LineChart);
@@ -29,6 +30,7 @@ var ResponsiveSankeyChart = (0, withResponsiveContainer_1.withResponsiveContaine
29
30
  var ResponsiveGaugeChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_7.GaugeChart);
30
31
  var ResponsiveGroupedVerticalBarChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_8.GroupedVerticalBarChart);
31
32
  var ResponsiveVerticalBarChart = (0, withResponsiveContainer_1.withResponsiveContainer)(index_9.VerticalBarChart);
33
+ var ResponsiveChartTable = (0, withResponsiveContainer_1.withResponsiveContainer)(index_10.ChartTable);
32
34
  var useColorMapping = function () {
33
35
  var colorMap = React.useRef(new Map());
34
36
  return colorMap;
@@ -84,11 +86,10 @@ exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
84
86
  componentRef: chartRef,
85
87
  calloutProps: { layerProps: { eventBubblingEnabled: true } },
86
88
  };
87
- var useFluentVizColorPalette = props.fluentDataVizColorPalette === 'builtin';
88
89
  var renderLineArea = function (plotlyData, isAreaChart) {
89
90
  var _a;
90
91
  var isScatterMarkers = ['markers', 'text+markers', 'markers+text'].includes((_a = plotlyData[0]) === null || _a === void 0 ? void 0 : _a.mode);
91
- var chartProps = tslib_1.__assign(tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)({ data: plotlyData, layout: plotlyInput.layout }, isAreaChart, colorMap, useFluentVizColorPalette, isDarkTheme)), commonProps);
92
+ var chartProps = tslib_1.__assign(tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)({ data: plotlyData, layout: plotlyInput.layout }, isAreaChart, isScatterMarkers, colorMap, props.colorwayType, isDarkTheme)), commonProps);
92
93
  if (isAreaChart) {
93
94
  return React.createElement(ResponsiveAreaChart, tslib_1.__assign({}, chartProps));
94
95
  }
@@ -118,7 +119,7 @@ exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
118
119
  if (isAreaChart) {
119
120
  throw new Error('Fallback to VerticalStackedBarChart is not allowed for Area Charts.');
120
121
  }
121
- return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, useFluentVizColorPalette, isDarkTheme, fallbackVSBC), commonProps)));
122
+ return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme, fallbackVSBC), commonProps)));
122
123
  };
123
124
  var exportAsImage = React.useCallback(function (opts) {
124
125
  return new Promise(function (resolve, reject) {
@@ -136,21 +137,23 @@ exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
136
137
  }); }, [exportAsImage]);
137
138
  switch (chart.type) {
138
139
  case 'donut':
139
- return (React.createElement(ResponsiveDonutChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToDonutProps)(plotlyInputWithValidData, colorMap, useFluentVizColorPalette, isDarkTheme), commonProps)));
140
+ return (React.createElement(ResponsiveDonutChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToDonutProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
140
141
  case 'horizontalbar':
141
- return (React.createElement(ResponsiveHorizontalBarChartWithAxis, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHorizontalBarWithAxisProps)(plotlyInputWithValidData, colorMap, useFluentVizColorPalette, isDarkTheme), commonProps)));
142
+ return (React.createElement(ResponsiveHorizontalBarChartWithAxis, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHorizontalBarWithAxisProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
142
143
  case 'groupedverticalbar':
143
- return (React.createElement(ResponsiveGroupedVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGVBCProps)(plotlyInputWithValidData, colorMap, useFluentVizColorPalette, isDarkTheme), commonProps)));
144
+ return (React.createElement(ResponsiveGroupedVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGVBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
144
145
  case 'verticalstackedbar':
145
- return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, useFluentVizColorPalette, isDarkTheme), commonProps)));
146
+ return (React.createElement(ResponsiveVerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
146
147
  case 'heatmap':
147
148
  return (React.createElement(ResponsiveHeatMapChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHeatmapProps)(plotlyInputWithValidData), commonProps, { legendProps: {} })));
148
149
  case 'sankey':
149
- return (React.createElement(ResponsiveSankeyChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToSankeyProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
150
+ return (React.createElement(ResponsiveSankeyChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToSankeyProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
150
151
  case 'gauge':
151
- return (React.createElement(ResponsiveGaugeChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGaugeProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
152
+ return (React.createElement(ResponsiveGaugeChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGaugeProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
152
153
  case 'verticalbar':
153
- return (React.createElement(ResponsiveVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVBCProps)(plotlyInputWithValidData, colorMap, useFluentVizColorPalette, isDarkTheme), commonProps)));
154
+ return (React.createElement(ResponsiveVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme), commonProps)));
155
+ case 'table':
156
+ return (React.createElement(ResponsiveChartTable, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToChartTableProps)(plotlyInputWithValidData, colorMap, isDarkTheme), commonProps)));
154
157
  case 'area':
155
158
  case 'line':
156
159
  case 'fallback':
@@ -168,6 +171,6 @@ exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
168
171
  });
169
172
  exports.DeclarativeChart.displayName = 'DeclarativeChart';
170
173
  exports.DeclarativeChart.defaultProps = {
171
- fluentDataVizColorPalette: 'builtin',
174
+ colorwayType: 'default',
172
175
  };
173
176
  //# sourceMappingURL=DeclarativeChart.js.map