Skip to content

Commit

Permalink
fix: charts rerender with zero-height during tab switch (apache#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud authored and zhaoyongjie committed Nov 25, 2021
1 parent 5ba155b commit e68b4ac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ const propTypes = {
const formatter = getNumberFormatter();

function WorldMap(element, props) {
const { data, height, maxBubbleSize, showBubbles } = props;
const { data, width, height, maxBubbleSize, showBubbles } = props;

const div = d3.select(element);
div.classed('superset-legacy-chart-world-map', true);

const container = element;
container.style.height = `${height}px`;
div.selectAll('*').remove();

// Ignore XXX's to get better normalization
Expand Down Expand Up @@ -76,6 +73,8 @@ function WorldMap(element, props) {

const map = new Datamap({
element,
width,
height,
data: processedData,
fills: {
defaultFill: '#eee',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* under the License.
*/
export default function transformProps(chartProps) {
const { height, formData, queryData } = chartProps;
const { width, height, formData, queryData } = chartProps;
const { maxBubbleSize, showBubbles } = formData;

return {
data: queryData.data,
width,
height,
maxBubbleSize: parseInt(maxBubbleSize, 10),
showBubbles,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ function StickyWrap({
if (theadRef.current) {
const bodyThead = theadRef.current;
const theadHeight = bodyThead.clientHeight;
if (!theadHeight) {
return;
}
const fullTableHeight = (bodyThead.parentNode as HTMLTableElement).clientHeight;
const ths = bodyThead.childNodes[0].childNodes as NodeListOf<HTMLTableHeaderCellElement>;
const widths = Array.from(ths).map(th => th.clientWidth);
Expand Down

0 comments on commit e68b4ac

Please sign in to comment.