@cdc/chart 4.23.7 → 4.23.9
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/dist/cdcchart.js +28341 -27278
- package/examples/feature/__data__/area-chart-date-apple.json +5122 -0
- package/examples/feature/__data__/city-temperature.json +2198 -0
- package/examples/feature/area/area-chart-category.json +45 -45
- package/examples/feature/area/area-chart-date-apple.json +10376 -0
- package/examples/feature/area/area-chart-date-city-temperature.json +4528 -0
- package/examples/feature/area/area-chart-date.json +111 -3
- package/examples/feature/forest-plot/broken.json +700 -0
- package/examples/feature/forest-plot/data.csv +24 -0
- package/examples/feature/forest-plot/forest-plot.json +717 -0
- package/examples/feature/pie/planet-pie-example-config.json +1 -1
- package/index.html +28 -8
- package/package.json +4 -3
- package/src/CdcChart.jsx +24 -14
- package/src/components/AreaChart.jsx +84 -59
- package/src/components/BarChart.Horizontal.jsx +251 -0
- package/src/components/BarChart.StackedHorizontal.jsx +118 -0
- package/src/components/BarChart.StackedVertical.jsx +95 -0
- package/src/components/BarChart.Vertical.jsx +204 -0
- package/src/components/BarChart.jsx +14 -674
- package/src/components/BarChartType.jsx +15 -0
- package/src/components/BrushHandle.jsx +17 -0
- package/src/components/DataTable.jsx +185 -23
- package/src/components/EditorPanel.jsx +361 -305
- package/src/components/ForestPlot.jsx +191 -0
- package/src/components/ForestPlotSettings.jsx +508 -0
- package/src/components/Legend.jsx +11 -3
- package/src/components/LineChart.jsx +2 -2
- package/src/components/LinearChart.jsx +115 -310
- package/src/data/initial-state.js +47 -1
- package/src/hooks/useBarChart.js +186 -0
- package/src/hooks/useEditorPermissions.js +218 -0
- package/src/hooks/useLegendClasses.js +14 -11
- package/src/hooks/useMinMax.js +15 -3
- package/src/hooks/useReduceData.js +2 -2
- package/src/hooks/useScales.js +46 -3
- package/src/hooks/useTooltip.jsx +407 -0
- package/src/scss/legend.scss +206 -0
- package/src/scss/main.scss +26 -12
|
@@ -6,6 +6,7 @@ import LegendCircle from '@cdc/core/components/LegendCircle'
|
|
|
6
6
|
|
|
7
7
|
import useLegendClasses from './../hooks/useLegendClasses'
|
|
8
8
|
import { useHighlightedBars } from '../hooks/useHighlightedBars'
|
|
9
|
+
import { Line } from '@visx/shape'
|
|
9
10
|
|
|
10
11
|
// * FILE REVIEW *
|
|
11
12
|
// TODO: fix eslint-disable jsxa11y issues
|
|
@@ -28,7 +29,8 @@ const Legend = () => {
|
|
|
28
29
|
highlightReset,
|
|
29
30
|
transformedData: data,
|
|
30
31
|
colorPalettes,
|
|
31
|
-
currentViewport
|
|
32
|
+
currentViewport,
|
|
33
|
+
handleLineType
|
|
32
34
|
} = useContext(ConfigContext)
|
|
33
35
|
|
|
34
36
|
const { innerClasses, containerClasses } = useLegendClasses(config)
|
|
@@ -165,7 +167,6 @@ const Legend = () => {
|
|
|
165
167
|
const { HighLightedBarUtils } = useHighlightedBars(config)
|
|
166
168
|
|
|
167
169
|
let highLightedLegendItems = HighLightedBarUtils.findDuplicates(config.highlightedBarValues)
|
|
168
|
-
|
|
169
170
|
if (!legend) return null
|
|
170
171
|
|
|
171
172
|
return (
|
|
@@ -213,7 +214,14 @@ const Legend = () => {
|
|
|
213
214
|
highlight(label)
|
|
214
215
|
}}
|
|
215
216
|
>
|
|
216
|
-
|
|
217
|
+
{config.visualizationType === 'Line' && config.legend.lineMode ? (
|
|
218
|
+
<svg width={40} height={20}>
|
|
219
|
+
<Line from={{ x: 10, y: 10 }} to={{ x: 40, y: 10 }} stroke={label.value} strokeWidth={2} strokeDasharray={handleLineType(config.series[i]?.type ? config.series[i]?.type : '')} />
|
|
220
|
+
</svg>
|
|
221
|
+
) : (
|
|
222
|
+
<LegendCircle fill={label.value} />
|
|
223
|
+
)}
|
|
224
|
+
|
|
217
225
|
<LegendLabel align='left' margin='0 0 0 4px'>
|
|
218
226
|
{label.text}
|
|
219
227
|
</LegendLabel>
|
|
@@ -12,7 +12,7 @@ import useRightAxis from '../hooks/useRightAxis'
|
|
|
12
12
|
const LineChart = ({ xScale, yScale, getXAxisData, getYAxisData, xMax, yMax, handleTooltipMouseOver, handleTooltipMouseOff, showTooltip, seriesStyle = 'Line', svgRef, handleTooltipClick, tooltipData }) => {
|
|
13
13
|
// Not sure why there's a redraw here.
|
|
14
14
|
|
|
15
|
-
const { colorPalettes, transformedData: data, colorScale, seriesHighlight, config, formatNumber, formatDate, parseDate, isNumber, updateConfig, handleLineType, dashboardConfig } = useContext(ConfigContext)
|
|
15
|
+
const { colorPalettes, transformedData: data, colorScale, seriesHighlight, config, formatNumber, formatDate, parseDate, isNumber, updateConfig, handleLineType, dashboardConfig, tableData } = useContext(ConfigContext)
|
|
16
16
|
const { yScaleRight } = useRightAxis({ config, yMax, data, updateConfig })
|
|
17
17
|
|
|
18
18
|
if (!handleTooltipMouseOver) return
|
|
@@ -77,7 +77,7 @@ const LineChart = ({ xScale, yScale, getXAxisData, getYAxisData, xMax, yMax, han
|
|
|
77
77
|
isNumber(d[seriesKey]) && (
|
|
78
78
|
<Group key={`series-${seriesKey}-point-${dataIndex}`} className='checkwidth'>
|
|
79
79
|
{/* tooltips */}
|
|
80
|
-
<Bar key={'bars'} width={Number(xMax)} height={Number(yMax)} fill={DEBUG ? 'red' : 'transparent'} fillOpacity={0.05} onMouseMove={e => handleTooltipMouseOver(e,
|
|
80
|
+
<Bar key={'bars'} width={Number(xMax)} height={Number(yMax)} fill={DEBUG ? 'red' : 'transparent'} fillOpacity={0.05} onMouseMove={e => handleTooltipMouseOver(e, tableData)} onMouseOut={handleTooltipMouseOff} onClick={e => handleTooltipClick(e, data)} />
|
|
81
81
|
|
|
82
82
|
{/* Render legend */}
|
|
83
83
|
<Text display={config.labels ? 'block' : 'none'} x={xScale(getXAxisData(d))} y={seriesAxis === 'Right' ? yScaleRight(getYAxisData(d, seriesKey)) : yScale(getYAxisData(d, seriesKey))} fill={'#000'} textAnchor='middle'>
|