@semcore/d3-chart 18.0.0-prerelease.0 → 18.0.0-prerelease.2
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.
- package/CHANGELOG.md +10 -1
- package/lib/cjs/Area.js +123 -23
- package/lib/cjs/Area.js.map +1 -1
- package/lib/cjs/Axis.js +109 -97
- package/lib/cjs/Axis.js.map +1 -1
- package/lib/cjs/Bar.js +16 -16
- package/lib/cjs/Bubble.js +14 -14
- package/lib/cjs/ChartMetaData.js +44 -0
- package/lib/cjs/ChartMetaData.js.map +1 -0
- package/lib/cjs/CompactHorizontalBar.js +16 -16
- package/lib/cjs/Donut.js +18 -19
- package/lib/cjs/Donut.js.map +1 -1
- package/lib/cjs/Dots.js +67 -13
- package/lib/cjs/Dots.js.map +1 -1
- package/lib/cjs/HorizontalBar.js +16 -16
- package/lib/cjs/Hover.js +66 -52
- package/lib/cjs/Hover.js.map +1 -1
- package/lib/cjs/Line.js +82 -17
- package/lib/cjs/Line.js.map +1 -1
- package/lib/cjs/Pattern.js +113 -2
- package/lib/cjs/Pattern.js.map +1 -1
- package/lib/cjs/Plot.js +5 -2
- package/lib/cjs/Plot.js.map +1 -1
- package/lib/cjs/Radar.js +19 -19
- package/lib/cjs/RadialTree.js +12 -12
- package/lib/cjs/Reference.js +55 -18
- package/lib/cjs/Reference.js.map +1 -1
- package/lib/cjs/ScatterPlot.js +9 -9
- package/lib/cjs/Tooltip.js +16 -14
- package/lib/cjs/Tooltip.js.map +1 -1
- package/lib/cjs/a11y/PlotA11yView.js +2 -2
- package/lib/cjs/component/Chart/AbstractChart.js +21 -18
- package/lib/cjs/component/Chart/AbstractChart.js.map +1 -1
- package/lib/cjs/component/Chart/AbstractChart.type.js +19 -0
- package/lib/cjs/component/Chart/AbstractChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/AreaChart.js +21 -7
- package/lib/cjs/component/Chart/AreaChart.js.map +1 -1
- package/lib/cjs/component/Chart/AreaChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/BarChart.js +6 -3
- package/lib/cjs/component/Chart/BarChart.js.map +1 -1
- package/lib/cjs/component/Chart/BarChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/BubbleChart.js +4 -0
- package/lib/cjs/component/Chart/BubbleChart.js.map +1 -1
- package/lib/cjs/component/Chart/BubbleChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/CigaretteChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/CompactHorizontalBarChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/DonutChart.js +0 -1
- package/lib/cjs/component/Chart/DonutChart.js.map +1 -1
- package/lib/cjs/component/Chart/DonutChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/HistogramChart.js +6 -3
- package/lib/cjs/component/Chart/HistogramChart.js.map +1 -1
- package/lib/cjs/component/Chart/HistogramChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/LineChart.js +16 -6
- package/lib/cjs/component/Chart/LineChart.js.map +1 -1
- package/lib/cjs/component/Chart/LineChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/RadarChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/ScatterPlotChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/VennChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/index.js +43 -0
- package/lib/cjs/component/Chart/index.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/cjs/component/ChartLegend/LegendFlex/legend-flex.shadow.css +2 -2
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +16 -16
- package/lib/cjs/component/ChartLegend/LegendItem/legend-item.shadow.css +11 -11
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +7 -7
- package/lib/cjs/component/ChartLegend/LegendTable/legend-table.shadow.css +2 -2
- package/lib/cjs/index.js +55 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/abstract-chart.shadow.css +13 -3
- package/lib/cjs/style/area.shadow.css +8 -5
- package/lib/cjs/style/axis.shadow.css +51 -60
- package/lib/cjs/style/bar.shadow.css +6 -6
- package/lib/cjs/style/bubble.shadow.css +3 -3
- package/lib/cjs/style/donut.shadow.css +2 -2
- package/lib/cjs/style/dot.shadow.css +37 -2
- package/lib/cjs/style/hover.shadow.css +30 -13
- package/lib/cjs/style/line.shadow.css +3 -3
- package/lib/cjs/style/pattern.shadow.css +10 -0
- package/lib/cjs/style/plotA11yView.shadow.css +3 -3
- package/lib/cjs/style/radar.shadow.css +7 -7
- package/lib/cjs/style/radial-tree.shadow.css +2 -2
- package/lib/cjs/style/reference.shadow.css +4 -4
- package/lib/cjs/style/scatterplot.shadow.css +1 -1
- package/lib/cjs/style/tooltip.shadow.css +12 -12
- package/lib/cjs/types/Axis.d.js.map +1 -1
- package/lib/cjs/types/Donut.d.js.map +1 -1
- package/lib/cjs/types/Hover.d.js.map +1 -1
- package/lib/cjs/utils.js +21 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/Area.js +125 -25
- package/lib/es6/Area.js.map +1 -1
- package/lib/es6/Axis.js +109 -97
- package/lib/es6/Axis.js.map +1 -1
- package/lib/es6/Bar.js +16 -16
- package/lib/es6/Bubble.js +14 -14
- package/lib/es6/ChartMetaData.js +36 -0
- package/lib/es6/ChartMetaData.js.map +1 -0
- package/lib/es6/CompactHorizontalBar.js +16 -16
- package/lib/es6/Donut.js +18 -19
- package/lib/es6/Donut.js.map +1 -1
- package/lib/es6/Dots.js +68 -14
- package/lib/es6/Dots.js.map +1 -1
- package/lib/es6/HorizontalBar.js +16 -16
- package/lib/es6/Hover.js +66 -52
- package/lib/es6/Hover.js.map +1 -1
- package/lib/es6/Line.js +84 -19
- package/lib/es6/Line.js.map +1 -1
- package/lib/es6/Pattern.js +108 -2
- package/lib/es6/Pattern.js.map +1 -1
- package/lib/es6/Plot.js +5 -2
- package/lib/es6/Plot.js.map +1 -1
- package/lib/es6/Radar.js +19 -19
- package/lib/es6/RadialTree.js +12 -12
- package/lib/es6/Reference.js +55 -18
- package/lib/es6/Reference.js.map +1 -1
- package/lib/es6/ScatterPlot.js +9 -9
- package/lib/es6/Tooltip.js +16 -14
- package/lib/es6/Tooltip.js.map +1 -1
- package/lib/es6/a11y/PlotA11yView.js +2 -2
- package/lib/es6/component/Chart/AbstractChart.js +21 -18
- package/lib/es6/component/Chart/AbstractChart.js.map +1 -1
- package/lib/es6/component/Chart/AbstractChart.type.js +14 -1
- package/lib/es6/component/Chart/AbstractChart.type.js.map +1 -1
- package/lib/es6/component/Chart/AreaChart.js +21 -7
- package/lib/es6/component/Chart/AreaChart.js.map +1 -1
- package/lib/es6/component/Chart/AreaChart.type.js.map +1 -1
- package/lib/es6/component/Chart/BarChart.js +6 -3
- package/lib/es6/component/Chart/BarChart.js.map +1 -1
- package/lib/es6/component/Chart/BarChart.type.js.map +1 -1
- package/lib/es6/component/Chart/BubbleChart.js +4 -0
- package/lib/es6/component/Chart/BubbleChart.js.map +1 -1
- package/lib/es6/component/Chart/BubbleChart.type.js.map +1 -1
- package/lib/es6/component/Chart/CigaretteChart.type.js.map +1 -1
- package/lib/es6/component/Chart/CompactHorizontalBarChart.type.js.map +1 -1
- package/lib/es6/component/Chart/DonutChart.js +0 -1
- package/lib/es6/component/Chart/DonutChart.js.map +1 -1
- package/lib/es6/component/Chart/DonutChart.type.js.map +1 -1
- package/lib/es6/component/Chart/HistogramChart.js +6 -3
- package/lib/es6/component/Chart/HistogramChart.js.map +1 -1
- package/lib/es6/component/Chart/HistogramChart.type.js.map +1 -1
- package/lib/es6/component/Chart/LineChart.js +14 -4
- package/lib/es6/component/Chart/LineChart.js.map +1 -1
- package/lib/es6/component/Chart/LineChart.type.js.map +1 -1
- package/lib/es6/component/Chart/RadarChart.type.js.map +1 -1
- package/lib/es6/component/Chart/ScatterPlotChart.type.js.map +1 -1
- package/lib/es6/component/Chart/VennChart.type.js.map +1 -1
- package/lib/es6/component/Chart/index.js +2 -0
- package/lib/es6/component/Chart/index.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/es6/component/ChartLegend/LegendFlex/legend-flex.shadow.css +2 -2
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +16 -16
- package/lib/es6/component/ChartLegend/LegendItem/legend-item.shadow.css +11 -11
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +7 -7
- package/lib/es6/component/ChartLegend/LegendTable/legend-table.shadow.css +2 -2
- package/lib/es6/index.js +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/abstract-chart.shadow.css +13 -3
- package/lib/es6/style/area.shadow.css +8 -5
- package/lib/es6/style/axis.shadow.css +51 -60
- package/lib/es6/style/bar.shadow.css +6 -6
- package/lib/es6/style/bubble.shadow.css +3 -3
- package/lib/es6/style/donut.shadow.css +2 -2
- package/lib/es6/style/dot.shadow.css +37 -2
- package/lib/es6/style/hover.shadow.css +30 -13
- package/lib/es6/style/line.shadow.css +3 -3
- package/lib/es6/style/pattern.shadow.css +10 -0
- package/lib/es6/style/plotA11yView.shadow.css +3 -3
- package/lib/es6/style/radar.shadow.css +7 -7
- package/lib/es6/style/radial-tree.shadow.css +2 -2
- package/lib/es6/style/reference.shadow.css +4 -4
- package/lib/es6/style/scatterplot.shadow.css +1 -1
- package/lib/es6/style/tooltip.shadow.css +12 -12
- package/lib/es6/types/Axis.d.js.map +1 -1
- package/lib/es6/types/Donut.d.js.map +1 -1
- package/lib/es6/types/Hover.d.js.map +1 -1
- package/lib/es6/utils.js +18 -0
- package/lib/es6/utils.js.map +1 -1
- package/lib/esm/Area.mjs +127 -26
- package/lib/esm/Axis.mjs +110 -98
- package/lib/esm/Bar.mjs +17 -17
- package/lib/esm/Bubble.mjs +15 -15
- package/lib/esm/ChartMetaData.mjs +38 -0
- package/lib/esm/CompactHorizontalBar.mjs +17 -17
- package/lib/esm/Donut.mjs +19 -20
- package/lib/esm/Dots.mjs +66 -15
- package/lib/esm/HorizontalBar.mjs +17 -17
- package/lib/esm/Hover.mjs +67 -53
- package/lib/esm/Line.mjs +86 -20
- package/lib/esm/Pattern.mjs +119 -0
- package/lib/esm/Plot.mjs +6 -3
- package/lib/esm/Radar.mjs +20 -20
- package/lib/esm/RadialTree.mjs +13 -13
- package/lib/esm/Reference.mjs +56 -19
- package/lib/esm/ScatterPlot.mjs +10 -10
- package/lib/esm/Tooltip.mjs +17 -15
- package/lib/esm/a11y/PlotA11yView.mjs +3 -3
- package/lib/esm/component/Chart/AbstractChart.mjs +22 -19
- package/lib/esm/component/Chart/AbstractChart.type.mjs +16 -0
- package/lib/esm/component/Chart/AreaChart.mjs +21 -7
- package/lib/esm/component/Chart/BarChart.mjs +6 -3
- package/lib/esm/component/Chart/BubbleChart.mjs +4 -0
- package/lib/esm/component/Chart/DonutChart.mjs +0 -1
- package/lib/esm/component/Chart/HistogramChart.mjs +6 -3
- package/lib/esm/component/Chart/LineChart.mjs +14 -4
- package/lib/esm/component/Chart/index.mjs +8 -0
- package/lib/esm/component/ChartLegend/LegendFlex/LegendFlex.mjs +5 -5
- package/lib/esm/component/ChartLegend/LegendFlex/legend-flex.shadow.css +2 -2
- package/lib/esm/component/ChartLegend/LegendItem/LegendItem.mjs +17 -17
- package/lib/esm/component/ChartLegend/LegendItem/legend-item.shadow.css +11 -11
- package/lib/esm/component/ChartLegend/LegendTable/LegendTable.mjs +8 -8
- package/lib/esm/component/ChartLegend/LegendTable/legend-table.shadow.css +2 -2
- package/lib/esm/index.mjs +8 -0
- package/lib/esm/style/abstract-chart.shadow.css +13 -3
- package/lib/esm/style/area.shadow.css +8 -5
- package/lib/esm/style/axis.shadow.css +51 -60
- package/lib/esm/style/bar.shadow.css +6 -6
- package/lib/esm/style/bubble.shadow.css +3 -3
- package/lib/esm/style/donut.shadow.css +2 -2
- package/lib/esm/style/dot.shadow.css +37 -2
- package/lib/esm/style/hover.shadow.css +30 -13
- package/lib/esm/style/line.shadow.css +3 -3
- package/lib/esm/style/pattern.shadow.css +10 -0
- package/lib/esm/style/plotA11yView.shadow.css +3 -3
- package/lib/esm/style/radar.shadow.css +7 -7
- package/lib/esm/style/radial-tree.shadow.css +2 -2
- package/lib/esm/style/reference.shadow.css +4 -4
- package/lib/esm/style/scatterplot.shadow.css +1 -1
- package/lib/esm/style/tooltip.shadow.css +12 -12
- package/lib/esm/utils.mjs +20 -0
- package/lib/types/Axis.d.ts +3 -2
- package/lib/types/ChartMetaData.d.ts +17 -0
- package/lib/types/ChartMetaData.d.ts.map +1 -0
- package/lib/types/Donut.d.ts +1 -1
- package/lib/types/Hover.d.ts +2 -0
- package/lib/types/Pattern.d.ts +18 -0
- package/lib/types/Pattern.d.ts.map +1 -1
- package/lib/types/component/Chart/AbstractChart.d.ts.map +1 -1
- package/lib/types/component/Chart/AbstractChart.type.d.ts +22 -4
- package/lib/types/component/Chart/AbstractChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/AreaChart.d.ts.map +1 -1
- package/lib/types/component/Chart/AreaChart.type.d.ts +8 -4
- package/lib/types/component/Chart/AreaChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/BarChart.d.ts.map +1 -1
- package/lib/types/component/Chart/BarChart.type.d.ts +1 -0
- package/lib/types/component/Chart/BarChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/BubbleChart.d.ts.map +1 -1
- package/lib/types/component/Chart/BubbleChart.type.d.ts +1 -1
- package/lib/types/component/Chart/BubbleChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/CigaretteChart.type.d.ts +1 -1
- package/lib/types/component/Chart/CigaretteChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/CompactHorizontalBarChart.type.d.ts +1 -1
- package/lib/types/component/Chart/CompactHorizontalBarChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/DonutChart.d.ts.map +1 -1
- package/lib/types/component/Chart/DonutChart.type.d.ts +1 -2
- package/lib/types/component/Chart/DonutChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/HistogramChart.d.ts.map +1 -1
- package/lib/types/component/Chart/HistogramChart.type.d.ts +1 -0
- package/lib/types/component/Chart/HistogramChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/LineChart.d.ts.map +1 -1
- package/lib/types/component/Chart/LineChart.type.d.ts +1 -0
- package/lib/types/component/Chart/LineChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/RadarChart.type.d.ts +1 -1
- package/lib/types/component/Chart/RadarChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/ScatterPlotChart.type.d.ts +1 -1
- package/lib/types/component/Chart/ScatterPlotChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/VennChart.type.d.ts +1 -1
- package/lib/types/component/Chart/VennChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/index.d.ts +2 -0
- package/lib/types/component/Chart/index.d.ts.map +1 -1
- package/lib/types/utils.d.ts +4 -1
- package/lib/types/utils.d.ts.map +1 -1
- package/package.json +15 -15
- package/lib/esm/utils/TextMeasurer.mjs +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.js","names":["createComponent","i18nEnhance","scaleBand","scaleLinear","scaleTime","React","AbstractChart","minMax","GroupBar","HoverRect","StackBar","Line","YAxis","XAxis","localizedMessages","BarChartComponent","constructor","args","_defineProperty","_data","e","barIndex","barKey","onClickBar","asProps","xScale","invertAxis","valueScale","categoryScale","yScale","defaultLegendProps","props","trend","undefined","withTrend","renderTrend","key","groupKey","state","trendItem","createElement","data","x","y","color","style","strokeWidth","strokeDasharray","Dots","display","renderChart","type","dataDefinitions","highlightedItem","length","item","BarComponent","HorizontalBar","Bar","checked","Fragment","id","onClick","handleClickBar","map","index","commonBarComponentProps","transparent","_extends","renderTooltip","onClickHoverRect","Tooltip","wMin","xIndex","yIndex","dataItem","children","getTooltipChildren","renderAxis","showXAxis","showYAxis","axisXValueFormatter","axisYValueFormatter","multilineXTicks","multilineYTicks","Array","isArray","xTicks","yTicks","childrenX","value","childrenY","Ticks","primaryText","multiline","ticks","Grid","getLegendAriaLabel","getI18nText","chartType","marginY","marginX","plotWidth","plotHeight","testItem","range","plotPadding","Date","Number","isNaN","getMilliseconds","domain","paddingInner","paddingOuter","max","maxStackedValue","Math","flatValues","direction","showTooltip","locale","BarChart"],"sources":["../../../../src/component/Chart/BarChart.tsx"],"sourcesContent":["import { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { scaleBand, scaleLinear, scaleTime } from 'd3-scale';\nimport React from 'react';\n\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { BaseLegendProps } from './AbstractChart.type';\nimport type { BarChartData, BarChartProps, BarChartType, BarChartDefaultProps } from './BarChart.type';\n// @ts-ignore\nimport { minMax, GroupBar, HoverRect, StackBar, Line, YAxis, XAxis } from '../..';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\nimport type { BarProps } from '../../types';\nimport type { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\n\nclass BarChartComponent extends AbstractChart<\n BarChartData,\n BarChartProps,\n typeof BarChartComponent.enhance,\n {},\n ChartState,\n BarChartDefaultProps\n> {\n static displayName = 'Chart.Bar';\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n locale: 'en',\n } as const;\n\n get xScale() {\n const { xScale, invertAxis } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n return invertAxis ? this.valueScale : this.categoryScale;\n }\n\n get yScale() {\n const { yScale, invertAxis } = this.asProps;\n\n if (yScale) {\n return yScale;\n }\n\n return invertAxis ? this.categoryScale : this.valueScale;\n }\n\n protected defaultLegendProps(): Partial<BaseLegendProps> {\n if (this.props.trend !== undefined) {\n return { withTrend: true };\n }\n\n return {};\n }\n\n renderTrend(key: LegendItemKey) {\n const { groupKey, invertAxis, trend } = this.asProps;\n const { withTrend } = this.state;\n const trendItem = trend?.[key];\n\n if (withTrend && trendItem) {\n return (\n <Line\n data={trendItem}\n key={`${key}_${groupKey}`}\n x={invertAxis ? 'y' : 'x'}\n y={invertAxis ? 'x' : 'y'}\n color='wall'\n style={{ strokeWidth: 3, strokeDasharray: 5 }}\n >\n <Line.Dots data={trendItem} display />\n </Line>\n );\n }\n\n return null;\n }\n\n renderChart() {\n const { groupKey, type = 'group', invertAxis } = this.asProps;\n const { dataDefinitions, highlightedItem } = this.state;\n\n if (dataDefinitions.length === 1) {\n const item = dataDefinitions[0];\n const BarComponent = invertAxis ? GroupBar.HorizontalBar : GroupBar.Bar;\n\n return (\n item.checked && (\n <>\n <BarComponent\n x={invertAxis ? item.id : groupKey}\n y={invertAxis ? groupKey : item.id}\n key={item.id}\n color={item.color}\n onClick={this.handleClickBar}\n />\n {this.renderTrend(item.id)}\n </>\n )\n );\n }\n\n if (type === 'group') {\n return (\n <>\n <GroupBar x={invertAxis ? undefined : groupKey} y={invertAxis ? groupKey : undefined}>\n {dataDefinitions.map((item, index) => {\n const BarComponent = invertAxis ? GroupBar.HorizontalBar : GroupBar.Bar;\n\n const commonBarComponentProps: BarProps = {\n color: item.color,\n transparent: highlightedItem !== -1 && highlightedItem !== index,\n onClick: this.handleClickBar,\n };\n\n if (invertAxis) {\n commonBarComponentProps.x = item.id;\n } else {\n commonBarComponentProps.y = item.id;\n }\n\n return item.checked && <BarComponent key={item.id} {...commonBarComponentProps} />;\n })}\n </GroupBar>\n {dataDefinitions.map((item) => item.checked && this.renderTrend(item.id))}\n </>\n );\n }\n\n if (type === 'stack') {\n return (\n <>\n <StackBar x={invertAxis ? undefined : groupKey} y={invertAxis ? groupKey : undefined}>\n {dataDefinitions.map((item, index) => {\n const BarComponent = invertAxis ? StackBar.HorizontalBar : StackBar.Bar;\n\n const commonBarComponentProps: BarProps = {\n color: item.color,\n transparent: highlightedItem !== -1 && highlightedItem !== index,\n onClick: this.handleClickBar,\n };\n\n if (invertAxis) {\n commonBarComponentProps.x = item.id;\n } else {\n commonBarComponentProps.y = item.id;\n }\n\n return item.checked && <BarComponent key={item.id} {...commonBarComponentProps} />;\n })}\n </StackBar>\n {dataDefinitions.map((item) => item.checked && this.renderTrend(item.id))}\n </>\n );\n }\n\n return null;\n }\n\n renderTooltip(): React.ReactNode {\n const { data, groupKey, invertAxis, onClickHoverRect } = this.asProps;\n\n return (\n <HoverRect.Tooltip\n x={invertAxis ? undefined : groupKey}\n y={invertAxis ? groupKey : undefined}\n wMin={100}\n onClick={onClickHoverRect}\n >\n {({ xIndex, yIndex }: any) => {\n const index = invertAxis ? yIndex : xIndex;\n const dataItem = data[index];\n\n return {\n children: this.getTooltipChildren({\n Tooltip: HoverRect.Tooltip,\n dataItem,\n index,\n }),\n };\n }}\n </HoverRect.Tooltip>\n );\n }\n\n protected override renderAxis(): React.ReactNode {\n const {\n invertAxis,\n showXAxis,\n showYAxis,\n data,\n axisXValueFormatter,\n axisYValueFormatter,\n multilineXTicks,\n multilineYTicks,\n } = this.asProps;\n\n if (!Array.isArray(data)) {\n return null;\n }\n\n const xTicks = this.xTicks;\n const yTicks = this.yTicks;\n\n const childrenX = axisXValueFormatter\n ? ({ value }: any) => ({ children: axisXValueFormatter(value) })\n : undefined;\n const childrenY = axisYValueFormatter\n ? ({ value }: any) => ({ children: axisYValueFormatter(value) })\n : undefined;\n\n return (\n <>\n {showYAxis && (\n <YAxis>\n {yTicks\n ? (\n <YAxis.Ticks primaryText={invertAxis} multiline={multilineYTicks} ticks={yTicks}>{childrenY}</YAxis.Ticks>\n )\n : (\n <YAxis.Ticks primaryText={invertAxis} multiline={multilineYTicks}>{childrenY}</YAxis.Ticks>\n )}\n {invertAxis !== true && (yTicks ? <YAxis.Grid ticks={yTicks} /> : <YAxis.Grid />)}\n </YAxis>\n )}\n\n {showXAxis && (\n <XAxis>\n {xTicks\n ? (\n <XAxis.Ticks multiline={multilineXTicks} ticks={xTicks}>{childrenX}</XAxis.Ticks>\n )\n : (\n <XAxis.Ticks multiline={multilineXTicks}>{childrenX}</XAxis.Ticks>\n )}\n {invertAxis === true && (xTicks ? <XAxis.Grid ticks={xTicks} /> : <XAxis.Grid />)}\n </XAxis>\n )}\n </>\n );\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Bar' });\n }\n\n private handleClickBar = (\n _data: BarChartData[0],\n e: React.SyntheticEvent,\n barIndex: number,\n barKey: string,\n ) => {\n const { onClickBar } = this.asProps;\n\n if (onClickBar) {\n onClickBar(barIndex, barKey, e);\n }\n };\n\n private get categoryScale() {\n const {\n marginY = 40,\n marginX = 32,\n invertAxis,\n data,\n groupKey,\n } = this.asProps;\n const { plotWidth, plotHeight } = this;\n\n const testItem = data[0][groupKey];\n const range = invertAxis\n ? [plotHeight - marginX, this.plotPadding]\n : [marginY, plotWidth - this.plotPadding];\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n const domain = minMax(data, groupKey);\n\n return scaleTime(domain, range);\n }\n\n const domain = data.map((item) => item[groupKey]);\n\n return scaleBand(domain, range).paddingInner(0.4).paddingOuter(0.2);\n }\n\n private get valueScale() {\n const { marginY = 40, marginX = 32, invertAxis, type } = this.asProps;\n const { plotWidth, plotHeight } = this;\n\n const max = type === 'stack' ? super.maxStackedValue : Math.max(...super.flatValues);\n\n return scaleLinear()\n .range(\n invertAxis\n ? [marginY, plotWidth - this.plotPadding]\n : [plotHeight - marginX, this.plotPadding],\n )\n .domain([0, max]);\n }\n}\n\n/**\n * BarChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/bar-chart/bar-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/bar-chart/bar-chart-code/|Examples}\n */\nexport const BarChart = createComponent<\n BarChartType,\n typeof BarChartComponent\n>(BarChartComponent);\n"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,SAAS,EAAEC,WAAW,EAAEC,SAAS,QAAQ,UA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;MAAE3E,UAAU;MAAEyB;IAAK,CAAC,GAAG,IAAI,CAAC3B,OAAO;IACrE,MAAM;MAAE8E,SAAS;MAAEC;IAAW,CAAC,GAAG,IAAI;IAEtC,MAAMW,GAAG,GAAG/D,IAAI,KAAK,OAAO,GAAG,KAAK,CAACgE,eAAe,GAAGC,IAAI,CAACF,GAAG,CAAC,GAAG,KAAK,CAACG,UAAU,CAAC;IAEpF,OAAOlH,WAAW,CAAC,CAAC,CACjBsG,KAAK,CACJ/E,UAAU,GACN,CAAC0E,OAAO,EAAEE,SAAS,GAAG,IAAI,CAACI,WAAW,CAAC,GACvC,CAACH,UAAU,GAAGF,OAAO,EAAE,IAAI,CAACK,WAAW,CAC7C,CAAC,CACAK,MAAM,CAAC,CAAC,CAAC,EAAEG,GAAG,CAAC,CAAC;EACrB;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJAhG,eAAA,CAtSMH,iBAAiB,iBAQA,WAAW;AAAAG,eAAA,CAR5BH,iBAAiB,aAUJ,CAACd,WAAW,CAACa,iBAAiB,CAAC,CAAC;AAAAI,eAAA,CAV7CH,iBAAiB,kBAYC;EACpBuG,SAAS,EAAE,QAAQ;EACnBvC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfuC,WAAW,EAAE,IAAI;EACjBC,MAAM,EAAE;AACV,CAAC;AAyRH,OAAO,MAAMC,QAAQ,GAAGzH,eAAe,CAGrCe,iBAAiB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"BarChart.js","names":["createComponent","i18nEnhance","scaleBand","scaleLinear","scaleTime","React","AbstractChart","minMax","GroupBar","HoverRect","StackBar","Line","YAxis","XAxis","localizedMessages","BarChartComponent","constructor","args","_defineProperty","_data","e","barIndex","barKey","onClickBar","asProps","xScale","invertAxis","valueScale","categoryScale","yScale","defaultLegendProps","props","trend","undefined","withTrend","renderTrend","key","groupKey","state","trendItem","createElement","data","x","y","color","style","strokeWidth","strokeDasharray","Dots","display","renderChart","type","dataDefinitions","highlightedItem","length","item","BarComponent","HorizontalBar","Bar","checked","Fragment","id","onClick","handleClickBar","map","index","commonBarComponentProps","transparent","_extends","renderTooltip","onClickHoverRect","showXAxis","Tooltip","wMin","hideTickHover","xIndex","yIndex","dataItem","children","getTooltipChildren","renderAxis","showYAxis","axisXValueFormatter","axisYValueFormatter","multilineXTicks","multilineYTicks","Array","isArray","xTicks","yTicks","childrenX","value","childrenY","Ticks","primaryText","multiline","ticks","Grid","getLegendAriaLabel","getI18nText","chartType","marginY","marginX","plotWidth","plotHeight","testItem","range","plotPadding","Date","Number","isNaN","getMilliseconds","domain","paddingInner","paddingOuter","max","maxStackedValue","Math","flatValues","direction","showTooltip","locale","deltaPercentGrowthColor","BarChart"],"sources":["../../../../src/component/Chart/BarChart.tsx"],"sourcesContent":["import { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { scaleBand, scaleLinear, scaleTime } from 'd3-scale';\nimport React from 'react';\n\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { BaseLegendProps } from './AbstractChart.type';\nimport type { BarChartData, BarChartProps, BarChartType, BarChartDefaultProps } from './BarChart.type';\n// @ts-ignore\nimport { minMax, GroupBar, HoverRect, StackBar, Line, YAxis, XAxis } from '../..';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\nimport type { BarProps } from '../../types';\nimport type { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\n\nclass BarChartComponent extends AbstractChart<\n BarChartData,\n BarChartProps,\n typeof BarChartComponent.enhance,\n {},\n ChartState,\n BarChartDefaultProps\n> {\n static displayName = 'Chart.Bar';\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n locale: 'en',\n deltaPercentGrowthColor: 'success',\n } as const;\n\n get xScale() {\n const { xScale, invertAxis } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n return invertAxis ? this.valueScale : this.categoryScale;\n }\n\n get yScale() {\n const { yScale, invertAxis } = this.asProps;\n\n if (yScale) {\n return yScale;\n }\n\n return invertAxis ? this.categoryScale : this.valueScale;\n }\n\n protected defaultLegendProps(): Partial<BaseLegendProps> {\n if (this.props.trend !== undefined) {\n return { withTrend: true };\n }\n\n return {};\n }\n\n renderTrend(key: LegendItemKey) {\n const { groupKey, invertAxis, trend } = this.asProps;\n const { withTrend } = this.state;\n const trendItem = trend?.[key];\n\n if (withTrend && trendItem) {\n return (\n <Line\n data={trendItem}\n key={`${key}_${groupKey}`}\n x={invertAxis ? 'y' : 'x'}\n y={invertAxis ? 'x' : 'y'}\n color='wall'\n style={{ strokeWidth: 3, strokeDasharray: 5 }}\n >\n <Line.Dots data={trendItem} display />\n </Line>\n );\n }\n\n return null;\n }\n\n renderChart() {\n const { groupKey, type = 'group', invertAxis } = this.asProps;\n const { dataDefinitions, highlightedItem } = this.state;\n\n if (dataDefinitions.length === 1) {\n const item = dataDefinitions[0];\n const BarComponent = invertAxis ? GroupBar.HorizontalBar : GroupBar.Bar;\n\n return (\n item.checked && (\n <>\n <BarComponent\n x={invertAxis ? item.id : groupKey}\n y={invertAxis ? groupKey : item.id}\n key={item.id}\n color={item.color}\n onClick={this.handleClickBar}\n />\n {this.renderTrend(item.id)}\n </>\n )\n );\n }\n\n if (type === 'group') {\n return (\n <>\n <GroupBar x={invertAxis ? undefined : groupKey} y={invertAxis ? groupKey : undefined}>\n {dataDefinitions.map((item, index) => {\n const BarComponent = invertAxis ? GroupBar.HorizontalBar : GroupBar.Bar;\n\n const commonBarComponentProps: BarProps = {\n color: item.color,\n transparent: highlightedItem !== -1 && highlightedItem !== index,\n onClick: this.handleClickBar,\n };\n\n if (invertAxis) {\n commonBarComponentProps.x = item.id;\n } else {\n commonBarComponentProps.y = item.id;\n }\n\n return item.checked && <BarComponent key={item.id} {...commonBarComponentProps} />;\n })}\n </GroupBar>\n {dataDefinitions.map((item) => item.checked && this.renderTrend(item.id))}\n </>\n );\n }\n\n if (type === 'stack') {\n return (\n <>\n <StackBar x={invertAxis ? undefined : groupKey} y={invertAxis ? groupKey : undefined}>\n {dataDefinitions.map((item, index) => {\n const BarComponent = invertAxis ? StackBar.HorizontalBar : StackBar.Bar;\n\n const commonBarComponentProps: BarProps = {\n color: item.color,\n transparent: highlightedItem !== -1 && highlightedItem !== index,\n onClick: this.handleClickBar,\n };\n\n if (invertAxis) {\n commonBarComponentProps.x = item.id;\n } else {\n commonBarComponentProps.y = item.id;\n }\n\n return item.checked && <BarComponent key={item.id} {...commonBarComponentProps} />;\n })}\n </StackBar>\n {dataDefinitions.map((item) => item.checked && this.renderTrend(item.id))}\n </>\n );\n }\n\n return null;\n }\n\n renderTooltip(): React.ReactNode {\n const { data, groupKey, invertAxis, onClickHoverRect, showXAxis } = this.asProps;\n\n return (\n <HoverRect.Tooltip\n x={invertAxis ? undefined : groupKey}\n y={invertAxis ? groupKey : undefined}\n wMin={100}\n onClick={onClickHoverRect}\n hideTickHover={!showXAxis}\n >\n {({ xIndex, yIndex }: any) => {\n const index = invertAxis ? yIndex : xIndex;\n const dataItem = data[index];\n\n return {\n children: this.getTooltipChildren({\n Tooltip: HoverRect.Tooltip,\n dataItem,\n index,\n }),\n };\n }}\n </HoverRect.Tooltip>\n );\n }\n\n protected override renderAxis(): React.ReactNode {\n const {\n invertAxis,\n showXAxis,\n showYAxis,\n data,\n axisXValueFormatter,\n axisYValueFormatter,\n multilineXTicks,\n multilineYTicks,\n } = this.asProps;\n\n if (!Array.isArray(data)) {\n return null;\n }\n\n const xTicks = this.xTicks;\n const yTicks = this.yTicks;\n\n const childrenX = axisXValueFormatter\n ? ({ value }: any) => ({ children: axisXValueFormatter(value) })\n : undefined;\n const childrenY = axisYValueFormatter\n ? ({ value }: any) => ({ children: axisYValueFormatter(value) })\n : undefined;\n\n return (\n <>\n {showYAxis && (\n <YAxis>\n {yTicks\n ? (\n <YAxis.Ticks primaryText={invertAxis} multiline={multilineYTicks} ticks={yTicks}>{childrenY}</YAxis.Ticks>\n )\n : (\n <YAxis.Ticks primaryText={invertAxis} multiline={multilineYTicks}>{childrenY}</YAxis.Ticks>\n )}\n {invertAxis !== true && (yTicks ? <YAxis.Grid ticks={yTicks} /> : <YAxis.Grid />)}\n </YAxis>\n )}\n\n {showXAxis && (\n <XAxis>\n {xTicks\n ? (\n <XAxis.Ticks multiline={multilineXTicks} ticks={xTicks}>{childrenX}</XAxis.Ticks>\n )\n : (\n <XAxis.Ticks multiline={multilineXTicks}>{childrenX}</XAxis.Ticks>\n )}\n {invertAxis === true && (xTicks ? <XAxis.Grid ticks={xTicks} /> : <XAxis.Grid />)}\n </XAxis>\n )}\n </>\n );\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Bar' });\n }\n\n private handleClickBar = (\n _data: BarChartData[0],\n e: React.SyntheticEvent,\n barIndex: number,\n barKey: string,\n ) => {\n const { onClickBar } = this.asProps;\n\n if (onClickBar) {\n onClickBar(barIndex, barKey, e);\n }\n };\n\n private get categoryScale() {\n const {\n marginY = 40,\n marginX = 32,\n invertAxis,\n data,\n groupKey,\n } = this.asProps;\n const { plotWidth, plotHeight } = this;\n\n const testItem = data[0][groupKey];\n const range = invertAxis\n ? [plotHeight - marginX, this.plotPadding]\n : [marginY, plotWidth - this.plotPadding];\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n const domain = minMax(data, groupKey);\n\n return scaleTime(domain, range);\n }\n\n const domain = data.map((item) => item[groupKey]);\n\n return scaleBand(domain, range).paddingInner(0.4).paddingOuter(0.2);\n }\n\n private get valueScale() {\n const { marginY = 40, marginX = 32, invertAxis, type } = this.asProps;\n const { plotWidth, plotHeight } = this;\n\n const max = type === 'stack' ? super.maxStackedValue : Math.max(...super.flatValues);\n\n return scaleLinear()\n .range(\n invertAxis\n ? [marginY, plotWidth - this.plotPadding]\n : [plotHeight - marginX, this.plotPadding],\n )\n .domain([0, max]);\n }\n}\n\n/**\n * BarChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/bar-chart/bar-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/bar-chart/bar-chart-code/|Examples}\n */\nexport const BarChart = createComponent<\n BarChartType,\n typeof BarChartComponent\n>(BarChartComponent);\n"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,SAAS,EAAEC,WAAW,EAAEC,SAAS,QAAQ,UAAU;AAC5D,OAAOC,KAAK,MAAM,OAAO;AAGzB,SAASC,aAAa,QAAQ,iBAAiB;AAG/C;AACA,SAASC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,KAAK,EAAEC,KAAK,QAAQ,OAAO;AACjF,SAASC,iBAAiB,QAAQ,oDAAoD;AAItF,MAAMC,iBAAiB,SAAST,aAAa,CAO3C;EAAAU,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,yBA0OyB,CACvBC,KAAsB,EACtBC,CAAuB,EACvBC,QAAgB,EAChBC,MAAc,KACX;MACH,MAAM;QAAEC;MAAW,CAAC,GAAG,IAAI,CAACC,OAAO;MAEnC,IAAID,UAAU,EAAE;QACdA,UAAU,CAACF,QAAQ,EAAEC,MAAM,EAAEF,CAAC,CAAC;MACjC;IACF,CAAC;EAAA;EAvOD,IAAIK,MAAMA,CAAA,EAAG;IACX,MAAM;MAAEA,MAAM;MAAEC;IAAW,CAAC,GAAG,IAAI,CAACF,OAAO;IAE3C,IAAIC,MAAM,EAAE;MACV,OAAOA,MAAM;IACf;IAEA,OAAOC,UAAU,GAAG,IAAI,CAACC,UAAU,GAAG,IAAI,CAACC,aAAa;EAC1D;EAEA,IAAIC,MAAMA,CAAA,EAAG;IACX,MAAM;MAAEA,MAAM;MAAEH;IAAW,CAAC,GAAG,IAAI,CAACF,OAAO;IAE3C,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AAE;AAC3B,CAAC;AA0RH,OAAO,MAAMC,QAAQ,GAAG3H,eAAe,CAGrCe,iBAAiB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.type.js","names":[],"sources":["../../../../src/component/Chart/BarChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';\nimport type React from 'react';\n\nimport type { AriaNameProps, BaseChartProps } from './AbstractChart.type';\nimport type { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\n\ntype TrendItem = {\n x: number | string;\n y: number | string;\n};\n\ntype BarKey = string;\n\nexport type BarChartData = Array<Record<BarKey, string | number | Date>>;\n\nexport type BarChartProps = BaseChartProps<BarChartData> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Custom x-axis scale */\n xScale?: ScaleBand<any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Controls whether bars are grouped side-by-side or stacked */\n type?: 'stack' | 'group';\n /** Optional trend line data to overlay on the bars */\n trend?: Record<LegendItemKey, TrendItem[]>;\n /** Handle click by `HoverRect`. `index` is an index of the data array. */\n onClickHoverRect?: (index: number, e: React.SyntheticEvent) => void;\n /** Handle click by Bar. */\n onClickBar?: (barItem: number, barKey: BarKey, e: React.SyntheticEvent) => void;\n};\n\nexport type BarChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n};\n\nexport type BarChartType = Intergalactic.Component<typeof Flex, BarChartProps & AriaNameProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"BarChart.type.js","names":[],"sources":["../../../../src/component/Chart/BarChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';\nimport type React from 'react';\n\nimport type { AriaNameProps, BaseChartProps } from './AbstractChart.type';\nimport type { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\n\ntype TrendItem = {\n x: number | string;\n y: number | string;\n};\n\ntype BarKey = string;\n\nexport type BarChartData = Array<Record<BarKey, string | number | Date>>;\n\nexport type BarChartProps = BaseChartProps<BarChartData> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Custom x-axis scale */\n xScale?: ScaleBand<any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Controls whether bars are grouped side-by-side or stacked */\n type?: 'stack' | 'group';\n /** Optional trend line data to overlay on the bars */\n trend?: Record<LegendItemKey, TrendItem[]>;\n /** Handle click by `HoverRect`. `index` is an index of the data array. */\n onClickHoverRect?: (index: number, e: React.SyntheticEvent) => void;\n /** Handle click by Bar. */\n onClickBar?: (barItem: number, barKey: BarKey, e: React.SyntheticEvent) => void;\n};\n\nexport type BarChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n deltaPercentGrowthColor: 'success';\n};\n\nexport type BarChartType = Intergalactic.Component<typeof Flex, BarChartProps & AriaNameProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -11,6 +11,10 @@ import { Bubble, calculateBubbleDomain } from '../..';
|
|
|
11
11
|
import { AbstractChart } from './AbstractChart';
|
|
12
12
|
import { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';
|
|
13
13
|
class BubbleChartComponent extends AbstractChart {
|
|
14
|
+
constructor(...args) {
|
|
15
|
+
super(...args);
|
|
16
|
+
_defineProperty(this, "plotPadding", 8);
|
|
17
|
+
}
|
|
14
18
|
get dataKeys() {
|
|
15
19
|
const {
|
|
16
20
|
data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BubbleChart.js","names":["Box","Flex","createComponent","sstyled","i18nEnhance","Text","scaleLinear","React","Bubble","calculateBubbleDomain","AbstractChart","localizedMessages","BubbleChartComponent","dataKeys","data","props","map","_","index","toString","getDefaultDataDefinitions","legendProps","item","key","legendData","legendMap","color","undefined","resolveColor","dataDefinition","id","label","icon","checked","defaultChecked","columns","additionalInfo","count","xScale","marginY","asProps","plotWidth","range","plotPadding","domain","yScale","marginX","plotHeight","defaultLegendProps","shape","renderChart","onClickBubble","dataDefinitions","state","createElement","onClick","x","y","value","Circle","visible","renderTooltip","Tooltip","_ref","styles","STooltipChildrenWrapper","children","cn","Title","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","showXAxis","showYAxis","showTooltip","locale","BubbleChart"],"sources":["../../../../src/component/Chart/BubbleChart.tsx"],"sourcesContent":["import { Box, Flex } from '@semcore/base-components';\nimport { createComponent, sstyled } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { Text } from '@semcore/typography';\nimport { scaleLinear, type ScaleLinear } from 'd3-scale';\nimport React from 'react';\n\n// @ts-ignore\nimport { Bubble, calculateBubbleDomain } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { BubbleChartData, BubbleChartProps, BubbleChartType, BubbleChartDefaultProps } from './BubbleChart.type';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\nimport type { LegendItem } from '../ChartLegend/LegendItem/LegendItem.type';\n\nclass BubbleChartComponent extends AbstractChart<\n BubbleChartData,\n BubbleChartProps,\n typeof BubbleChartComponent.enhance,\n {},\n ChartState,\n BubbleChartDefaultProps\n> {\n static displayName = 'Chart.Bubble';\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n locale: 'en',\n } as const;\n\n protected get dataKeys(): string[] {\n const { data } = this.props;\n\n return data.map((_, index) => index.toString());\n }\n\n protected override getDefaultDataDefinitions(): Array<\n LegendItem & { columns: React.ReactNode[] }\n > {\n const { legendProps, data } = this.props;\n\n return data.map((item, index) => {\n const key = index.toString();\n const legendData = legendProps?.legendMap?.[key];\n\n if (item.color === undefined) {\n item.color = this.resolveColor(key, index);\n }\n\n const dataDefinition: LegendItem & { columns: React.ReactNode[] } = {\n id: key,\n label: legendData?.label ?? item.label ?? key,\n icon: legendData?.icon ?? undefined,\n checked: legendData?.defaultChecked ?? true,\n color: item.color,\n columns: [],\n };\n\n if (legendData?.additionalInfo || legendData?.count) {\n dataDefinition.additionalInfo = legendData.additionalInfo\n ? { label: legendData.additionalInfo }\n : legendData.count\n ? { count: legendData.count }\n : undefined;\n }\n\n return dataDefinition;\n });\n }\n\n get xScale() {\n const { xScale, marginY = 30, data } = this.asProps;\n const { plotWidth } = this;\n\n if (xScale) {\n return xScale;\n }\n\n const range = [marginY, plotWidth - this.plotPadding];\n const domain = calculateBubbleDomain(data, 'x', range);\n\n return scaleLinear().domain(domain).range(range);\n }\n\n get yScale(): ScaleLinear<any, any> {\n const { yScale, marginX = 30, data } = this.asProps;\n const { plotHeight } = this;\n\n if (yScale) {\n return yScale;\n }\n\n const range = [plotHeight - marginX, this.plotPadding];\n const domain = calculateBubbleDomain(data, 'y', range);\n\n return scaleLinear().domain(domain).range(range);\n }\n\n defaultLegendProps() {\n return {\n shape: 'Circle' as const,\n };\n }\n\n renderChart() {\n const { onClickBubble } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return (\n <Bubble onClick={onClickBubble} x='x' y='y' value='value' color='color' label='label'>\n {dataDefinitions.map(({ checked, id }, index) => (\n <Bubble.Circle visible={checked} key={id} index={index} />\n ))}\n </Bubble>\n );\n }\n\n renderTooltip() {\n return (\n <Bubble.Tooltip>\n {({ index, data }: any) => {\n const { styles } = this.asProps;\n const STooltipChildrenWrapper = Box;\n\n return {\n children: sstyled(styles)(\n <Flex direction='column'>\n <Bubble.Tooltip.Title>Data</Bubble.Tooltip.Title>\n <STooltipChildrenWrapper\n // @ts-ignore\n columnsCount={2}\n >\n <Text>X axis</Text>\n <Text textAlign='end'>{data[index].x}</Text>\n <Text>Y axis</Text>\n <Text textAlign='end'>{data[index].y}</Text>\n <Text>Value</Text>\n <Text textAlign='end'>{data[index].value}</Text>\n </STooltipChildrenWrapper>\n </Flex>,\n ),\n };\n }}\n </Bubble.Tooltip>\n );\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Bubble' });\n }\n}\n\n/**\n * BubbleChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/bubble-chart/bubble-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/bubble-chart/bubble-chart-code/|Examples}\n */\nexport const BubbleChart = createComponent<\n BubbleChartType,\n typeof BubbleChartComponent\n>(BubbleChartComponent);\n"],"mappings":";AAAA,SAASA,GAAG,EAAEC,IAAI,QAAQ,0BAA0B;AACpD,SAASC,eAAe,EAAEC,OAAO,QAAQ,eAAe;AACxD,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,SAASC,WAAW,QAA0B,UAAU;AACxD,OAAOC,KAAK,MAAM,OAAO;;AAEzB;AACA,SAASC,MAAM,EAAEC,qBAAqB,QAAQ,OAAO;AAErD,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,iBAAiB,QAAQ,oDAAoD;AAGtF,MAAMC,oBAAoB,SAASF,aAAa,CAO9C;EAaA,IAAcG,QAAQA,CAAA,EAAa;IACjC,MAAM;MAAEC;IAAK,CAAC,GAAG,IAAI,CAACC,KAAK;IAE3B,OAAOD,IAAI,CAACE,GAAG,CAAC,CAACC,CAAC,EAAEC,KAAK,KAAKA,KAAK,CAACC,QAAQ,CAAC,CAAC,CAAC;EACjD;EAEmBC,yBAAyBA,CAAA,EAE1C;IACA,MAAM;MAAEC,WAAW;MAAEP;IAAK,CAAC,GAAG,IAAI,CAACC,KAAK;IAExC,OAAOD,IAAI,CAACE,GAAG,CAAC,CAACM,IAAI,EAAEJ,KAAK,KAAK;MAC/B,M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I,EAAA0D,IAAA,CAAAI,EAAA;UAAA,aAAW;QAAK,IAAErD,IAAI,CAACI,KAAK,CAAC,CAACwC,KAAY,CACxB,CACrB,CAAC;MAEX,CAAC;IACH,CACc,CAAC;EAErB;EAEUW,kBAAkBA,CAAA,EAAW;IACrC,OAAO,IAAI,CAAC7B,OAAO,CAAC8B,WAAW,CAAC,gBAAgB,EAAE;MAAEC,SAAS,EAAE;IAAS,CAAC,CAAC;EAC5E;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJAC,eAAA,CA9IM5D,oBAAoB,iBAQH,cAAc;AAAA4D,eAAA,CAR/B5D,oBAAoB,aAUP,CAACR,WAAW,CAACO,iBAAiB,CAAC,CAAC;AAAA6D,eAAA,CAV7C5D,oBAAoB,kBAYF;EACpB6D,SAAS,EAAE,QAAQ;EACnBC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,IAAI;EACjBC,MAAM,EAAE;AACV,CAAC;AAiIH,OAAO,MAAMC,WAAW,GAAG5E,eAAe,CAGxCU,oBAAoB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"BubbleChart.js","names":["Box","Flex","createComponent","sstyled","i18nEnhance","Text","scaleLinear","React","Bubble","calculateBubbleDomain","AbstractChart","localizedMessages","BubbleChartComponent","constructor","args","_defineProperty","dataKeys","data","props","map","_","index","toString","getDefaultDataDefinitions","legendProps","item","key","legendData","legendMap","color","undefined","resolveColor","dataDefinition","id","label","icon","checked","defaultChecked","columns","additionalInfo","count","xScale","marginY","asProps","plotWidth","range","plotPadding","domain","yScale","marginX","plotHeight","defaultLegendProps","shape","renderChart","onClickBubble","dataDefinitions","state","createElement","onClick","x","y","value","Circle","visible","renderTooltip","Tooltip","_ref","styles","STooltipChildrenWrapper","children","cn","Title","getLegendAriaLabel","getI18nText","chartType","direction","showXAxis","showYAxis","showTooltip","locale","BubbleChart"],"sources":["../../../../src/component/Chart/BubbleChart.tsx"],"sourcesContent":["import { Box, Flex } from '@semcore/base-components';\nimport { createComponent, sstyled } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { Text } from '@semcore/typography';\nimport { scaleLinear, type ScaleLinear } from 'd3-scale';\nimport React from 'react';\n\n// @ts-ignore\nimport { Bubble, calculateBubbleDomain } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { BubbleChartData, BubbleChartProps, BubbleChartType, BubbleChartDefaultProps } from './BubbleChart.type';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\nimport type { LegendItem } from '../ChartLegend/LegendItem/LegendItem.type';\n\nclass BubbleChartComponent extends AbstractChart<\n BubbleChartData,\n BubbleChartProps,\n typeof BubbleChartComponent.enhance,\n {},\n ChartState,\n BubbleChartDefaultProps\n> {\n static displayName = 'Chart.Bubble';\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n locale: 'en',\n } as const;\n\n protected plotPadding = 8;\n\n protected get dataKeys(): string[] {\n const { data } = this.props;\n\n return data.map((_, index) => index.toString());\n }\n\n protected override getDefaultDataDefinitions(): Array<\n LegendItem & { columns: React.ReactNode[] }\n > {\n const { legendProps, data } = this.props;\n\n return data.map((item, index) => {\n const key = index.toString();\n const legendData = legendProps?.legendMap?.[key];\n\n if (item.color === undefined) {\n item.color = this.resolveColor(key, index);\n }\n\n const dataDefinition: LegendItem & { columns: React.ReactNode[] } = {\n id: key,\n label: legendData?.label ?? item.label ?? key,\n icon: legendData?.icon ?? undefined,\n checked: legendData?.defaultChecked ?? true,\n color: item.color,\n columns: [],\n };\n\n if (legendData?.additionalInfo || legendData?.count) {\n dataDefinition.additionalInfo = legendData.additionalInfo\n ? { label: legendData.additionalInfo }\n : legendData.count\n ? { count: legendData.count }\n : undefined;\n }\n\n return dataDefinition;\n });\n }\n\n get xScale() {\n const { xScale, marginY = 30, data } = this.asProps;\n const { plotWidth } = this;\n\n if (xScale) {\n return xScale;\n }\n\n const range = [marginY, plotWidth - this.plotPadding];\n const domain = calculateBubbleDomain(data, 'x', range);\n\n return scaleLinear().domain(domain).range(range);\n }\n\n get yScale(): ScaleLinear<any, any> {\n const { yScale, marginX = 30, data } = this.asProps;\n const { plotHeight } = this;\n\n if (yScale) {\n return yScale;\n }\n\n const range = [plotHeight - marginX, this.plotPadding];\n const domain = calculateBubbleDomain(data, 'y', range);\n\n return scaleLinear().domain(domain).range(range);\n }\n\n defaultLegendProps() {\n return {\n shape: 'Circle' as const,\n };\n }\n\n renderChart() {\n const { onClickBubble } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return (\n <Bubble onClick={onClickBubble} x='x' y='y' value='value' color='color' label='label'>\n {dataDefinitions.map(({ checked, id }, index) => (\n <Bubble.Circle visible={checked} key={id} index={index} />\n ))}\n </Bubble>\n );\n }\n\n renderTooltip() {\n return (\n <Bubble.Tooltip>\n {({ index, data }: any) => {\n const { styles } = this.asProps;\n const STooltipChildrenWrapper = Box;\n\n return {\n children: sstyled(styles)(\n <Flex direction='column'>\n <Bubble.Tooltip.Title>Data</Bubble.Tooltip.Title>\n <STooltipChildrenWrapper\n // @ts-ignore\n columnsCount={2}\n >\n <Text>X axis</Text>\n <Text textAlign='end'>{data[index].x}</Text>\n <Text>Y axis</Text>\n <Text textAlign='end'>{data[index].y}</Text>\n <Text>Value</Text>\n <Text textAlign='end'>{data[index].value}</Text>\n </STooltipChildrenWrapper>\n </Flex>,\n ),\n };\n }}\n </Bubble.Tooltip>\n );\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Bubble' });\n }\n}\n\n/**\n * BubbleChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/bubble-chart/bubble-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/bubble-chart/bubble-chart-code/|Examples}\n */\nexport const BubbleChart = createComponent<\n BubbleChartType,\n typeof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iBAQH,cAAc;AAAAG,eAAA,CAR/BH,oBAAoB,aAUP,CAACR,WAAW,CAACO,iBAAiB,CAAC,CAAC;AAAAI,eAAA,CAV7CH,oBAAoB,kBAYF;EACpB+D,SAAS,EAAE,QAAQ;EACnBC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,IAAI;EACjBC,MAAM,EAAE;AACV,CAAC;AAmIH,OAAO,MAAMC,WAAW,GAAG9E,eAAe,CAGxCU,oBAAoB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BubbleChart.type.js","names":[],"sources":["../../../../src/component/Chart/BubbleChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type ScaledValues = {\n x: number[];\n y: number[];\n};\n\nexport type BubbleChartData = Array<{\n x: number;\n y: number;\n value: number;\n label?: string;\n color?: string;\n}>;\n\nexport type BubbleChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<BubbleChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta'\n> & {\n /** Field name that groups the data points */\n groupKey?: never;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Callback triggered when a user clicks on a bubble */\n onClickBubble?: (index: number, event: React.SyntheticEvent) => void;\n};\n\nexport type BubbleChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n};\n\nexport type BubbleChartType = Intergalactic.Component<typeof Flex, BubbleChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"BubbleChart.type.js","names":[],"sources":["../../../../src/component/Chart/BubbleChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type ScaledValues = {\n x: number[];\n y: number[];\n};\n\nexport type BubbleChartData = Array<{\n x: number;\n y: number;\n value: number;\n label?: string;\n color?: string;\n}>;\n\nexport type BubbleChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<BubbleChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta' | 'deltaPercentGrowthColor'\n> & {\n /** Field name that groups the data points */\n groupKey?: never;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Callback triggered when a user clicks on a bubble */\n onClickBubble?: (index: number, event: React.SyntheticEvent) => void;\n};\n\nexport type BubbleChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n};\n\nexport type BubbleChartType = Intergalactic.Component<typeof Flex, BubbleChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CigaretteChart.type.js","names":[],"sources":["../../../../src/component/Chart/CigaretteChart.type.ts"],"sourcesContent":["import type { Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\nimport type { BaseChartProps } from './AbstractChart.type';\nimport type { interpolateValue } from '../../utils';\n\nexport type CigaretteChartDataKey = string;\n\nexport type CigaretteChartData = Record<CigaretteChartDataKey, number | typeof interpolateValue>;\n\nexport type CigaretteChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<CigaretteChartData>,\n 'xScale' | 'yScale' | 'showDeltaPercentInTooltip' | 'getPercentDelta'\n> & {\n /** Title text displayed in the tooltip */\n tooltipTitle?: string;\n /** Controls whether the tooltip shows all data or single item data */\n tooltipViewType?: 'all' | 'single';\n /** Show percent value in tooltip */\n showPercentValueInTooltip?: boolean;\n /** Custom percent formatter. */\n percentFormatter?: (value: number) => number;\n /** Header content for the chart */\n header?: React.ReactNode;\n /** Animation duration in milliseconds */\n duration?: number;\n /** Click handler that receives the data key and event */\n onClick?: (key: CigaretteChartDataKey, event: React.SyntheticEvent) => void;\n /** Minimal bar width in pixels. Default is `2`. */\n minimalBarWidth?: number;\n};\n\nexport type CigaretteChartDefaultProps = {\n invertAxis: CigaretteChartProps['invertAxis'];\n showXAxis: false;\n showYAxis: false;\n showTooltip: true;\n showLegend: false;\n marginX: 0;\n marginY: 0;\n duration: 500;\n plotWidth: CigaretteChartProps['plotWidth'];\n plotHeight: CigaretteChartProps['plotHeight'];\n showPercentValueInTooltip: false;\n minimalBarWidth: 2;\n locale: 'en';\n};\n\nexport type CigaretteChartType = Intergalactic.Component<'div', CigaretteChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"CigaretteChart.type.js","names":[],"sources":["../../../../src/component/Chart/CigaretteChart.type.ts"],"sourcesContent":["import type { Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\nimport type { BaseChartProps } from './AbstractChart.type';\nimport type { interpolateValue } from '../../utils';\n\nexport type CigaretteChartDataKey = string;\n\nexport type CigaretteChartData = Record<CigaretteChartDataKey, number | typeof interpolateValue>;\n\nexport type CigaretteChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<CigaretteChartData>,\n 'xScale' | 'yScale' | 'showDeltaPercentInTooltip' | 'getPercentDelta' | 'deltaPercentGrowthColor'\n> & {\n /** Title text displayed in the tooltip */\n tooltipTitle?: string;\n /** Controls whether the tooltip shows all data or single item data */\n tooltipViewType?: 'all' | 'single';\n /** Show percent value in tooltip */\n showPercentValueInTooltip?: boolean;\n /** Custom percent formatter. */\n percentFormatter?: (value: number) => number;\n /** Header content for the chart */\n header?: React.ReactNode;\n /** Animation duration in milliseconds */\n duration?: number;\n /** Click handler that receives the data key and event */\n onClick?: (key: CigaretteChartDataKey, event: React.SyntheticEvent) => void;\n /** Minimal bar width in pixels. Default is `2`. */\n minimalBarWidth?: number;\n};\n\nexport type CigaretteChartDefaultProps = {\n invertAxis: CigaretteChartProps['invertAxis'];\n showXAxis: false;\n showYAxis: false;\n showTooltip: true;\n showLegend: false;\n marginX: 0;\n marginY: 0;\n duration: 500;\n plotWidth: CigaretteChartProps['plotWidth'];\n plotHeight: CigaretteChartProps['plotHeight'];\n showPercentValueInTooltip: false;\n minimalBarWidth: 2;\n locale: 'en';\n};\n\nexport type CigaretteChartType = Intergalactic.Component<'div', CigaretteChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactHorizontalBarChart.type.js","names":[],"sources":["../../../../src/component/Chart/CompactHorizontalBarChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';\nimport type React from 'react';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\ntype BarKey = string;\n\nexport type CompactHorizontalBarChartData = Array<Record<BarKey, number | string>>;\n\nexport type CompactHorizontalBarChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<CompactHorizontalBarChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta'\n> & {\n /** Field name from data array for the x-axis values */\n x: string;\n /** Field name from data array for the y-axis values */\n y: string;\n /** Custom x-axis scale */\n xScale?: ScaleBand<any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n\n /** Handle click by `HoverRect`. `index` is an index of the data array. */\n onClickHoverRect?: (index: number, e: React.SyntheticEvent) => void;\n\n /** Handle click by Bar. */\n onClickBar?: (barItem: number, e: React.SyntheticEvent) => void;\n};\n\nexport type CompactHorizontalBarChartDefaultProps = {\n direction: 'column';\n showXAxis: false;\n showYAxis: false;\n showTooltip: true;\n showLegend: false;\n locale: 'en';\n};\n\nexport type CompactHorizontalBarChartType = Intergalactic.Component
|
|
1
|
+
{"version":3,"file":"CompactHorizontalBarChart.type.js","names":[],"sources":["../../../../src/component/Chart/CompactHorizontalBarChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';\nimport type React from 'react';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\ntype BarKey = string;\n\nexport type CompactHorizontalBarChartData = Array<Record<BarKey, number | string>>;\n\nexport type CompactHorizontalBarChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<CompactHorizontalBarChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta' | 'deltaPercentGrowthColor'\n> & {\n /** Field name from data array for the x-axis values */\n x: string;\n /** Field name from data array for the y-axis values */\n y: string;\n /** Custom x-axis scale */\n xScale?: ScaleBand<any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n\n /** Handle click by `HoverRect`. `index` is an index of the data array. */\n onClickHoverRect?: (index: number, e: React.SyntheticEvent) => void;\n\n /** Handle click by Bar. */\n onClickBar?: (barItem: number, e: React.SyntheticEvent) => void;\n};\n\nexport type CompactHorizontalBarChartDefaultProps = {\n direction: 'column';\n showXAxis: false;\n showYAxis: false;\n showTooltip: true;\n showLegend: false;\n locale: 'en';\n};\n\nexport type CompactHorizontalBarChartType = Intergalactic.Component<typeof Flex, CompactHorizontalBarChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonutChart.js","names":["Flex","createComponent","i18nEnhance","Text","scaleLinear","React","Donut","AbstractChart","localizedMessages","DonutChartComponent","xScale","asProps","yScale","defaultLegendProps","legendType","renderChart","innerRadius","halfsize","innerLabel","onClickPie","dataDefinitions","highlightedItem","state","checkedLegendItems","filter","item","checked","createElement","onClick","length","EmptyData","map","index","Pie","key","id","dataKey","name","label","color","active","Label","renderTooltip","data","Tooltip","title","find","children","Fragment","Title","tooltipTitleFormatter","justifyContent","bold","tooltipValueFormatter","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","alignItems","marginX","marginY","locale","DonutChart"],"sources":["../../../../src/component/Chart/DonutChart.tsx"],"sourcesContent":["import { Flex } from '@semcore/base-components';\nimport { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { Text } from '@semcore/typography';\nimport { scaleLinear } from 'd3-scale';\nimport React from 'react';\n\n// @ts-ignore\nimport { Donut } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { DonutChartData, DonutChartDefaultProps, DonutChartProps, DonutChartType } from './DonutChart.type';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\n\nclass DonutChartComponent extends AbstractChart<\n DonutChartData,\n DonutChartProps,\n typeof DonutChartComponent.enhance,\n {},\n ChartState,\n DonutChartDefaultProps\n> {\n static displayName = 'Chart.Donut';\n static defaultProps = {\n direction: 'row-reverse',\n alignItems: 'flex-start',\n
|
|
1
|
+
{"version":3,"file":"DonutChart.js","names":["Flex","createComponent","i18nEnhance","Text","scaleLinear","React","Donut","AbstractChart","localizedMessages","DonutChartComponent","xScale","asProps","yScale","defaultLegendProps","legendType","renderChart","innerRadius","halfsize","innerLabel","onClickPie","dataDefinitions","highlightedItem","state","checkedLegendItems","filter","item","checked","createElement","onClick","length","EmptyData","map","index","Pie","key","id","dataKey","name","label","color","active","Label","renderTooltip","data","Tooltip","title","find","children","Fragment","Title","tooltipTitleFormatter","justifyContent","bold","tooltipValueFormatter","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","alignItems","marginX","marginY","locale","DonutChart"],"sources":["../../../../src/component/Chart/DonutChart.tsx"],"sourcesContent":["import { Flex } from '@semcore/base-components';\nimport { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { Text } from '@semcore/typography';\nimport { scaleLinear } from 'd3-scale';\nimport React from 'react';\n\n// @ts-ignore\nimport { Donut } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { DonutChartData, DonutChartDefaultProps, DonutChartProps, DonutChartType } from './DonutChart.type';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\n\nclass DonutChartComponent extends AbstractChart<\n DonutChartData,\n DonutChartProps,\n typeof DonutChartComponent.enhance,\n {},\n ChartState,\n DonutChartDefaultProps\n> {\n static displayName = 'Chart.Donut';\n static defaultProps = {\n direction: 'row-reverse',\n alignItems: 'flex-start',\n marginX: 0,\n marginY: 0,\n locale: 'en',\n } as const;\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n get xScale() {\n const { xScale } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n return scaleLinear();\n }\n\n get yScale() {\n const { yScale } = this.asProps;\n\n if (yScale) {\n return yScale;\n }\n\n return scaleLinear();\n }\n\n defaultLegendProps() {\n return {\n legendType: 'Table' as const,\n };\n }\n\n renderChart() {\n const { innerRadius, halfsize, innerLabel, onClickPie } = this.asProps;\n const { dataDefinitions, highlightedItem } = this.state;\n\n const checkedLegendItems = dataDefinitions.filter((item) => item.checked);\n\n return (\n <Donut onClick={onClickPie} halfsize={halfsize} innerRadius={innerRadius}>\n {checkedLegendItems.length === 0 && <Donut.EmptyData />}\n {checkedLegendItems.map((item, index) => {\n return (\n <Donut.Pie\n key={item.id}\n dataKey={item.id}\n name={item.label}\n color={item.color}\n active={highlightedItem === index}\n />\n );\n })}\n {innerLabel && <Donut.Label>{innerLabel}</Donut.Label>}\n </Donut>\n );\n }\n\n renderTooltip() {\n const { data } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return (\n <Donut.Tooltip>\n {({ dataKey }: any) => {\n const title = dataDefinitions.find((item) => item.id === dataKey);\n\n return {\n children: (\n <>\n <Donut.Tooltip.Title>{this.tooltipTitleFormatter(title?.label || dataKey)}</Donut.Tooltip.Title>\n <Flex justifyContent='space-between'>\n <Text bold>{this.tooltipValueFormatter(data[dataKey])}</Text>\n </Flex>\n </>\n ),\n };\n }}\n </Donut.Tooltip>\n );\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Donut' });\n }\n}\n\n/**\n * DonutChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/donut-chart/donut-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/donut-chart/donut-chart-code/|Examples}\n */\nexport const DonutChart = createComponent<\n DonutChartType,\n typeof DonutChartComponent\n>(DonutChartComponent);\n"],"mappings":";AAAA,SAASA,IAAI,QAAQ,0BAA0B;AAC/C,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,SAASC,WAAW,QAAQ,UAAU;AACtC,OAAOC,KAAK,MAAM,OAAO;;AAEzB;AACA,SAASC,KAAK,QAAQ,OAAO;AAE7B,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,iBAAiB,QAAQ,oDAAoD;AAEtF,MAAMC,mBAAmB,SAASF,aAAa,CAO7C;EAYA,IAAIG,MAAMA,CAAA,EAAG;IACX,MAAM;MAAEA;IAAO,CAAC,GAAG,IAAI,CAACC,OAAO;IAE/B,IAAID,MAAM,EAAE;MACV,OAAOA,MAAM;IACf;IAEA,OAAON,WAAW,CAAC,CAAC;EACtB;EAEA,IAAIQ,MAAMA,CAAA,EAAG;IACX,MAAM;MAAEA;IAAO,CAAC,GAAG,IAAI,CAACD,OAAO;IAE/B,IAAIC,MAAM,EAAE;MACV,OAAOA,MAAM;IACf;IAEA,OAAOR,WAAW,CAAC,CAAC;EACtB;EAEAS,kBAAkBA,CAAA,EAAG;IACnB,OAAO;MACLC,UAAU,EAAE;IACd,CAAC;EACH;EAEAC,WAAWA,CAAA,EAAG;IACZ,M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AI,IAAKA,IAAI,CAACU,EAAE,KAAKC,OAAO,CAAC;MAEjE,OAAO;QACLW,QAAQ,eACN1C,KAAA,CAAAsB,aAAA,CAAAtB,KAAA,CAAA2C,QAAA,qBACE3C,KAAA,CAAAsB,aAAA,CAACrB,KAAK,CAACsC,OAAO,CAACK,KAAK,QAAE,IAAI,CAACC,qBAAqB,CAACL,KAAK,EAAEP,KAAK,IAAIF,OAAO,CAAuB,CAAC,eAChG/B,KAAA,CAAAsB,aAAA,CAAC3B,IAAI;UAACmD,cAAc,EAAC;QAAe,gBAClC9C,KAAA,CAAAsB,aAAA,CAACxB,IAAI;UAACiD,IAAI;QAAA,GAAE,IAAI,CAACC,qBAAqB,CAACV,IAAI,CAACP,OAAO,CAAC,CAAQ,CACxD,CACN;MAEN,CAAC;IACH,CACa,CAAC;EAEpB;EAEUkB,kBAAkBA,CAAA,EAAW;IACrC,OAAO,IAAI,CAAC3C,OAAO,CAAC4C,WAAW,CAAC,gBAAgB,EAAE;MAAEC,SAAS,EAAE;IAAQ,CAAC,CAAC;EAC3E;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJAC,eAAA,CAnGMhD,mBAAmB,iBAQF,aAAa;AAAAgD,eAAA,CAR9BhD,mBAAmB,kBASD;EACpBiD,SAAS,EAAE,aAAa;EACxBC,UAAU,EAAE,YAAY;EACxBC,OAAO,EAAE,CAAC;EACVC,OAAO,EAAE,CAAC;EACVC,MAAM,EAAE;AACV,CAAC;AAAAL,eAAA,CAfGhD,mBAAmB,aAiBN,CAACP,WAAW,CAACM,iBAAiB,CAAC,CAAC;AAuFnD,OAAO,MAAMuD,UAAU,GAAG9D,eAAe,CAGvCQ,mBAAmB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonutChart.type.js","names":[],"sources":["../../../../src/component/Chart/DonutChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\nimport type React from 'react';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type DataKey = string;\n\nexport type DonutChartData = Record<DataKey, number>;\n\nexport type DonutChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<DonutChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta'\n> & {\n /** Internal */\n groupKey?: never;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Controls the inner radius of the donut */\n innerRadius?: number;\n /** Creates a semi-donut chart when enabled */\n halfsize?: boolean;\n /** Content displayed in the center of the donut */\n innerLabel?: React.ReactNode;\n /** Callback triggered when a user clicks on a pie */\n onClickPie?: (key: DataKey, e: React.SyntheticEvent) => void;\n};\n\nexport type DonutChartDefaultProps = {\n direction: 'row-reverse';\n alignItems: 'flex-start';\n
|
|
1
|
+
{"version":3,"file":"DonutChart.type.js","names":[],"sources":["../../../../src/component/Chart/DonutChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\nimport type React from 'react';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type DataKey = string;\n\nexport type DonutChartData = Record<DataKey, number>;\n\nexport type DonutChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<DonutChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta' | 'deltaPercentGrowthColor'\n> & {\n /** Internal */\n groupKey?: never;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Controls the inner radius of the donut */\n innerRadius?: number;\n /** Creates a semi-donut chart when enabled */\n halfsize?: boolean;\n /** Content displayed in the center of the donut */\n innerLabel?: React.ReactNode;\n /** Callback triggered when a user clicks on a pie */\n onClickPie?: (key: DataKey, e: React.SyntheticEvent) => void;\n};\n\nexport type DonutChartDefaultProps = {\n direction: 'row-reverse';\n alignItems: 'flex-start';\n marginX: 0;\n marginY: 0;\n locale: 'en';\n};\n\nexport type DonutChartType = Intergalactic.Component<typeof Flex, DonutChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -114,12 +114,14 @@ class HistogramChartComponent extends AbstractChart {
|
|
|
114
114
|
const {
|
|
115
115
|
data,
|
|
116
116
|
groupKey,
|
|
117
|
-
invertAxis
|
|
117
|
+
invertAxis,
|
|
118
|
+
showXAxis
|
|
118
119
|
} = this.asProps;
|
|
119
120
|
return /*#__PURE__*/React.createElement(HoverRect.Tooltip, {
|
|
120
121
|
x: invertAxis ? undefined : groupKey,
|
|
121
122
|
y: invertAxis ? groupKey : undefined,
|
|
122
|
-
wMin: 100
|
|
123
|
+
wMin: 100,
|
|
124
|
+
hideTickHover: !showXAxis
|
|
123
125
|
}, ({
|
|
124
126
|
xIndex,
|
|
125
127
|
yIndex
|
|
@@ -154,7 +156,8 @@ _defineProperty(HistogramChartComponent, "defaultProps", {
|
|
|
154
156
|
showXAxis: true,
|
|
155
157
|
showYAxis: true,
|
|
156
158
|
showTooltip: true,
|
|
157
|
-
locale: 'en'
|
|
159
|
+
locale: 'en',
|
|
160
|
+
deltaPercentGrowthColor: 'success'
|
|
158
161
|
});
|
|
159
162
|
export const HistogramChart = createComponent(HistogramChartComponent);
|
|
160
163
|
//# sourceMappingURL=HistogramChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistogramChart.js","names":["createComponent","i18nEnhance","scaleBand","scaleLinear","scaleTime","React","Bar","minMax","HoverRect","StackBar","AbstractChart","localizedMessages","HistogramChartComponent","xScale","marginY","marginX","invertAxis","data","groupKey","asProps","plotWidth","plotHeight","testItem","range","plotPadding","Date","Number","isNaN","getMilliseconds","domain","map","item","paddingInner","paddingOuter","yScale","max","isStack","reduce","barSum","Object","values","sum","val","flatValues","Math","dataDefinitions","state","length","renderChart","highlightedItem","createElement","x","undefined","y","index","BarComponent","HorizontalBar","commonBarComponentProps","color","transparent","id","checked","_extends","key","renderTooltip","Tooltip","wMin","xIndex","yIndex","dataItem","children","getTooltipChildren","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","showXAxis","showYAxis","showTooltip","locale","HistogramChart"],"sources":["../../../../src/component/Chart/HistogramChart.tsx"],"sourcesContent":["import { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { scaleBand, scaleLinear, type ScaleLinear, scaleTime } from 'd3-scale';\nimport React from 'react';\n\n// @ts-ignore\nimport { Bar, minMax, HoverRect, StackBar, type BarProps } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { HistogramChartData, HistogramChartDefaultProps, HistogramChartProps, HistogramChartType } from './HistogramChart.type';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\n\nclass HistogramChartComponent extends AbstractChart<\n HistogramChartData,\n HistogramChartProps,\n typeof HistogramChartComponent.enhance,\n {},\n ChartState,\n HistogramChartDefaultProps\n> {\n static displayName = 'Chart.Histogram';\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n locale: 'en',\n } as const;\n\n get xScale() {\n const {\n xScale,\n marginY = 30,\n marginX = 30,\n invertAxis,\n data,\n groupKey,\n } = this.asProps;\n const { plotWidth, plotHeight } = this;\n\n if (xScale) {\n return xScale;\n }\n\n const testItem = data[0][groupKey];\n const range = invertAxis\n ? [plotHeight - marginX, this.plotPadding]\n : [marginY, plotWidth - this.plotPadding];\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n const domain = minMax(data, groupKey);\n\n return scaleTime(domain, range);\n }\n\n const domain = data.map((item) => item[groupKey]);\n\n return scaleBand(domain, range).paddingInner(0.05).paddingOuter(0.2);\n }\n\n get yScale(): ScaleLinear<any, any> {\n const {\n yScale,\n marginY = 30,\n marginX = 30,\n invertAxis,\n data,\n } = this.asProps;\n const { plotWidth, plotHeight } = this;\n\n let max: number;\n\n if (this.isStack) {\n max = data.reduce((max, item) => {\n const barSum = Object.values(item).reduce<number>((sum, val) => {\n if (val instanceof Date && !Number.isNaN(val.getMilliseconds())) {\n return sum + val.getMilliseconds();\n }\n\n return sum + (val as number);\n }, 0);\n\n if (barSum > max) {\n max = barSum;\n }\n\n return max;\n }, 0);\n } else {\n const flatValues = super.flatValues;\n\n max = Math.max(...flatValues);\n }\n\n return (\n yScale ??\n scaleLinear()\n .range(\n invertAxis\n ? [marginY, plotWidth - this.plotPadding]\n : [plotHeight - marginX, this.plotPadding],\n )\n .domain([0, max])\n );\n }\n\n get isStack(): boolean {\n const { dataDefinitions } = this.state;\n\n return dataDefinitions.length > 1;\n }\n\n renderChart() {\n const { groupKey, invertAxis } = this.asProps;\n const { dataDefinitions, highlightedItem } = this.state;\n\n if (this.isStack) {\n return (\n <StackBar x={invertAxis ? undefined : groupKey} y={invertAxis ? groupKey : undefined}>\n {dataDefinitions.map((item, index) => {\n const BarComponent = invertAxis ? StackBar.HorizontalBar : StackBar.Bar;\n\n const commonBarComponentProps: BarProps = {\n color: item.color,\n transparent: highlightedItem !== -1 && highlightedItem !== index,\n };\n\n if (invertAxis) {\n commonBarComponentProps.x = item.id;\n } else {\n commonBarComponentProps.y = item.id;\n }\n\n return item.checked && <BarComponent key={item.id} {...commonBarComponentProps} />;\n })}\n </StackBar>\n );\n }\n\n const item = dataDefinitions[0];\n\n return (\n item.checked && (\n <Bar\n x={invertAxis ? item.id : groupKey}\n y={invertAxis ? groupKey : item.id}\n key={item.id}\n color={item.color}\n />\n )\n );\n }\n\n renderTooltip(): React.ReactNode {\n const { data, groupKey, invertAxis } = this.asProps;\n\n return (\n <HoverRect.Tooltip\n x={invertAxis ? undefined : groupKey}\n y={invertAxis ? groupKey : undefined}\n wMin={100}\n >\n {({ xIndex, yIndex }: any) => {\n const index = invertAxis ? yIndex : xIndex;\n const dataItem = data[index];\n\n return {\n children: this.getTooltipChildren({\n Tooltip: HoverRect.Tooltip,\n dataItem,\n index,\n }),\n };\n }}\n </HoverRect.Tooltip>\n );\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Histogram' });\n }\n}\n\n/**\n * HistogramChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/histogram-chart/histogram-chart-api/|API}\n */\nexport const HistogramChart = createComponent<\n HistogramChartType,\n typeof HistogramChartComponent\n>(HistogramChartComponent);\n"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,SAAS,EAAEC,WAAW,EAAoBC,SAAS,QAAQ,UAAU;AAC9E,OAAOC,KAAK,MAAM,OAAO;;AAEzB;AACA,SAASC,GAAG,EAAEC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAuB,OAAO;AAEvE,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,iBAAiB,QAAQ,oDAAoD;AAEtF,MAAMC,uBAAuB,SAASF,aAAa,CAOjD;EAaA,IAAIG,MAAMA,CAAA,EAAG;IACX,MAAM;MACJA,MAAM;MACNC,OAAO,GAAG,EAAE;MACZC,OAAO,GAAG,EAAE;MACZC,UAAU;MACVC,IAAI;MACJC;IACF,CAAC,GAAG,IAAI,CAACC,OAAO;IAChB,MAAM;MAAEC,SAAS;MAAEC;IAAW,CAAC,GAAG,IAAI;IAEtC,IAAIR,MAAM,EAAE;MACV,OAAOA,MAAM;IACf;IAEA,MAAMS,QAAQ,GAAGL,IAAI,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC;IAClC,MAAMK,KAAK,GAAGP,UAAU,GACpB,CAACK,UAAU,GAAGN,OAAO,EAAE,IAAI,CAACS,WAAW,CAAC,GACxC,CAACV,OAAO,EAAEM,SAAS,GAAG,IAAI,CAACI,W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MAE5B,OAAO;QACLgB,QAAQ,EAAE,IAAI,CAACC,kBAAkB,CAAC;UAChCN,OAAO,EAAEzD,SAAS,CAACyD,OAAO;UAC1BI,QAAQ;UACRf;QACF,CAAC;MACH,CAAC;IACH,CACiB,CAAC;EAExB;EAEUkB,kBAAkBA,CAAA,EAAW;IACrC,OAAO,IAAI,CAACrD,OAAO,CAACsD,WAAW,CAAC,gBAAgB,EAAE;MAAEC,SAAS,EAAE;IAAY,CAAC,CAAC;EAC/E;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJAC,eAAA,CA9KM/D,uBAAuB,iBAQN,iBAAiB;AAAA+D,eAAA,CARlC/D,uBAAuB,aAUV,CAACX,WAAW,CAACU,iBAAiB,CAAC,CAAC;AAAAgE,eAAA,CAV7C/D,uBAAuB,kBAYL;EACpBgE,SAAS,EAAE,QAAQ;EACnBC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,IAAI;EACjBC,MAAM,EAAE;AACV,CAAC;AAiKH,OAAO,MAAMC,cAAc,GAAGjF,eAAe,CAG3CY,uBAAuB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"HistogramChart.js","names":["createComponent","i18nEnhance","scaleBand","scaleLinear","scaleTime","React","Bar","minMax","HoverRect","StackBar","AbstractChart","localizedMessages","HistogramChartComponent","xScale","marginY","marginX","invertAxis","data","groupKey","asProps","plotWidth","plotHeight","testItem","range","plotPadding","Date","Number","isNaN","getMilliseconds","domain","map","item","paddingInner","paddingOuter","yScale","max","isStack","reduce","barSum","Object","values","sum","val","flatValues","Math","dataDefinitions","state","length","renderChart","highlightedItem","createElement","x","undefined","y","index","BarComponent","HorizontalBar","commonBarComponentProps","color","transparent","id","checked","_extends","key","renderTooltip","showXAxis","Tooltip","wMin","hideTickHover","xIndex","yIndex","dataItem","children","getTooltipChildren","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","showYAxis","showTooltip","locale","deltaPercentGrowthColor","HistogramChart"],"sources":["../../../../src/component/Chart/HistogramChart.tsx"],"sourcesContent":["import { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { scaleBand, scaleLinear, type ScaleLinear, scaleTime } from 'd3-scale';\nimport React from 'react';\n\n// @ts-ignore\nimport { Bar, minMax, HoverRect, StackBar, type BarProps } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { HistogramChartData, HistogramChartDefaultProps, HistogramChartProps, HistogramChartType } from './HistogramChart.type';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\n\nclass HistogramChartComponent extends AbstractChart<\n HistogramChartData,\n HistogramChartProps,\n typeof HistogramChartComponent.enhance,\n {},\n ChartState,\n HistogramChartDefaultProps\n> {\n static displayName = 'Chart.Histogram';\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n locale: 'en',\n deltaPercentGrowthColor: 'success',\n } as const;\n\n get xScale() {\n const {\n xScale,\n marginY = 30,\n marginX = 30,\n invertAxis,\n data,\n groupKey,\n } = this.asProps;\n const { plotWidth, plotHeight } = this;\n\n if (xScale) {\n return xScale;\n }\n\n const testItem = data[0][groupKey];\n const range = invertAxis\n ? [plotHeight - marginX, this.plotPadding]\n : [marginY, plotWidth - this.plotPadding];\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n const domain = minMax(data, groupKey);\n\n return scaleTime(domain, range);\n }\n\n const domain = data.map((item) => item[groupKey]);\n\n return scaleBand(domain, range).paddingInner(0.05).paddingOuter(0.2);\n }\n\n get yScale(): ScaleLinear<any, any> {\n const {\n yScale,\n marginY = 30,\n marginX = 30,\n invertAxis,\n data,\n } = this.asProps;\n const { plotWidth, plotHeight } = this;\n\n let max: number;\n\n if (this.isStack) {\n max = data.reduce((max, item) => {\n const barSum = Object.values(item).reduce<number>((sum, val) => {\n if (val instanceof Date && !Number.isNaN(val.getMilliseconds())) {\n return sum + val.getMilliseconds();\n }\n\n return sum + (val as number);\n }, 0);\n\n if (barSum > max) {\n max = barSum;\n }\n\n return max;\n }, 0);\n } else {\n const flatValues = super.flatValues;\n\n max = Math.max(...flatValues);\n }\n\n return (\n yScale ??\n scaleLinear()\n .range(\n invertAxis\n ? [marginY, plotWidth - this.plotPadding]\n : [plotHeight - marginX, this.plotPadding],\n )\n .domain([0, max])\n );\n }\n\n get isStack(): boolean {\n const { dataDefinitions } = this.state;\n\n return dataDefinitions.length > 1;\n }\n\n renderChart() {\n const { groupKey, invertAxis } = this.asProps;\n const { dataDefinitions, highlightedItem } = this.state;\n\n if (this.isStack) {\n return (\n <StackBar x={invertAxis ? undefined : groupKey} y={invertAxis ? groupKey : undefined}>\n {dataDefinitions.map((item, index) => {\n const BarComponent = invertAxis ? StackBar.HorizontalBar : StackBar.Bar;\n\n const commonBarComponentProps: BarProps = {\n color: item.color,\n transparent: highlightedItem !== -1 && highlightedItem !== index,\n };\n\n if (invertAxis) {\n commonBarComponentProps.x = item.id;\n } else {\n commonBarComponentProps.y = item.id;\n }\n\n return item.checked && <BarComponent key={item.id} {...commonBarComponentProps} />;\n })}\n </StackBar>\n );\n }\n\n const item = dataDefinitions[0];\n\n return (\n item.checked && (\n <Bar\n x={invertAxis ? item.id : groupKey}\n y={invertAxis ? groupKey : item.id}\n key={item.id}\n color={item.color}\n />\n )\n );\n }\n\n renderTooltip(): React.ReactNode {\n const { data, groupKey, invertAxis, showXAxis } = this.asProps;\n\n return (\n <HoverRect.Tooltip\n x={invertAxis ? undefined : groupKey}\n y={invertAxis ? groupKey : undefined}\n wMin={100}\n hideTickHover={!showXAxis}\n >\n {({ xIndex, yIndex }: any) => {\n const index = invertAxis ? yIndex : xIndex;\n const dataItem = data[index];\n\n return {\n children: this.getTooltipChildren({\n Tooltip: HoverRect.Tooltip,\n dataItem,\n index,\n }),\n };\n }}\n </HoverRect.Tooltip>\n );\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Histogram' });\n }\n}\n\n/**\n * HistogramChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/histogram-chart/histogram-chart-api/|API}\n */\nexport const HistogramChart = createComponent<\n HistogramChartType,\n typeof HistogramChartComponent\n>(HistogramChartComponent);\n"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,SAAS,EAAEC,WAAW,EAAoBC,SAAS,QAAQ,UAAU;AAC9E,OAAOC,KAAK,MAAM,OAAO;;AAEzB;AACA,SAASC,GAAG,EAAEC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAuB,OAAO;AAEvE,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,iBAAiB,QAAQ,oDAAoD;AAEtF,MAAMC,uBAAuB,SAASF,aAAa,CAOjD;EAcA,IAAIG,MAAMA,CAAA,EAAG;IACX,MAAM;MACJA,MAAM;MACNC,OAAO,GAAG,EAAE;MACZC,OAAO,GAAG,EAAE;MACZC,UAAU;MACVC,IAAI;MACJC;IACF,CAAC,GAAG,IAAI,CAACC,OAAO;IAChB,MAAM;MAAEC,SAAS;MAAEC;IAAW,CAAC,GAAG,IAAI;IAEtC,IAAIR,MAAM,EAAE;MACV,OAAOA,MAAM;IACf;IAEA,MAAMS,QAAQ,GAAGL,IAAI,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC;IAClC,MAAMK,KAAK,GAAGP,UAAU,GACpB,CAACK,UAAU,GAAGN,OAAO,EAAE,IAAI,CAACS,WAAW,CAAC,GACxC,CAACV,OAAO,EAAEM,SAAS,GAAG,IAAI,CAACI,WAAW,CAAC;IAE3C,IAAIF,QAAQ,YAAYG,IAAI,IAAI,CAACC,MAAM,CAACC,KAAK,CAACL,QAAQ,CAACM,eAAe,CAAC,CAAC,CAAC,EAAE;MACzE,MAAMC,MAAM,GAAGtB,MAA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C1BK,QAAQ;UACRjB;QACF,CAAC;MACH,CAAC;IACH,CACiB,CAAC;EAExB;EAEUoB,kBAAkBA,CAAA,EAAW;IACrC,OAAO,IAAI,CAACvD,OAAO,CAACwD,WAAW,CAAC,gBAAgB,EAAE;MAAEC,SAAS,EAAE;IAAY,CAAC,CAAC;EAC/E;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJAC,eAAA,CAhLMjE,uBAAuB,iBAQN,iBAAiB;AAAAiE,eAAA,CARlCjE,uBAAuB,aAUV,CAACX,WAAW,CAACU,iBAAiB,CAAC,CAAC;AAAAkE,eAAA,CAV7CjE,uBAAuB,kBAYL;EACpBkE,SAAS,EAAE,QAAQ;EACnBb,SAAS,EAAE,IAAI;EACfc,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,IAAI;EACjBC,MAAM,EAAE,IAAI;EACZC,uBAAuB,EAAE;AAC3B,CAAC;AAkKH,OAAO,MAAMC,cAAc,GAAGnF,eAAe,CAG3CY,uBAAuB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistogramChart.type.js","names":[],"sources":["../../../../src/component/Chart/HistogramChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type HistogramChartData = Array<Record<string, number | Date>>;\n\nexport type HistogramChartProps = BaseChartProps<HistogramChartData> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Custom x-axis scale */\n xScale?: ScaleBand<any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n};\n\nexport type HistogramChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n};\n\nexport type HistogramChartType = Intergalactic.Component<typeof Flex, HistogramChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"HistogramChart.type.js","names":[],"sources":["../../../../src/component/Chart/HistogramChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type HistogramChartData = Array<Record<string, number | Date>>;\n\nexport type HistogramChartProps = BaseChartProps<HistogramChartData> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Custom x-axis scale */\n xScale?: ScaleBand<any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n};\n\nexport type HistogramChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n deltaPercentGrowthColor: 'success';\n};\n\nexport type HistogramChartType = Intergalactic.Component<typeof Flex, HistogramChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -3,11 +3,18 @@ import { createComponent } from '@semcore/core';
|
|
|
3
3
|
import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
4
4
|
import { scaleLinear, scaleTime } from 'd3-scale';
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { HIGHLIGHT_DOT } from './AbstractChart.type';
|
|
6
7
|
// @ts-ignore
|
|
7
8
|
import { Line, minMax, HoverLine } from '../..';
|
|
8
9
|
import { AbstractChart } from './AbstractChart';
|
|
9
10
|
import { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';
|
|
10
11
|
class LineChartComponent extends AbstractChart {
|
|
12
|
+
constructor(...args) {
|
|
13
|
+
super(...args);
|
|
14
|
+
_defineProperty(this, "displayDots", (i, isActive, noAround, data) => {
|
|
15
|
+
return isActive || noAround || Boolean(data[HIGHLIGHT_DOT]);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
11
18
|
get xScale() {
|
|
12
19
|
const {
|
|
13
20
|
xScale,
|
|
@@ -68,7 +75,7 @@ class LineChartComponent extends AbstractChart {
|
|
|
68
75
|
curve: curve,
|
|
69
76
|
onClick: onClickLine
|
|
70
77
|
}, /*#__PURE__*/React.createElement(Line.Dots, {
|
|
71
|
-
display: showDots
|
|
78
|
+
display: showDots || this.displayDots
|
|
72
79
|
}), area?.[item.id] && /*#__PURE__*/React.createElement(Line.Area, {
|
|
73
80
|
area: area[item.id],
|
|
74
81
|
y0: "y0",
|
|
@@ -80,11 +87,13 @@ class LineChartComponent extends AbstractChart {
|
|
|
80
87
|
renderTooltip() {
|
|
81
88
|
const {
|
|
82
89
|
data,
|
|
83
|
-
groupKey
|
|
90
|
+
groupKey,
|
|
91
|
+
showXAxis
|
|
84
92
|
} = this.asProps;
|
|
85
93
|
return /*#__PURE__*/React.createElement(HoverLine.Tooltip, {
|
|
86
94
|
x: groupKey,
|
|
87
|
-
wMin: 100
|
|
95
|
+
wMin: 100,
|
|
96
|
+
hideTickHover: !showXAxis
|
|
88
97
|
}, ({
|
|
89
98
|
xIndex
|
|
90
99
|
}) => {
|
|
@@ -117,7 +126,8 @@ _defineProperty(LineChartComponent, "defaultProps", {
|
|
|
117
126
|
showXAxis: true,
|
|
118
127
|
showYAxis: true,
|
|
119
128
|
showTooltip: true,
|
|
120
|
-
locale: 'en'
|
|
129
|
+
locale: 'en',
|
|
130
|
+
deltaPercentGrowthColor: 'success'
|
|
121
131
|
});
|
|
122
132
|
export const LineChart = createComponent(LineChartComponent);
|
|
123
133
|
//# sourceMappingURL=LineChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.js","names":["createComponent","i18nEnhance","scaleLinear","scaleTime","React","Line","minMax","HoverLine","AbstractChart","localizedMessages","LineChartComponent","
|
|
1
|
+
{"version":3,"file":"LineChart.js","names":["createComponent","i18nEnhance","scaleLinear","scaleTime","React","HIGHLIGHT_DOT","Line","minMax","HoverLine","AbstractChart","localizedMessages","LineChartComponent","constructor","args","_defineProperty","i","isActive","noAround","data","Boolean","xScale","marginY","groupKey","asProps","plotWidth","testItem","range","plotPadding","domain","Date","Number","isNaN","getMilliseconds","yScale","marginX","plotHeight","flatValues","max","Math","min","renderChart","curve","showDots","area","areaCurve","onClickLine","dataDefinitions","highlightedItem","state","map","item","index","checked","createElement","x","toString","y","id","key","color","transparent","onClick","Dots","display","displayDots","Area","y0","y1","renderTooltip","showXAxis","Tooltip","wMin","hideTickHover","xIndex","dataItem","children","getTooltipChildren","getLegendAriaLabel","getI18nText","chartType","direction","showYAxis","showTooltip","locale","deltaPercentGrowthColor","LineChart"],"sources":["../../../../src/component/Chart/LineChart.tsx"],"sourcesContent":["import { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { type ScaleLinear, scaleLinear, scaleTime } from 'd3-scale';\nimport React from 'react';\n\nimport type { ObjectData } from './AbstractChart.type';\nimport { HIGHLIGHT_DOT } from './AbstractChart.type';\nimport type { LineChartData, LineChartDefaultProps, LineChartProps, LineChartType } from './LineChart.type';\n// @ts-ignore\nimport { Line, minMax, HoverLine } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\n\nclass LineChartComponent extends AbstractChart<\n LineChartData,\n LineChartProps,\n typeof LineChartComponent.enhance,\n {},\n ChartState,\n LineChartDefaultProps\n> {\n static displayName = 'Chart.Line';\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n locale: 'en',\n deltaPercentGrowthColor: 'success',\n } as const;\n\n protected get xScale() {\n const { xScale, marginY = 30, data, groupKey } = this.asProps;\n const { plotWidth } = this;\n\n if (xScale) {\n return xScale;\n }\n\n const testItem = data[0][groupKey];\n const range = [marginY, plotWidth - this.plotPadding];\n const domain = minMax(data, groupKey);\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n return scaleTime(domain, range);\n }\n\n return scaleLinear(domain, range);\n }\n\n protected get yScale(): ScaleLinear<any, any> {\n const { yScale, marginX = 32 } = this.asProps;\n const { plotHeight } = this;\n\n if (yScale) {\n return yScale;\n }\n\n const flatValues = super.flatValues;\n\n const max = Math.max(...flatValues);\n const min = Math.min(...flatValues);\n\n return scaleLinear()\n .range([plotHeight - marginX, this.plotPadding])\n .domain([min, max]);\n }\n\n protected renderChart() {\n const { groupKey, curve, showDots, area, areaCurve, onClickLine } = this.asProps;\n const { dataDefinitions, highlightedItem } = this.state;\n\n return dataDefinitions.map((item, index) => {\n return (\n item.checked && (\n <Line\n x={groupKey.toString()}\n y={item.id}\n key={item.id}\n color={item.color}\n transparent={highlightedItem !== -1 && highlightedItem !== index}\n curve={curve}\n onClick={onClickLine}\n >\n <Line.Dots display={showDots || this.displayDots} />\n {area?.[item.id] && (\n <Line.Area area={area[item.id]} y0='y0' y1='y1' curve={areaCurve} />\n )}\n </Line>\n )\n );\n });\n }\n\n protected renderTooltip() {\n const { data, groupKey, showXAxis } = this.asProps;\n\n return (\n <HoverLine.Tooltip x={groupKey} wMin={100} hideTickHover={!showXAxis}>\n {({ xIndex }: any) => {\n const dataItem = data[xIndex];\n\n return {\n children: this.getTooltipChildren({\n Tooltip: HoverLine.Tooltip,\n dataItem,\n index: xIndex,\n }),\n };\n }}\n </HoverLine.Tooltip>\n );\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Line' });\n }\n\n protected displayDots = (i: number, isActive: boolean, noAround: boolean, data: ObjectData): boolean => {\n return isActive || noAround || Boolean(data[HIGHLIGHT_DOT]);\n };\n}\n\n/**\n * LineChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/line-chart/line-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/line-chart/line-chart-code/|Examples}\n */\nexport const LineChart = createComponent<\n LineChartType,\n typeof LineChartComponent\n>(LineChartComponent);\n"],"mappings":";AAAA,SAAS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ACS,iBAAiB,CAAC,CAAC;AAAAI,eAAA,CAV7CH,kBAAkB,kBAYA;EACpBqE,SAAS,EAAE,QAAQ;EACnBX,SAAS,EAAE,IAAI;EACfY,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,IAAI;EACjBC,MAAM,EAAE,IAAI;EACZC,uBAAuB,EAAE;AAC3B,CAAC;AAmGH,OAAO,MAAMC,SAAS,GAAGrF,eAAe,CAGtCW,kBAAkB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.type.js","names":[],"sources":["../../../../src/component/Chart/LineChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear, ScaleTime } from 'd3-scale';\nimport type { CurveFactory } from 'd3-shape';\n\nimport type { BaseChartProps } from './AbstractChart.type';\nimport type { interpolateValue } from '../../utils';\nimport type { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\n\ntype AreaItem = {\n x: number;\n y0: number;\n y1: number;\n};\n\nexport type LineChartData = Array<Record<string, string | number | typeof interpolateValue | Date>>;\n\nexport type LineChartProps = BaseChartProps<LineChartData> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Optional area data for rendering filled areas under lines */\n area?: Record<LegendItemKey, AreaItem[]>;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Controls whether to display dots on the line chart */\n showDots?: boolean;\n /** D3 curve factory for line interpolation */\n curve?: CurveFactory;\n /** Curve factory specifically for area rendering */\n areaCurve?: CurveFactory;\n /** Callback triggered when a user clicks on a line */\n onClickLine?: (index: number, event: React.SyntheticEvent) => void;\n};\n\nexport type LineChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n};\n\nexport type LineChartType = Intergalactic.Component<typeof Flex, LineChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LineChart.type.js","names":[],"sources":["../../../../src/component/Chart/LineChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear, ScaleTime } from 'd3-scale';\nimport type { CurveFactory } from 'd3-shape';\n\nimport type { BaseChartProps } from './AbstractChart.type';\nimport type { interpolateValue } from '../../utils';\nimport type { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\n\ntype AreaItem = {\n x: number;\n y0: number;\n y1: number;\n};\n\nexport type LineChartData = Array<Record<string, string | number | typeof interpolateValue | Date>>;\n\nexport type LineChartProps = BaseChartProps<LineChartData> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Optional area data for rendering filled areas under lines */\n area?: Record<LegendItemKey, AreaItem[]>;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Controls whether to display dots on the line chart */\n showDots?: boolean;\n /** D3 curve factory for line interpolation */\n curve?: CurveFactory;\n /** Curve factory specifically for area rendering */\n areaCurve?: CurveFactory;\n /** Callback triggered when a user clicks on a line */\n onClickLine?: (index: number, event: React.SyntheticEvent) => void;\n};\n\nexport type LineChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n deltaPercentGrowthColor: 'success';\n};\n\nexport type LineChartType = Intergalactic.Component<typeof Flex, LineChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadarChart.type.js","names":[],"sources":["../../../../src/component/Chart/RadarChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type RadarChartData = Record<string, string[] | number[]>;\n\nexport type RadarChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<RadarChartData>,\n 'showTotalInTooltip'
|
|
1
|
+
{"version":3,"file":"RadarChart.type.js","names":[],"sources":["../../../../src/component/Chart/RadarChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type RadarChartData = Record<string, string[] | number[]>;\n\nexport type RadarChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<RadarChartData>,\n | 'showTotalInTooltip'\n | 'showPercentValueInTooltip'\n | 'showDeltaPercentInTooltip'\n | 'getPercentDelta'\n | 'deltaPercentGrowthColor'\n> & {\n groupKey: string;\n scale?: ScaleLinear<any, any>;\n xScale?: never;\n yScale?: never;\n showDots?: boolean;\n circle?: boolean;\n /** Callback triggered when a user clicks on a chart at a position corresponding to a category */\n onClickRadar?: (index: number, e: React.SyntheticEvent) => void;\n};\n\nexport type RadarChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n};\n\nexport type RadarChartType = Intergalactic.Component<typeof Flex, RadarChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScatterPlotChart.type.js","names":[],"sources":["../../../../src/component/Chart/ScatterPlotChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear, ScaleTime } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\nimport type { interpolateValue } from '../../utils';\n\nexport type ScatterPlotChartData = Array<Record<string, number | typeof interpolateValue | Date>>;\n\nexport type ScatterPlotChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<ScatterPlotChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta'\n> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Optional field name for additional value data */\n valueKey?: string;\n /** Callback triggered when a user clicks on a scatter item */\n onClickScatterItem?: (index: number, event: React.SyntheticEvent) => void;\n};\n\nexport type ScatterPlotChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n showLegend: false;\n locale: 'en';\n};\n\nexport type ScatterPlotChartType = Intergalactic.Component<typeof Flex, ScatterPlotChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ScatterPlotChart.type.js","names":[],"sources":["../../../../src/component/Chart/ScatterPlotChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear, ScaleTime } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\nimport type { interpolateValue } from '../../utils';\n\nexport type ScatterPlotChartData = Array<Record<string, number | typeof interpolateValue | Date>>;\n\nexport type ScatterPlotChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<ScatterPlotChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta' | 'deltaPercentGrowthColor'\n> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Optional field name for additional value data */\n valueKey?: string;\n /** Callback triggered when a user clicks on a scatter item */\n onClickScatterItem?: (index: number, event: React.SyntheticEvent) => void;\n};\n\nexport type ScatterPlotChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n showLegend: false;\n locale: 'en';\n};\n\nexport type ScatterPlotChartType = Intergalactic.Component<typeof Flex, ScatterPlotChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VennChart.type.js","names":[],"sources":["../../../../src/component/Chart/VennChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type DataKey = string;\n\nexport type VennChartData = Record<DataKey, number>;\n\nexport type VennChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<VennChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta'\n> & {\n /** Internal */\n groupKey?: never;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Callback triggered when a user clicks on a circle */\n onClickVennItem?: (key: DataKey, e: React.SyntheticEvent) => void;\n};\n\nexport type VennChartDefaultProps = {\n direction: 'row-reverse';\n alignItems: 'flex-start';\n marginY: 0;\n marginX: 0;\n locale: 'en';\n};\n\nexport type VennChartType = Intergalactic.Component<typeof Flex, VennChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"VennChart.type.js","names":[],"sources":["../../../../src/component/Chart/VennChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type DataKey = string;\n\nexport type VennChartData = Record<DataKey, number>;\n\nexport type VennChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<VennChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta' | 'deltaPercentGrowthColor'\n> & {\n /** Internal */\n groupKey?: never;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Callback triggered when a user clicks on a circle */\n onClickVennItem?: (key: DataKey, e: React.SyntheticEvent) => void;\n};\n\nexport type VennChartDefaultProps = {\n direction: 'row-reverse';\n alignItems: 'flex-start';\n marginY: 0;\n marginX: 0;\n locale: 'en';\n};\n\nexport type VennChartType = Intergalactic.Component<typeof Flex, VennChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GOOD, BAD, INSIGHTFUL, HIGHLIGHT_DOT, DATA_TYPE, POTENTIAL, FORECAST } from './AbstractChart.type';
|
|
1
2
|
import { AreaChart } from './AreaChart';
|
|
2
3
|
import { BarChart } from './BarChart';
|
|
3
4
|
import { BubbleChart } from './BubbleChart';
|
|
@@ -22,4 +23,5 @@ export default {
|
|
|
22
23
|
Cigarette: CigaretteChart,
|
|
23
24
|
CompactHorizontalBar: CompactHorizontalBarChart
|
|
24
25
|
};
|
|
26
|
+
export { GOOD, BAD, INSIGHTFUL, HIGHLIGHT_DOT, DATA_TYPE, FORECAST, POTENTIAL };
|
|
25
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["AreaChart","BarChart","BubbleChart","CigaretteChart","CompactHorizontalBarChart","DonutChart","HistogramChart","LineChart","RadarChart","ScatterPlotChart","VennChart","Line","Bar","Histogram","ScatterPlot","Area","Bubble","Donut","Venn","Radar","Cigarette","CompactHorizontalBar"],"sources":["../../../../src/component/Chart/index.ts"],"sourcesContent":["import { AreaChart } from './AreaChart';\nimport { BarChart } from './BarChart';\nimport { BubbleChart } from './BubbleChart';\nimport { CigaretteChart } from './CigaretteChart';\nimport { CompactHorizontalBarChart } from './CompactHorizontalBarChart';\nimport { DonutChart } from './DonutChart';\nimport { HistogramChart } from './HistogramChart';\nimport { LineChart } from './LineChart';\nimport { RadarChart } from './RadarChart';\nimport { ScatterPlotChart } from './ScatterPlotChart';\nimport { VennChart } from './VennChart';\n\nexport default {\n Line: LineChart,\n Bar: BarChart,\n Histogram: HistogramChart,\n ScatterPlot: ScatterPlotChart,\n Area: AreaChart,\n Bubble: BubbleChart,\n Donut: DonutChart,\n Venn: VennChart,\n Radar: RadarChart,\n Cigarette: CigaretteChart,\n CompactHorizontalBar: CompactHorizontalBarChart,\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;AACvC,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,QAAQ,aAAa;AAEvC,eAAe;EACbC,IAAI,EAAEJ,SAAS;EACfK,GAAG,EAAEX,QAAQ;EACbY,SAAS,EAAEP,cAAc;EACzBQ,WAAW,EAAEL,gBAAgB;EAC7BM,IAAI,EAAEf,SAAS;EACfgB,MAAM,EAAEd,WAAW;EACnBe,KAAK,EAAEZ,UAAU;EACjBa,IAAI,EAAER,SAAS;EACfS,KAAK,EAAEX,UAAU;EACjBY,SAAS,EAAEjB,cAAc;EACzBkB,oBAAoB,EAAEjB;AACxB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["GOOD","BAD","INSIGHTFUL","HIGHLIGHT_DOT","DATA_TYPE","POTENTIAL","FORECAST","AreaChart","BarChart","BubbleChart","CigaretteChart","CompactHorizontalBarChart","DonutChart","HistogramChart","LineChart","RadarChart","ScatterPlotChart","VennChart","Line","Bar","Histogram","ScatterPlot","Area","Bubble","Donut","Venn","Radar","Cigarette","CompactHorizontalBar"],"sources":["../../../../src/component/Chart/index.ts"],"sourcesContent":["import { GOOD, BAD, INSIGHTFUL, HIGHLIGHT_DOT, DATA_TYPE, POTENTIAL, FORECAST } from './AbstractChart.type';\nimport { AreaChart } from './AreaChart';\nimport { BarChart } from './BarChart';\nimport { BubbleChart } from './BubbleChart';\nimport { CigaretteChart } from './CigaretteChart';\nimport { CompactHorizontalBarChart } from './CompactHorizontalBarChart';\nimport { DonutChart } from './DonutChart';\nimport { HistogramChart } from './HistogramChart';\nimport { LineChart } from './LineChart';\nimport { RadarChart } from './RadarChart';\nimport { ScatterPlotChart } from './ScatterPlotChart';\nimport { VennChart } from './VennChart';\n\nexport default {\n Line: LineChart,\n Bar: BarChart,\n Histogram: HistogramChart,\n ScatterPlot: ScatterPlotChart,\n Area: AreaChart,\n Bubble: BubbleChart,\n Donut: DonutChart,\n Venn: VennChart,\n Radar: RadarChart,\n Cigarette: CigaretteChart,\n CompactHorizontalBar: CompactHorizontalBarChart,\n};\n\nexport {\n GOOD,\n BAD,\n INSIGHTFUL,\n HIGHLIGHT_DOT,\n DATA_TYPE,\n FORECAST,\n POTENTIAL,\n};\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,GAAG,EAAEC,UAAU,EAAEC,aAAa,EAAEC,SAAS,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,sBAAsB;AAC3G,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,QAAQ,aAAa;AAEvC,eAAe;EACbC,IAAI,EAAEJ,SAAS;EACfK,GAAG,EAAEX,QAAQ;EACbY,SAAS,EAAEP,cAAc;EACzBQ,WAAW,EAAEL,gBAAgB;EAC7BM,IAAI,EAAEf,SAAS;EACfgB,MAAM,EAAEd,WAAW;EACnBe,KAAK,EAAEZ,UAAU;EACjBa,IAAI,EAAER,SAAS;EACfS,KAAK,EAAEX,UAAU;EACjBY,SAAS,EAAEjB,cAAc;EACzBkB,oBAAoB,EAAEjB;AACxB,CAAC;AAED,SACEX,IAAI,EACJC,GAAG,EACHC,UAAU,EACVC,aAAa,EACbC,SAAS,EACTE,QAAQ,EACRD,SAAS","ignoreList":[]}
|
|
@@ -8,12 +8,12 @@ import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
|
8
8
|
import Divider from '@semcore/divider';
|
|
9
9
|
import React from 'react';
|
|
10
10
|
/*!__reshadow-styles__:"./legend-flex.shadow.css"*/
|
|
11
|
-
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
11
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SLegendFlex_8xxmp_gg_._direction_row_8xxmp_gg_{align-items:flex-start;align-content:flex-start;flex-wrap:wrap;gap:var(--intergalactic-spacing-2x,8px) var(--intergalactic-spacing-4x,16px)}.___SLegendFlex_8xxmp_gg_._direction_column_8xxmp_gg_{align-items:flex-start;flex-wrap:wrap;gap:var(--intergalactic-spacing-2x,8px)}", /*__inner_css_end__*/"8xxmp_gg_"),
|
|
12
12
|
/*__reshadow_css_end__*/
|
|
13
13
|
{
|
|
14
|
-
"__SLegendFlex": "
|
|
15
|
-
"_direction_row": "
|
|
16
|
-
"_direction_column": "
|
|
14
|
+
"__SLegendFlex": "___SLegendFlex_8xxmp_gg_",
|
|
15
|
+
"_direction_row": "_direction_row_8xxmp_gg_",
|
|
16
|
+
"_direction_column": "_direction_column_8xxmp_gg_"
|
|
17
17
|
});
|
|
18
18
|
import { localizedMessages } from '../../../translations/__intergalactic-dynamic-locales';
|
|
19
19
|
import { BaseLegend } from '../BaseLegend';
|