GitHub user ypandey-fluidata created a discussion: Apache Superset 6.0.0: Big 
Number (Legacy) chart, how to override default “No data” empty-state messages 
when embedding charts

### Bug description

[BigNumberViz.tsx](https://github.com/user-attachments/files/24611197/BigNumberViz.tsx)

Current Behavior
-For the Big Number legacy chart, the following messages are rendered by 
default when no data is available:

Header value
-"No data"

Subtitle (no fallback value)
-"No data after filtering or data is NULL for the latest time record"

Subtitle (fallback exists)
-"Try applying different filters or ensuring your datasource has data"

These strings are defined directly in:
-superset-frontend/src/visualizations/BigNumber/BigNumberViz.tsx

# What I need support with?
I have shared the updated tsx but i need help with how can I implement this 
change on my custom superset image--

  const renderHeader = (maxHeight: number) => {
    const { bigNumber, width, colorThresholdFormatters, onContextMenu } = props;
    // @ts-ignore
    const text = bigNumber === null ? t('N/A') : headerFormatter(bigNumber);

    const hasThresholdColorFormatter =
      Array.isArray(colorThresholdFormatters) &&
      colorThresholdFormatters.length > 0;

    let numberColor;
    if (hasThresholdColorFormatter) {
      colorThresholdFormatters!.forEach(formatter => {
        const formatterResult = bigNumber
          ? formatter.getColorFromValue(bigNumber as number)
          : false;
        if (formatterResult) {
          numberColor = formatterResult;
        }
      });
    } else {
      numberColor = theme.colorText;
    }

    const container = createTemporaryContainer();
    document.body.append(container);
    const fontSize = computeMaxFontSize({
      text,
      maxWidth: width * 0.9, // reduced it's max width
      maxHeight,
      className: 'header-line',
      container,
    });
    container.remove();

    const handleContextMenu = (e: MouseEvent<HTMLDivElement>) => {
      if (onContextMenu) {
        e.preventDefault();
        onContextMenu(e.nativeEvent.clientX, e.nativeEvent.clientY);
      }
    };

    return (
      <div
        ref={headerRef}
        className="header-line"
        style={{
          display: 'flex',
          alignItems: 'center',
          fontSize,
          height: 'auto',
          color: numberColor,
        }}
        onContextMenu={handleContextMenu}
      >
        {text}
      </div>
    );
  };

  const rendermetricComparisonSummary = (maxHeight: number) => {
    const { width } = props;
    let fontSize = 0;

    const text = subheader;

    if (text) {
      const container = createTemporaryContainer();
      document.body.append(container);
      try {
        fontSize = computeMaxFontSize({
          text,
          maxWidth: width * 0.9,
          maxHeight,
          className: 'subheader-line',
          container,
        });
      } finally {
        container.remove();
      }

      return (
        <div
          ref={subheaderRef}
          className="subheader-line"
          style={{
            fontSize,
            height: maxHeight,
          }}
        >
          {text}
        </div>
      );
    }
    return null;
  };

  const renderSubtitle = (maxHeight: number) => {
    const { subtitle, width, bigNumber, bigNumberFallback } = props;
    let fontSize = 0;

    const NO_DATA_OR_HASNT_LANDED = t(
      'N/A — no data available',
    );
    const NO_DATA = t(
      'N/A — no data available, try different filters',
    );

### 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.
- [x] 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.

GitHub link: https://github.com/apache/superset/discussions/41053

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to