Skip to content

[Feature] able to customize the dataMax/dataMin of axis rather than fixed max/min #20770

Closed

Description

@Justin-ZS

What problem does this feature solve?

demo

Like this demo, the axis.max/min just change the aixs range to [min, max].
max: 1555 will change the axis max to 1555

I want a dataMin/dataMax property that set the aixs range to [rounded(dataMin),rounded(dataMax)]
dataMax: 1555 will change the axis max to 1800

What does the proposed API look like?

type ValueAxis = {
  // other properties
  dataMax: number,
  dataMin: number
}

Activity

  1. changed the title [-][Feature] How to customize the dataMax/dataMin of axis rather than fixed max/min[/-] [+][Feature] able to customize the dataMax/dataMin of axis rather than fixed max/min[/+] on Feb 20, 2025
  2. linghaoSu commented on Feb 20, 2025

    @linghaoSu
    Member

    The scale attribute in the axis options might be what you need.

    doc demo

  3. Justin-ZS commented on Feb 20, 2025

    @Justin-ZS
    ContributorAuthor

    The scale attribute in the axis options might be what you need.

    doc demo

    No. The scale is used for other cases and doesn't work when max/min are set

    This configuration item is unavailable when the min and max are set.

  4. MatthiasMert commented on Feb 20, 2025

    @MatthiasMert

    You can pass a function to axis.min / axis.max and compute the axis boundary values from the min and max in your data.

    Example

  5. Justin-ZS commented on Feb 20, 2025

    @Justin-ZS
    ContributorAuthor

    You can pass a function to axis.min / axis.max and compute the axis boundary values from the min and max in your data.

    Example

    It's realy a good solution for simple cases.
    However, mantaining a function to handle many edge cases — such as negtive, small numbers, big numbers — can be quite annoying.
    ECharts already handles these cases effectively.
    All we need is a new API to seamlessly integrate our custom dataMax/dataMin values.

  6. MatthiasMert commented on Feb 20, 2025

    @MatthiasMert

    Another possible workaround would be to use an inviseble helper series that only contains your min and max values. Could be problematic combined with tooltip: { trigger: 'axis' }.

    Example

  7. Justin-ZS commented on Feb 21, 2025

    @Justin-ZS
    ContributorAuthor

    Another possible workaround would be to use an inviseble helper series that only contains your min and max values. Could be problematic combined with tooltip: { trigger: 'axis' }.

    Example

    Yes. It's exactly the workaround i'm using for now.
    I append an invisible line series to meet the requirement, but an official API would be much better

    const invisibleSeries = {
        type: 'line',
        symbolSize: 0,
        lineStyle: {
            width: 0,
            opacity: 0,
        },
        emphasis: {
            scale: false,
            disabled: true,
        },
        select: {
            disabled: true,
        },
        silent: true,
        animation: false,
        label: {
            show: false,
            formatter: '',
        },
        tooltip: {
            show: false,
            formatter: '',
        },
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions