Skip to content

[Bug] Too many splitlines on time axis #17023

Closed

Description

@teuf22

Version

5.3.2

Link to Minimal Reproduction

No response

Steps to Reproduce

image

  option = {
      series: [
        {  data: [
            [ "2022-02-11", "0" ], [ "2022-02-14", "-0.005" ], [ "2022-02-15", "0.286" ], [ "2022-02-16", "0.462" ],
            [ "2022-02-17", "0.162" ], [ "2022-02-18", "0.033" ], [ "2022-02-21", "0.033" ], [ "2022-02-22", "-0.128" ],
            [ "2022-02-23", "-0.366" ], [ "2022-02-24", "0.104" ], [ "2022-02-25", "0.503" ], [ "2022-02-28", "1.015" ],
            [ "2022-03-01", "1.669" ], [ "2022-03-02", "2.689" ], [ "2022-03-03", "2.457" ], [ "2022-03-04", "2.893" ],
            [ "2022-03-07", "2.766" ], [ "2022-03-08", "3.595" ], [ "2022-03-09", "2.237" ], [ "2022-03-10", "1.988" ],
            [ "2022-03-11", "1.763" ], [ "2022-03-14", "0.519" ], [ "2022-03-15", "0.341" ], [ "2022-03-16", "0.935" ],
            [ "2022-03-17", "2.164" ], [ "2022-03-18", "2.457" ], [ "2022-03-21", "2.838" ], [ "2022-03-22", "2.861" ],
            [ "2022-03-23", "3.104" ], [ "2022-03-24", "3.158" ], [ "2022-03-25", "3.293" ], [ "2022-03-28", "2.364" ],
            [ "2022-03-29", "3.069" ], [ "2022-03-30", "3.033" ], [ "2022-03-31", "2.236" ], [ "2022-04-01", "2.507" ],
            [ "2022-04-04", "2.755" ], [ "2022-04-05", "1.842" ], [ "2022-04-06", "1.306" ], [ "2022-04-07", "1.201" ],
            [ "2022-04-08", "1.212" ], [ "2022-04-11", "0.738" ], [ "2022-04-12", "1.308" ], [ "2022-04-13", "2.167" ],
            [ "2022-04-14", "2.057" ], [ "2022-04-15", "2.057" ], [ "2022-04-18", "2.065" ], [ "2022-04-19", "1.85" ],
            [ "2022-04-20", "2.082" ], [ "2022-04-21", "1.307" ], [ "2022-04-22", "0.284" ], [ "2022-04-25", "0.04" ],
            [ "2022-04-26", "-0.527" ], [ "2022-04-27", "-0.577" ], [ "2022-04-28", "-0.089" ], [ "2022-04-29", "-0.836" ],
            [ "2022-05-02", "-0.727" ], [ "2022-05-03", "-0.647" ], [ "2022-05-04", "0.662" ], [ "2022-05-05", "-0.493" ],
            [ "2022-05-06", "-0.844" ], [ "2022-05-09", "-2.828" ], [ "2022-05-10", "-2.779" ], [ "2022-05-11", "-3.038" ]
          ],
          type: "line"
        }
      ],
      xAxis: {
        type:      "time",
        axisLine:  { show: true },
        splitLine: { show: true, lineStyle: { color: "#999" } }
      },
      yAxis: {
        type:      "value",
        axisLabel: { formatter: "{value}%" },
        axisLine:  { show: true },
        splitLine: { show: false }
      }
    }

Current Behavior

The splitline at April 29 causes a label overlap.

Also, the chart is difficult to read because splitlines are not distributed at regular time intervals.

Expected Behavior

Suggested solutions

  • display splitlines on days or on months, but not both at the same time
  • for each month, skip the last splitline on days if too close to month start

Environment

No response

Any additional comments?

No response

Activity

  1. added
    en
    pending
    on May 12, 2022
  2. jiawulin001 commented on May 14, 2022

    @jiawulin001
    Member

    The time interval designed in Echarts is decided by axis.splitNumber, and when it's (7.5,16], the tick interval is returned as 7 days.

    echarts/src/scale/Time.ts

    Lines 371 to 378 in 84b9578

    function getDateInterval(approxInterval: number, daysInMonth: number) {
    approxInterval /= ONE_DAY;
    return approxInterval > 16 ? 16
    // Math.floor(daysInMonth / 2) + 1 // In this case we only want one tick betwen two month.
    : approxInterval > 7.5 ? 7 // TODO week 7 or day 8?
    : approxInterval > 3.5 ? 4
    : approxInterval > 1.5 ? 2 : 1;
    }

    However you can try setting xAxis.minInterval to one month to show only the month ticks.

  3. Ovilia commented on May 16, 2022

    @Ovilia
    Contributor

    You can also set xAxis.minInterval.

  4. teuf22 commented on May 16, 2022

    @teuf22
    Author

    Thank you for the tips. Great library

  5. StimioAnthonyLeRoy commented on Sep 12, 2022

    @StimioAnthonyLeRoy

    What do you put to see only days and to not see the months ?

  6. StimioAnthonyLeRoy commented on Sep 12, 2022

    @StimioAnthonyLeRoy

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenpendingwaiting-for: community

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions