GithubHelp home page GithubHelp logo

Report&Alert Format about superset HOT 4 OPEN

liangliangGit avatar liangliangGit commented on May 18, 2024
Report&Alert Format

from superset.

Comments (4)

rusackas avatar rusackas commented on May 18, 2024

Hmm... I don't really use the text-based reports, so I'll CC @yousoph here for more context/info. Did they ever support these formatters, or is it just the raw data from the database? The date formatters are picked up by the various visualizations to use as they need to... if we need to add support for formatters in text-based reports where it didn't exist before, then that seems more like a new feature request.

from superset.

liangliangGit avatar liangliangGit commented on May 18, 2024

Hmm... I don't really use the text-based reports, so I'll CC @yousoph here for more context/info. Did they ever support these formatters, or is it just the raw data from the database? The date formatters are picked up by the various visualizations to use as they need to... if we need to add support for formatters in text-based reports where it didn't exist before, then that seems more like a new feature request.

Yes, the data is retrieved from the database, and some formats have been implemented while others haven't. Here's a summary of my findings:
,d (12345.432 => 12,345) NG
.1s (12345.432 => 10k) NG
.3s (12345.432 => 12.3k) NG
,.1% (12345.432 => 1,234,543.2%) OK
.2% (12345.432 => 1234543.20%) OK
.3% (12345.432 => 1234543.200%) OK
.4r (12345.432 => 12350) NG
,.1f (12345.432 => 12,345.4) OK
,.2f (12345.432 => 12,345.43) OK
,.3f (12345.432 => 12,345.432) OK
"+, (12345.432 => +12,345) " NG
$,.2f (12345.432 => $12,345.43) NG
Duration in ms (66000 => 1m 6s) NG
Duration in ms (1.40008 => 1ms 400ยตs 80ns) NG
%d/%m/%Y | 14/01/2019 NG
%m/%d/%Y | 01/14/2019 NG
%Y-%m-%d | 2019-01-14 NG
%Y-%m-%d %H:%M:%S | 2019-01-14 01:32:10 OK
%d-%m-%Y %H:%M:%S | 14-01-2019 01:32:10 NG
%H:%M:%S | 01:32:10 NG
Prefix ยฅ (JPY) NG
Suffix ยฅ (JPY) NG

from superset.

rusackas avatar rusackas commented on May 18, 2024

Oh, interesting... I didn't know it was a mixed bag... I'm not sure why some are being picked up, but not others.

CC @eschutho in case you happen to know which gear isn't meshing.

from superset.

liangliangGit avatar liangliangGit commented on May 18, 2024

Below is a section of Python backend formatting code (found within the 'post_processing.py' file). It is deemed accurate if the Python format method aligns exactly with the d3format syntax, for instance, when using .1%.

def table(
    df: pd.DataFrame,
    form_data: dict[str, Any],
    datasource: Optional[  # pylint: disable=unused-argument
        Union["BaseDatasource", "Query"]
    ] = None,
) -> pd.DataFrame:
    """
    Table.
    """
    # apply `d3NumberFormat` to columns, if present
    column_config = form_data.get("column_config", {})
    for column, config in column_config.items():
        if "d3NumberFormat" in config:
            format_ = "{:" + config["d3NumberFormat"] + "}"
            try:
                df[column] = df[column].apply(format_.format)
            except Exception:  # pylint: disable=broad-except
                # if we can't format the column for any reason, send as is
                pass

    return df

from superset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.