@cdc/chart 4.24.3 → 4.24.4

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/index.html CHANGED
@@ -5,16 +5,17 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
6
6
  <style>
7
7
  body {
8
- /* max-width: 1000px; */
9
- margin: 0 auto !important;
10
- display: flex;
11
- flex-direction: column;
12
- justify-content: center;
8
+ margin: 0;
9
+ border-top: none !important;
13
10
  }
14
11
 
15
- .react-container + .react-container {
16
- margin-top: 3rem;
12
+ .cdc-map-outer-container {
13
+ min-height: 100vh;
17
14
  }
15
+
16
+ /* .react-container + .react-container {
17
+ margin-top: 3rem;
18
+ } */
18
19
  </style>
19
20
  <link rel="stylesheet prefetch" href="https://www.cdc.gov/TemplatePackage/contrib/libs/bootstrap/latest/css/bootstrap.min.css?_=39423" />
20
21
  <link rel="stylesheet prefetch" href="https://www.cdc.gov/TemplatePackage/4.0/assets/css/app.min.css?_=39423" />
@@ -45,6 +46,7 @@
45
46
  -->
46
47
 
47
48
  <!-- GENERIC CHART TYPES -->
49
+ <div class="react-container" data-config="/examples/test.json"></div>
48
50
  <!-- <div class="react-container" data-config="/examples/private/rvr.json"></div> -->
49
51
  <!-- <div class="react-container" data-config="/examples/feature/filters/url-filter.json"></div> -->
50
52
  <!-- <div class="react-container" data-config="/examples/feature/bar/additional-column-tooltip.json"></div> -->
@@ -56,7 +58,7 @@
56
58
  <!-- <div class="react-container" data-config="/examples/feature/forest-plot/forest-plot.json"></div> -->
57
59
  <!-- <div class="react-container" data-config="/examples/feature/pie/planet-pie-example-config.json"></div> -->
58
60
  <!-- <div class="react-container" data-config=https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/Line_Chart_Viz.json></div> -->
59
- <!-- <div class="react-container" data-config=/examples/feature/regions/index.json></div> -->
61
+ <div class="react-container" data-config=/examples/feature/regions/index.json></div>
60
62
  <!-- <div class="react-container" data-config=https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/Line_Chart_Regions_Viz.json></div> -->
61
63
  <!-- <div class="react-container" data-config=https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/Line_Chart_Regions_Viz.json></div> -->
62
64
  <!-- <div class="react-container" data-config="/examples/feature/forecasting/forecasting.json"></div> -->
@@ -69,12 +71,12 @@
69
71
  <!-- <div class="react-container" data-config="/examples/feature/boxplot/boxplot.json"></div> -->
70
72
  <!-- <div class="react-container" data-config="/examples/feature/combo/planet-combo-example-config.json"></div> -->
71
73
  <!-- <div class="react-container" data-config="/examples/feature/combo/right-issues.json"></div> -->
72
- <div class="react-container" data-config="/examples/region-issue.json"></div>
74
+ <!-- <div class="react-container" data-config="/examples/region-issue.json"></div> -->
73
75
 
74
76
  <!-- BAR -->
75
77
  <!-- <div class="react-container" data-config="/examples/feature/bar/planet-example-config.json"></div> -->
76
78
  <!-- <div class="react-container" data-config="/examples/feature/bar/planet-chart-horizontal-example-config.json"></div> -->
77
- <!-- <div class="react-container" data-config="/examples/feature/bar/example-bar-chart.json"></div> -->
79
+ <div class="react-container" data-config="/examples/feature/bar/example-bar-chart.json"></div>
78
80
  <!-- <div class="react-container" data-config="/examples/feature/bar/horizontal-chart-max-increase.json"></div> -->
79
81
  <!-- <div class="react-container" data-config="/examples/feature/bar/horizontal-chart.json"></div> -->
80
82
  <!-- <div class="react-container" data-config="/examples/feature/bar/horizontal-stacked-bar-chart.json"></div> -->
@@ -115,7 +117,7 @@
115
117
  <!-- <div class="react-container" data-config="/examples/feature/tests-non-numerics/example-bar-chart-nonnumeric.json"></div> -->
116
118
  <!-- <div class="react-container" data-config="/examples/sparkline.json"></div> -->
117
119
  <!-- <div class="react-container" data-config="/examples/feature/tests-non-numerics/sparkline-chart-nonnumeric.json"></div> -->
118
- <!-- <div class="react-container" data-config="/examples/feature/bar/lollipop.json"></div> -->
120
+ <div class="react-container" data-config="/examples/region-issue.json"></div>
119
121
  <!-- <div class="react-container" data-config="/examples/feature/tests-non-numerics/stacked-vertical-bar-example-nonnumerics.json"></div> -->
120
122
 
121
123
  <!-- TESTS CUTOFF -->
@@ -133,7 +135,7 @@
133
135
 
134
136
  <!-- GENERIC CHART TYPES -->
135
137
  <!-- <div class="react-container" data-config="/examples/gallery/paired-bar/paired-bar-chart.json"></div> -->
136
- <!-- <div class="react-container" data-config="/examples/feature/line/line-chart.json"></div> -->
138
+ <div class="react-container" data-config="/examples/feature/line/line-chart.json"></div>
137
139
 
138
140
  <!-- HORIZONTAL BAR CHARTS -->
139
141
  <!-- <div class="react-container" data-config="/examples/gallery/bar-chart-horizontal/horizontal-bar-chart-with-numbers-on-bar.json"></div> -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdc/chart",
3
- "version": "4.24.3",
3
+ "version": "4.24.4",
4
4
  "description": "React component for visualizing tabular data in various types of charts",
5
5
  "moduleName": "CdcChart",
6
6
  "main": "dist/cdcchart",
@@ -60,7 +60,7 @@
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0"
62
62
  },
63
- "gitHead": "9c7ef7ca74f2d2a1e04d923b133fe0fc557a62bf",
63
+ "gitHead": "1843b4632140d582af6a87606374cbd4fe25ad5c",
64
64
  "devDependencies": {
65
65
  "@types/d3-sankey": "^0.12.4",
66
66
  "resize-observer-polyfill": "^1.5.1"
package/src/CdcChart.tsx CHANGED
@@ -1,9 +1,11 @@
1
- import React, { useState, useEffect, useCallback, useRef } from 'react'
1
+ import React, { useState, useEffect, useCallback, useRef, useId } from 'react'
2
2
 
3
3
  // IE11
4
4
  import ResizeObserver from 'resize-observer-polyfill'
5
5
  import 'whatwg-fetch'
6
6
  import * as d3 from 'd3-array'
7
+ import Layout from '@cdc/core/components/Layout'
8
+ import Button from '@cdc/core/components/elements/Button'
7
9
 
8
10
  // External Libraries
9
11
  import { scaleOrdinal } from '@visx/scale'
@@ -94,8 +96,8 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
94
96
  if (config.table && (!config.table?.label || config.table?.label === '')) config.table.label = 'Data Table'
95
97
 
96
98
  const { barBorderClass, lineDatapointClass, contentClasses, sparkLineStyles } = useDataVizClasses(config)
97
-
98
- const handleChartTabbing = !config.legend?.hide ? `legend` : config?.title ? `dataTableSection__${config.title.replace(/\s/g, '')}` : `dataTableSection`
99
+ const legendId = useId()
100
+ const handleChartTabbing = !config.legend?.hide ? legendId : config?.title ? `dataTableSection__${config.title.replace(/\s/g, '')}` : `dataTableSection`
99
101
 
100
102
  const reloadURLData = async () => {
101
103
  if (config.dataUrl) {
@@ -443,7 +445,7 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
443
445
  if (series.type === 'Forecasting') {
444
446
  newConfig.runtime.forecastingSeriesKeys.push(series)
445
447
  }
446
- if (series.type === 'Bar') {
448
+ if (series.type === 'Bar' || series.type === 'Combo') {
447
449
  newConfig.runtime.barSeriesKeys.push(series.dataKey)
448
450
  }
449
451
  if (series.type === 'Line' || series.type === 'dashed-sm' || series.type === 'dashed-md' || series.type === 'dashed-lg') {
@@ -1008,6 +1010,63 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
1008
1010
  return formattedValue
1009
1011
  }
1010
1012
 
1013
+ const Confirm = () => {
1014
+ const confirmDone = e => {
1015
+ if (e) {
1016
+ e.preventDefault()
1017
+ }
1018
+
1019
+ let newConfig = { ...config }
1020
+ delete newConfig.newViz
1021
+
1022
+ updateConfig(newConfig)
1023
+ }
1024
+
1025
+ const styles = {
1026
+ position: 'relative',
1027
+ height: '100vh',
1028
+ width: '100%',
1029
+ display: 'flex',
1030
+ justifyContent: 'center',
1031
+ alignItems: 'center',
1032
+ gridArea: 'content'
1033
+ }
1034
+
1035
+ return (
1036
+ <section className='waiting' style={styles}>
1037
+ <section className='waiting-container'>
1038
+ <h3>Finish Configuring</h3>
1039
+ <p>Set all required options to the left and confirm below to display a preview of the chart.</p>
1040
+ <Button className='btn' style={{ margin: '1em auto' }} disabled={missingRequiredSections()} onClick={e => confirmDone(e)}>
1041
+ I'm Done
1042
+ </Button>
1043
+ </section>
1044
+ </section>
1045
+ )
1046
+ }
1047
+
1048
+ const Error = () => {
1049
+ const styles = {
1050
+ position: 'absolute',
1051
+ background: 'white',
1052
+ zIndex: '999',
1053
+ height: '100vh',
1054
+ width: '100%',
1055
+ display: 'flex',
1056
+ justifyContent: 'center',
1057
+ alignItems: 'center',
1058
+ gridArea: 'content'
1059
+ }
1060
+ return (
1061
+ <section className='waiting' style={styles}>
1062
+ <section className='waiting-container'>
1063
+ <h3>Error With Configuration</h3>
1064
+ <p>{config.runtime.editorErrorMessage}</p>
1065
+ </section>
1066
+ </section>
1067
+ )
1068
+ }
1069
+
1011
1070
  // this is passed DOWN into the various components
1012
1071
  // then they do a lookup based on the bin number as index into here (TT)
1013
1072
  const applyLegendToRow = rowObj => {
@@ -1042,6 +1101,17 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
1042
1101
  // Prevent render if loading
1043
1102
  let body = <Loading />
1044
1103
 
1104
+ const getChartWrapperClasses = () => {
1105
+ const classes = ['chart-container', 'p-relative']
1106
+ if (config.legend.position === 'bottom') classes.push('bottom')
1107
+ if (config.legend.hide) classes.push('legend-hidden')
1108
+ if (lineDatapointClass) classes.push(lineDatapointClass)
1109
+ if (!config.barHasBorder) classes.push('chart-bar--no-border')
1110
+ if (isDebug) classes.push('debug')
1111
+ classes.push(...contentClasses)
1112
+ return classes
1113
+ }
1114
+
1045
1115
  if (!loading) {
1046
1116
  const tableLink = (
1047
1117
  <a href={`#data-table-${config.dataKey}`} className='margin-left-href'>
@@ -1051,80 +1121,82 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
1051
1121
  body = (
1052
1122
  <>
1053
1123
  {isEditor && <EditorPanel />}
1054
- {!missingRequiredSections() && !config.newViz && (
1055
- <div className='cdc-chart-inner-container' aria-label={handleChartAriaLabels(config)} tabIndex={0}>
1056
- <Title showTitle={config.showTitle} isDashboard={isDashboard} title={title} superTitle={config.superTitle} classes={['chart-title', `${config.theme}`, 'cove-component__header']} style={undefined} />
1057
- <SkipTo skipId={handleChartTabbing} skipMessage='Skip Over Chart Container' />
1058
-
1059
- {/* Filters */}
1060
- {config.filters && !externalFilters && config.visualizationType !== 'Spark Line' && <Filters config={config} setConfig={setConfig} setFilteredData={setFilteredData} filteredData={filteredData} excludedData={excludedData} filterData={filterData} dimensions={dimensions} />}
1061
- {/* Visualization */}
1062
- {config?.introText && config.visualizationType !== 'Spark Line' && <section className='introText'>{parse(config.introText)}</section>}
1063
- <div
1064
- style={{ marginBottom: computeMarginBottom(config, legend, currentViewport) }}
1065
- className={`chart-container p-relative ${config.legend.position === 'bottom' ? 'bottom' : ''}${config.legend.hide ? ' legend-hidden' : ''}${lineDatapointClass}${barBorderClass} ${contentClasses.join(' ')} ${isDebug ? 'debug' : ''}`}
1066
- >
1067
- {/* All charts except sparkline */}
1068
- {config.visualizationType !== 'Spark Line' && chartComponents[config.visualizationType]}
1069
-
1070
- {/* Sparkline */}
1071
- {config.visualizationType === 'Spark Line' && (
1072
- <>
1073
- <Filters config={config} setConfig={setConfig} setFilteredData={setFilteredData} filteredData={filteredData} excludedData={excludedData} filterData={filterData} dimensions={dimensions} />
1074
- {config?.introText && (
1075
- <section className='introText' style={{ padding: '0px 0 35px' }}>
1076
- {parse(config.introText)}
1077
- </section>
1078
- )}
1079
- <div style={{ height: `100px`, width: `100%`, ...sparkLineStyles }}>
1080
- <ParentSize>{parent => <SparkLine width={parent.width} height={parent.height} />}</ParentSize>
1081
- </div>
1082
- {description && (
1083
- <div className='subtext' style={{ padding: '35px 0 15px' }}>
1084
- {parse(description)}
1124
+ <Layout.Responsive isEditor={isEditor}>
1125
+ {config.newViz && <Confirm />}
1126
+ {undefined === config.newViz && isEditor && config.runtime && config.runtime?.editorErrorMessage && <Error />}
1127
+ {!missingRequiredSections() && !config.newViz && (
1128
+ <div className='cdc-chart-inner-container cove-component__content' aria-label={handleChartAriaLabels(config)} tabIndex={0}>
1129
+ <Title showTitle={config.showTitle} isDashboard={isDashboard} title={title} superTitle={config.superTitle} classes={['chart-title', `${config.theme}`, 'cove-component__header']} style={undefined} />
1130
+
1131
+ {/* Filters */}
1132
+ {config.filters && !externalFilters && config.visualizationType !== 'Spark Line' && <Filters config={config} setConfig={setConfig} setFilteredData={setFilteredData} filteredData={filteredData} excludedData={excludedData} filterData={filterData} dimensions={dimensions} />}
1133
+ <SkipTo skipId={handleChartTabbing} skipMessage='Skip Over Chart Container' />
1134
+ {/* Visualization */}
1135
+ {config?.introText && config.visualizationType !== 'Spark Line' && <section className='introText'>{parse(config.introText)}</section>}
1136
+
1137
+ <div style={{ marginBottom: computeMarginBottom(config, legend, currentViewport) }} className={getChartWrapperClasses().join(' ')}>
1138
+ {/* All charts except sparkline */}
1139
+ {config.visualizationType !== 'Spark Line' && chartComponents[config.visualizationType]}
1140
+
1141
+ {/* Sparkline */}
1142
+ {config.visualizationType === 'Spark Line' && (
1143
+ <>
1144
+ <Filters config={config} setConfig={setConfig} setFilteredData={setFilteredData} filteredData={filteredData} excludedData={excludedData} filterData={filterData} dimensions={dimensions} />
1145
+ {config?.introText && (
1146
+ <section className='introText' style={{ padding: '0px 0 35px' }}>
1147
+ {parse(config.introText)}
1148
+ </section>
1149
+ )}
1150
+ <div style={{ height: `100px`, width: `100%`, ...sparkLineStyles }}>
1151
+ <ParentSize>{parent => <SparkLine width={parent.width} height={parent.height} />}</ParentSize>
1085
1152
  </div>
1086
- )}
1087
- </>
1153
+ {description && (
1154
+ <div className='subtext' style={{ padding: '35px 0 15px' }}>
1155
+ {parse(description)}
1156
+ </div>
1157
+ )}
1158
+ </>
1159
+ )}
1160
+ {/* Sankey */}
1161
+ {config.visualizationType === 'Sankey' && <ParentSize aria-hidden='true'>{parent => <SankeyChart runtime={config.runtime} width={parent.width} height={parent.height} />}</ParentSize>}
1162
+ {!config.legend.hide && config.visualizationType !== 'Spark Line' && config.visualizationType !== 'Sankey' && <Legend ref={legendRef} />}
1163
+ </div>
1164
+ {/* Link */}
1165
+ {isDashboard && config.table && config.table.show && config.table.showDataTableLink ? tableLink : link && link}
1166
+
1167
+ {/* Description */}
1168
+ {description && config.visualizationType !== 'Spark Line' && <div className={'column ' + config.isResponsiveTicks ? 'subtext--responsive-ticks' : 'subtext'}>{parse(description)}</div>}
1169
+
1170
+ {/* buttons */}
1171
+ <MediaControls.Section classes={['download-buttons']}>
1172
+ {config.table.showDownloadImgButton && <MediaControls.Button text='Download Image' title='Download Chart as Image' type='image' state={config} elementToCapture={imageId} />}
1173
+ {config.table.showDownloadPdfButton && <MediaControls.Button text='Download PDF' title='Download Chart as PDF' type='pdf' state={config} elementToCapture={imageId} />}
1174
+ </MediaControls.Section>
1175
+
1176
+ {/* Data Table */}
1177
+ {((config.xAxis.dataKey && config.table.show && config.visualizationType !== 'Spark Line' && config.visualizationType !== 'Sankey') || (config.visualizationType === 'Sankey' && config.table.show)) && (
1178
+ <DataTable
1179
+ config={config}
1180
+ rawData={config.visualizationType === 'Sankey' ? config?.data?.[0]?.tableData : config.table.customTableConfig ? filterData(config.filters, config.data) : config.data}
1181
+ runtimeData={config.visualizationType === 'Sankey' ? config?.data?.[0]?.tableData : transform.applySuppression(filteredData || excludedData, config.suppressedData)}
1182
+ expandDataTable={config.table.expanded}
1183
+ columns={config.columns}
1184
+ displayDataAsText={displayDataAsText}
1185
+ displayGeoName={displayGeoName}
1186
+ applyLegendToRow={applyLegendToRow}
1187
+ tableTitle={config.table.label}
1188
+ indexTitle={config.table.indexLabel}
1189
+ vizTitle={title}
1190
+ viewport={currentViewport}
1191
+ tabbingId={handleChartTabbing}
1192
+ colorScale={colorScale}
1193
+ />
1088
1194
  )}
1089
- {/* Sankey */}
1090
- {config.visualizationType === 'Sankey' && <ParentSize aria-hidden='true'>{parent => <SankeyChart runtime={config.runtime} width={parent.width} height={parent.height} />}</ParentSize>}
1091
- {!config.legend.hide && config.visualizationType !== 'Spark Line' && config.visualizationType !== 'Sankey' && <Legend ref={legendRef} />}
1195
+ {config?.footnotes && <section className='footnotes'>{parse(config.footnotes)}</section>}
1196
+ {/* show pdf or image button */}
1092
1197
  </div>
1093
- {/* Link */}
1094
- {isDashboard && config.table && config.table.show && config.table.showDataTableLink ? tableLink : link && link}
1095
-
1096
- {/* Description */}
1097
- {description && config.visualizationType !== 'Spark Line' && <div className={'column ' + config.isResponsiveTicks ? 'subtext--responsive-ticks' : 'subtext'}>{parse(description)}</div>}
1098
-
1099
- {/* buttons */}
1100
- <MediaControls.Section classes={['download-buttons']}>
1101
- {config.table.showDownloadImgButton && <MediaControls.Button text='Download Image' title='Download Chart as Image' type='image' state={config} elementToCapture={imageId} />}
1102
- {config.table.showDownloadPdfButton && <MediaControls.Button text='Download PDF' title='Download Chart as PDF' type='pdf' state={config} elementToCapture={imageId} />}
1103
- </MediaControls.Section>
1104
-
1105
- {/* Data Table */}
1106
- {((config.xAxis.dataKey && config.table.show && config.visualizationType !== 'Spark Line' && config.visualizationType !== 'Sankey') || (config.visualizationType === 'Sankey' && config.table.show)) && (
1107
- <DataTable
1108
- config={config}
1109
- rawData={config.visualizationType === 'Sankey' ? config?.data?.[0]?.tableData : config.table.customTableConfig ? filterData(config.filters, config.data) : config.data}
1110
- runtimeData={config.visualizationType === 'Sankey' ? config?.data?.[0]?.tableData : transform.applySuppression(filteredData || excludedData, config.suppressedData)}
1111
- expandDataTable={config.table.expanded}
1112
- columns={config.columns}
1113
- displayDataAsText={displayDataAsText}
1114
- displayGeoName={displayGeoName}
1115
- applyLegendToRow={applyLegendToRow}
1116
- tableTitle={config.table.label}
1117
- indexTitle={config.table.indexLabel}
1118
- vizTitle={title}
1119
- viewport={currentViewport}
1120
- tabbingId={handleChartTabbing}
1121
- colorScale={colorScale}
1122
- />
1123
- )}
1124
- {config?.footnotes && <section className='footnotes'>{parse(config.footnotes)}</section>}
1125
- {/* show pdf or image button */}
1126
- </div>
1127
- )}
1198
+ )}
1199
+ </Layout.Responsive>
1128
1200
  </>
1129
1201
  )
1130
1202
  }
@@ -1185,17 +1257,11 @@ export default function CdcChart({ configUrl, config: configObj, isEditor = fals
1185
1257
  debugSvg: isDebug
1186
1258
  }
1187
1259
 
1188
- const classes = ['cdc-open-viz-module', 'type-chart', `${currentViewport}`, `font-${config.fontSize}`, `${config.theme}`]
1189
-
1190
- config.visualizationType === 'Spark Line' && classes.push(`type-sparkline`)
1191
- isEditor && classes.push('spacing-wrapper')
1192
- isEditor && classes.push('isEditor')
1193
-
1194
1260
  return (
1195
1261
  <ConfigContext.Provider value={contextValues}>
1196
- <div className={`${classes.join(' ')}`} ref={outerContainerRef} data-lollipop={config.isLollipopChart} data-download-id={imageId}>
1262
+ <Layout.VisualizationWrapper config={config} isEditor={isEditor} currentViewport={currentViewport} ref={outerContainerRef} imageId={imageId} showEditorPanel={config?.showEditorPanel}>
1197
1263
  {body}
1198
- </div>
1264
+ </Layout.VisualizationWrapper>
1199
1265
  </ConfigContext.Provider>
1200
1266
  )
1201
1267
  }
@@ -78,6 +78,10 @@ export const BarChartHorizontal = () => {
78
78
  let transparentBar = config.legend.behavior === 'highlight' && seriesHighlight.length > 0 && seriesHighlight.indexOf(bar.key) === -1
79
79
  let displayBar = config.legend.behavior === 'highlight' || seriesHighlight.length === 0 || seriesHighlight.indexOf(bar.key) !== -1
80
80
  let barHeight = config.barHeight
81
+ let numbericBarHeight = parseInt(!config.isLollipopChart ? barHeight : lollipopBarWidth)
82
+ if (isNaN(numbericBarHeight)) {
83
+ numbericBarHeight = 25
84
+ }
81
85
  let barY = bar.value >= 0 && isNumber(bar.value) ? bar.y : yScale(scaleVal)
82
86
  const barXBase = bar.value < 0 ? Math.abs(xScale(bar.value)) : xScale(scaleVal)
83
87
  const barWidthHorizontal = Math.abs(xScale(bar.value) - xScale(scaleVal))
@@ -131,9 +135,9 @@ export const BarChartHorizontal = () => {
131
135
  barColor = assignColorsToValues(barGroups.length, barGroup.index, barColor) // Color code by category
132
136
  const isRegularLollipopColor = config.isLollipopChart && config.lollipopColorStyle === 'regular'
133
137
  const isTwoToneLollipopColor = config.isLollipopChart && config.lollipopColorStyle === 'two-tone'
134
- const isHighlightedBar = highlightedBarValues?.includes(yAxisValue)
135
- const highlightedBarColor = getHighlightedBarColorByValue(yAxisValue)
136
- const highlightedBar = getHighlightedBarByValue(yAxisValue)
138
+ const isHighlightedBar = highlightedBarValues?.includes(xAxisValue)
139
+ const highlightedBarColor = getHighlightedBarColorByValue(xAxisValue)
140
+ const highlightedBar = getHighlightedBarByValue(xAxisValue)
137
141
  const borderColor = isHighlightedBar ? highlightedBarColor : config.barHasBorder === 'true' ? '#000' : 'transparent'
138
142
  const borderWidth = isHighlightedBar ? highlightedBar.borderWidth : config.isLollipopChart ? 0 : config.barHasBorder === 'true' ? barBorderWidth : 0
139
143
  const displaylollipopShape = config.suppressedData.some(d => bar.key === d.column && bar.value === d.value) ? 'none' : 'block'
@@ -141,18 +145,7 @@ export const BarChartHorizontal = () => {
141
145
  if (barColor && labelColor && textFits) {
142
146
  labelColor = getContrastColor('#000', barColor)
143
147
  }
144
- const getTop = () => {
145
- if (Number(barHeight) < 20) return -4
146
- if (Number(barHeight) < 25) return -1
147
- if (Number(barHeight) < 30) return 2
148
- if (Number(barHeight) < 35) return 4
149
- if (Number(barHeight) < 40) return 5
150
- if (Number(barHeight) < 50) return 9
151
- if (Number(barHeight) < 60) return 10
152
- else {
153
- return 12
154
- }
155
- }
148
+
156
149
  const background = () => {
157
150
  if (isRegularLollipopColor) return barColor
158
151
  if (isTwoToneLollipopColor) return chroma(barColor).brighten(1)
@@ -172,7 +165,7 @@ export const BarChartHorizontal = () => {
172
165
  borderStyle: 'solid',
173
166
  borderWidth: `${borderWidth}px`,
174
167
  width: barWidth,
175
- height: !config.isLollipopChart ? barHeight : lollipopBarWidth,
168
+ height: numbericBarHeight,
176
169
  x: barX,
177
170
  y: barHeight * bar.index,
178
171
  onMouseOver: () => onMouseOverBar(xAxisValue, bar.key),
@@ -151,19 +151,19 @@ export const BarChartVertical = () => {
151
151
  * color the bar that is using the filter with barColor and
152
152
  * color the filteredOut (typically gray) bars with the filteredOutColor
153
153
  */
154
- if (dashboardConfig && dashboardConfig.dashboard.sharedFilters) {
154
+ if (dashboardConfig && dashboardConfig.dashboard.sharedFilters?.length !== 0) {
155
155
  const { sharedFilters } = dashboardConfig.dashboard
156
156
 
157
157
  _barColor = sharedFilters.map(_sharedFilter => {
158
158
  if (_sharedFilter.setBy === config.uid) {
159
159
  // If the current filter is the reset filter item.
160
- if (_sharedFilter.resetLabel === _sharedFilter.active) return barColor
160
+ if (_sharedFilter.resetLabel === _sharedFilter.active) return colorScale(config.runtime.seriesLabels[bar.key])
161
161
  // If the current filter is the bars
162
- if (_sharedFilter.active === transformedData[barGroup.index][config.xAxis.dataKey]) return barColor
162
+ if (_sharedFilter.active === transformedData[barGroup.index][config.xAxis.dataKey]) return colorScale(config.runtime.seriesLabels[bar.key])
163
163
  return _filteredOutColor
164
164
  } else {
165
165
  // If the setBy isn't the config.uid return the original barColor
166
- return barColor
166
+ return colorScale(config.runtime.seriesLabels[bar.key])
167
167
  }
168
168
  })[0]
169
169
 
@@ -188,7 +188,7 @@ export const BarChartVertical = () => {
188
188
  config: config,
189
189
  index: newIndex,
190
190
  id: `barGroup${barGroup.index}`,
191
- background: getBarBackgroundColor(barColor),
191
+ background: getBarBackgroundColor(colorScale(config.runtime.seriesLabels[bar.key])),
192
192
  borderColor,
193
193
  borderStyle: 'solid',
194
194
  borderWidth: `${borderWidth}px`,