You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "hk-the-analyst (via GitHub)" <gi...@apache.org> on 2024/06/18 06:03:26 UTC

[I] Blank Charts while loading dashboard [superset]

hk-the-analyst opened a new issue, #29283:
URL: https://github.com/apache/superset/issues/29283

   ### Bug description
   
   When we are loading dashboards with multiple charts blank charts are shown at first which will show values only when forced refresh or on right-clicking the chart.
   ![image](https://github.com/apache/superset/assets/123436992/ed07e4b5-be06-4bf6-b967-9e1b2f591b73)
   
   
   
   
   
   ### How to reproduce the bug
   
   Create a dashboard with multiple charts under multiple tabs
   Open the dashboard 
   Many charts will be blank the first time we are loading the chart
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
   - [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
   - [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Blank Charts while loading dashboard [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #29283: Blank Charts while loading dashboard
URL: https://github.com/apache/superset/issues/29283


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Blank Charts while loading dashboard [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #29283:
URL: https://github.com/apache/superset/issues/29283#issuecomment-2175130870

   <!-- Greeting -->
   Hey @hk-the-analyst! 👋 I'm here to help you with this bug. I'm a bot that can assist you with solving bugs, answering questions, and becoming a contributor.
   
   <!-- Answer -->
   To address the issue where dashboards with multiple charts initially display blank charts that only show values after a forced refresh or right-clicking on the chart, you can follow these steps:
   
   1. **Ensure Proper Resizing and Rendering**:
      - Call the `resize` method when the `Chart` component is first mounted and when it becomes visible.
   
   Here is an example of how you can update the `Chart` component:
   
   ```jsx
   class Chart extends React.Component {
     constructor(props) {
       super(props);
       this.state = {
         width: props.width,
         height: props.height,
         descriptionHeight: 0,
       };
   
       this.resize = debounce(this.resize.bind(this), RESIZE_TIMEOUT);
     }
   
     componentDidMount() {
       if (this.props.isExpanded) {
         const descriptionHeight = this.getDescriptionHeight();
         this.setState({ descriptionHeight });
       }
       this.resize(); // Ensure resize is called when the component is first mounted
     }
   
     componentDidUpdate(prevProps) {
       if (this.props.isExpanded !== prevProps.isExpanded) {
         const descriptionHeight = this.getDescriptionHeight();
         this.setState({ descriptionHeight });
       }
       if (this.props.isComponentVisible && !prevProps.isComponentVisible) {
         this.resize(); // Ensure resize is called when the component becomes visible
       }
     }
   
     // ... rest of the code remains unchanged
   }
   ```
   
   2. **Refresh Charts Properly**:
      - Use the `refreshCharts` function from the `dashboardState.js` file to ensure that charts are refreshed properly.
   
   Here is an example of how to use the `refreshCharts` function:
   
   ```js
   const refreshCharts = (chartList, force, interval, dashboardId, dispatch) =>
     new Promise(resolve => {
       dispatch(fetchCharts(chartList, force, interval, dashboardId));
       resolve();
     });
   
   export const ON_REFRESH = 'ON_REFRESH';
   export function onRefresh(
     chartList = [],
     force = false,
     interval = 0,
     dashboardId,
   ) {
     return dispatch => {
       dispatch({ type: ON_REFRESH });
       refreshCharts(chartList, force, interval, dashboardId, dispatch).then(
         () => {
           dispatch(onRefreshSuccess());
           dispatch(onFiltersRefresh());
         },
       );
     };
   }
   ```
   
   3. **Ensure Proper Chart Status Handling**:
      - Make sure the `chartReducer` handles various chart actions correctly, including updates and rendering.
   
   Here is an example of how the `chartReducer` handles chart actions:
   
   ```ts
   export default function chartReducer(
     charts: Record<string, ChartState> = {},
     action: AnyChartAction,
   ) {
     const actionHandlers: Record<string, ChartActionHandler> = {
       [actions.ADD_CHART]() {
         return {
           ...chart,
           ...action.chart,
         };
       },
       [actions.CHART_UPDATE_SUCCEEDED](state) {
         return {
           ...state,
           chartStatus: 'success',
           chartAlert: null,
           queriesResponse: action.queriesResponse,
           chartUpdateEndTime: now(),
         };
       },
       // ... other action handlers
     };
   
     if (action.type in actionHandlers) {
       return {
         ...charts,
         [action.key]: actionHandlers[action.type](charts[action.key]),
       };
     }
   
     return charts;
   }
   ```
   
   By implementing these changes, you can ensure that charts are properly rendered and refreshed, addressing the issue of initially blank charts <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/actions/dashboardState.js)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/superset-frontend/src/components/Chart/chartReducer.ts)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Blank Charts while loading dashboard [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #29283:
URL: https://github.com/apache/superset/issues/29283#issuecomment-2765063409

   We're no longer supporting 3.x, and this has been silent for a long time. Closing this, but if it's still happening somehow in 4.1.1, please add some updated context, and we can reopen/revisit.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org