Skip to content

Lines and mark areas disappear during zooming #3637

Closed

Description

@jnehlmeier

问题简述 (One-line summary)

During zooming ECharts does not paint lines to chart boundaries if the target point is outside of the visible coordinate range. Mark areas however are painted to chart boundaries. But mark areas also disappear if both start and end coordinates of the mark area are outside the visible coordinate range.

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version): 3.2.0 / master branch
  • 浏览器类型和版本 (Browser version): all
  • 操作系统类型和版本 (OS Version): all

重现步骤 (Steps to reproduce)

  1. Open https://jsfiddle.net/wy0v5yqv/ or used options posted below
  2. Move left handle of zoom slider slightly to the right and left most line part will disappear (bad), but left most mark area still visible (good)
  3. Move right handle of zoom slider slightly to the left and right most line part will disappear (bad), but right most mark area still visible (good)
  4. Move right handle of zoom slider further to the right and remaining line part will disappear once its target point is out of zoom range (bad). Moving the handle even further to the right until the zoomed/visible range crosses the right edge of the left most mark area causes the left most mark area to disappear as well. Now you have an empty chart (bad).

期望结果 (Expected behaviour)

Lines and mark areas should be painted even if their points are outside of the zoomed area. If you don't want that all the time, at least make it configurable.

可能哪里有问题 (What went wrong)

See "Steps to reproduce" above.

ECharts配置项 (ECharts option)

option = {
    legend: {
        data:['issue']
    },
    dataZoom: [
      { type: 'slider', show: true },
      { type: 'inside', show: true }
    ],
    xAxis: {
      type: 'time',
    },
    yAxis: {
      type: 'value',
      max: 50
    },
    series: [
      {
        name:'issue',
        type:'line',
        data:[
          {name : "2016-01-01", value: ["2016-01-01 00:00:00", 5]},
          {name : "2016-01-02", value: ["2016-01-02 00:00:00", 15]},
          {name : "2016-01-03", value: ["2016-01-03 00:00:00", 25]},
          {name : "2016-01-03", value: ["2016-01-05 00:00:00", 15]},
        ],
            markArea: {
                silent: true,
                data: [
                    [
                        { coord: ["2016-01-01 00:00:00", 5] }, 
                        { coord: ["2016-01-01 23:59:59", 15] }
                    ],
                    [
                        { coord: ["2016-01-02 00:00:00", 10] }, 
                        { coord: ["2016-01-02 23:59:59", 20] }
                    ],
                    [
                        { coord: ["2016-01-03 00:00:00", 15] }, 
                        { coord: ["2016-01-03 23:59:59", 35] }
                    ]
                ]
            },
        }
    ]
}

其他信息 (Other comments)

https://jsfiddle.net/wy0v5yqv/

Activity

  1. pissang commented on Jul 14, 2016

    @pissang
    Contributor

    That's because what dataZoom do is to zoom and filter the data, not simply zoom the view. So even if you move left handle of zoom slider slightly, the first data will still be filtered and not shown in the finally view.

  2. jnehlmeier commented on Jul 14, 2016

    @jnehlmeier
    Author

    @pissang I tried adding filterMode: 'empty' to the data zoom options because I thought that might change the behavior (a bit tough to guess without english docs :)), but it doesn't. Lines / mark areas still disappear.

    That behavior is a bit annoying when you zoom into a data set and then move the zoomed area across the whole data set, e.g you have 3 years of data and zoom into a week or month and then move this zoom window. Sometimes mark areas can disappear and if you have some larger gaps in your dataset the chart line itself can disappear. IMHO its confusing.

    What if you still filter data but keep the first left and right data points outside the range in your model so you can render the chart correctly?

  3. pissang commented on Jul 14, 2016

    @pissang
    Contributor

    I found markArea may do disappear unexpectedly. I will fix it in the next version.

    And about line we agree it's a bit annoying when sliding the window which there is no much data on the view. But it's difficult to "keep the first left and right data points outside the range" in this architecture. Sorry about that. And we will try to figure out a good way to solve the problem.

    About filterMode: 'empty'. In this mode the filtered data will be replaced with '-' instead of being removed. It is used not that often.

  4. jarben commented on Jul 22, 2016

    @jarben
    Contributor

    Any thoughts or progress on this one? Could the view "snap" to the nearest unfiltered data points if boundaryGap is false? Similarly to what happens in the 'category' type?

    Or filterMode:'hidden' which wouldn't filter data but just clip line in the view?

  5. Nick74k commented on Mar 31, 2017

    @Nick74k

    The same problem (And even worser) with Y axe. X axe just gives a shorter graph. Y axe removes a parts of graph completely, cutting it into small pieces, not linked with each other, and not cutted by graph edges visually, or dramatically changes its shape, depending on filterMode. Is it possible to make zooming without filtering? Please, please, please make filterMode: "none" for us and we will be happy completely )))
    Look at this - the same graph with Y zooming to 25, to 24 with filtermode="filter" and to 24 with filtermode="empty"

    2017-3-31_18-37-41 435

    P.S. And is it possible to add this option to toolbox->feature->dataZoom also?
    P.S.2 Commenting of row seriesData.filterSelf(dim, isInWindow); at AxisProxy.filterdata gives needed functionality of graph.

  6. BlueBeN82 commented on May 24, 2017

    @BlueBeN82

    Any updates on this one?

  7. jorat1346 commented on Sep 21, 2017

    @jorat1346

    I changed the line at echarts/src/component/dataZoom/dataZoomProcessor.js@54 from:
    dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel);
    to
    dataZoomModel.getAxisProxy(dimNames.name, axisIndex);

    It mint not be the best way to do this for fast rendering, but it works for me for now.

  8. mvdkwast commented on Dec 2, 2017

    @mvdkwast

    Based on jorat1346 comment, as a work-around I changed the line echarts/src/component/dataZoom/AxisProxy.js@307 to :

    (filterMode !== 'disabled') && each(seriesModels, function (seriesModel) {
    

    That way I can specify write the following in my dataZoom section :

    filterMode: 'disabled',
    

    This doesn't solve the issue with marklines / areas.

    Is there any work in progress on this ?

  9. iozbek commented on Nov 8, 2018

    @iozbek

    filtermode: 'none' resolves the problem.

  10. added
    stale
    on Jul 8, 2019
  11. ryantunis commented on Jan 9, 2020

    @ryantunis

    Adding filterMode: none doesn't resolve this problem for me. The mark line still disappears when zooming in.

    Echarts Version: 4.6.0

    Data Zoom Settings:

        /**
         * Get's the data zoom mode.
         */
        getDataZoom(): any[] {
          return [{
            type: 'slider',
            xAxisIndex: [0],
            filterMode: 'none'
          }, {
            type: 'slider',
            yAxisIndex: [0],
            filterMode: 'none',
          }, {
            type: 'inside',
            xAxisIndex: [0],
            filterMode: 'none'
          }, {
            type: 'inside',
            yAxisIndex: [0],
            filterMode: 'none'
          }];
        }

    Line Series Object with MarkLine:

       /**
       * Create's horizontal line series object.
       */
      createHorizontalLineSeries(
        name: string,
        formatterLabel: string,
        color: string,
        xMin: number,
        xMax: number,
        y: number
      ) {
        return {
          name: name,
          type: 'line',
          markLine: {
            lineStyle: {color: color},
            data: [
              [
                // start point of the line
                // we have to defined line attributes only here (not in the end point)
                {
                  xAxis: xMin,
                  yAxis: y,
                  symbol: 'none',
                  label: {
                    show: true,
                    position: 'end',
                    emphasis: {
                      show: true,
                      formatter: formatterLabel
                    }
    
                  }
                },
                // end point of the line
                {
                  xAxis: xMax,
                  yAxis: y,
                  symbol: 'none'
                }
              ]
            ]
          }
        } as EChartOption.SeriesLine;
      },
  12. kgtBiligoat commented on May 21, 2020

    @kgtBiligoat

    @ryantunis how do you fixed this problem now

  13. BaSmile commented on May 21, 2020

    @BaSmile

    @kgtBiligoat For a zoom type 'inside', filter:'none' works for me.

  14. 1 remaining item

  15. tomkp75 commented on Jun 25, 2020

    @tomkp75

    filterMode does not work for me either.

    Also, this workaround might not always answer the need. One may want to filter on the serie and not on the marks.

    The way I found a markArea would stick is by setting xAxis only (or yAxis only), or to also set x or y as a percentage which is inconvenient as it refers the pixels on the screen not the chart axis. All my other attempts to set both width and height resulted in the markArea disappearing.

  16. bojue214 commented on Nov 20, 2020

    @bojue214

    Any updates on this one?

  17. mmm2006 commented on Dec 17, 2020

    @mmm2006

    请问,这个问题有解答吗?我也遇到了同样的问题,标记了一个markArea, 通过datazoom放大的时候,只要markarea的范围超过了当前datazoom的区域,markarea就会消失。例子:https://echarts.apache.org/examples/zh/editor.html?c=area-rainfall 也能很容易就浮现这个问题,希望能提供解决方法。谢谢

  18. kkua22 commented on Jan 10, 2021

    @kkua22

    @Ovilia Any info? Setting filterMode: 'none' does not help my marklines still disappear as soon as I zoom in.

  19. kevalbhatt commented on Jan 12, 2021

    @kevalbhatt

    For me filterMode: "none" worked.

    dataZoom: [{
            startValue: "2018-05",
            filterMode: "none",
            start: 0,
            end: 20
        },
        {
            type: "inside"
        }
    ]
    

    but after this found another issue. The bar is going outside of the x-axis

    Capture

    @pissang any help would appreciate

  20. mackeroo commented on Jan 12, 2021

    @mackeroo

    Similar to others in this thread, filterMode: "none" is not working for me, and I've been tracking this thread for updates on this issue. @kevalbhatt I'm curious -- if you change the slider on the right to 06-2019, your markLine (blue horizontal line at ~2.4m) doesn't disappear? I expect the markLine to persist up until 06-2019 in this case.

  21. y0nd0 commented on Apr 2, 2021

    @y0nd0

    We could implement another filterMode or change the current default filter by simply include one more point on each side. So that the left and right are always outside of the view. So you have no gaps anymore.

    I don't know how the filter works (not viewed the source code), but we just have to include exact one point left and right. You know what I mean?

    record

    I could create a new issue if you want. But I thought I ask first.

  22. dthunn commented on Apr 28, 2021

    @dthunn

    Having the same issue, "filterMode: none" does nothing for me, issue should not be closed.

  23. dummyGit1 commented on Aug 17, 2021

    @dummyGit1

    as an alternative fix you can use the below code to generate multiple mark lines so that even with zoom you will have it working

    const getCoords = (xMin = 0, yMin = 0, xMax = 1, yMax = 1, accuracy = 10) => {
    const xDiff = (xMax - xMin) / accuracy;
    const yDiff = (yMax - yMin) / accuracy;
    let presentXVal = xMin;
    let presentYVal = yMin;
    const dataArr = [];
    while (presentXVal <= xMax) {
    let coordArr: { coord: number[] }[] = [];
    coordArr = [{ coord: [presentXVal, presentYVal] }];
    presentXVal += xDiff;
    presentYVal += yDiff;
    coordArr.push({ coord: [presentXVal, presentYVal] });
    dataArr.push(coordArr);
    }
    return dataArr;
    };

  24. locinus commented on Aug 22, 2021

    @locinus

    Other workaround proposed on the other topic: #14835 (comment)

  25. Nurech commented on Mar 4, 2022

    @Nurech

    filtermode: 'none' should be default IMO. Was quite troublesome to get to this post to solve the visual problem itself creates. Anyway, glad I found this post!

  26. Zamlos commented on Apr 24, 2023

    @Zamlos

    This issue is not solved

  27. rafalrat commented on May 4, 2023

    @rafalrat

    I can confirm that the issue still exists. My case is as such: I have a bar chart with 100 entries and a markArea starting at 11th measurement, I zoom in and scroll the data to the right. The left-hand side of the area gets cut off when the first tick on the X-axis is not at [0, 0] in the current view port. Please compare:

    The first tick is not at [0, 0]:
    image

    When the first tick is at [0, 0], then the area is not cropped:
    image

    Below a minimalistic configuration of the mentioned problem:

    const randomValues = Array.from({ length: 100 }, (i) => (Math.random() * 40));
    
    option = {
      xAxis: {
        data: randomValues.map((_, i) => (`meas${i}`))
      },
      yAxis: {},
      series: [{
        name: "Sale",
        type: "bar",
        data: randomValues,
        markArea: {
          silent: true,
          data: [
            [{ xAxis: 'meas10', itemStyle: { color: 'rgb(239, 150, 0)' } }, { yAxis: 20 }]
          ]
        }
      }],
      dataZoom: { type: 'inside' } 
    }

    and here is a working demo. Please zoom-in the chart and start scrolling to the right to the see the effect.

    Does anyone have an idea how to solve this issue. It is quite annoying when the markArea gets cut off as the zoomed-in chart is being scrolled.

    markarea-bug-on-scrolling

  28. helgasoft commented on Oct 6, 2024

    @helgasoft

    @rafalrat, defining markArea.data by yAxis only will maintain a smooth scroll - [{yAxis: 0, itemStyle:{ color:'gold'}},{yAxis: 20}]

  29. 752841728 commented on Mar 12, 2025

    @752841728

    This issue is not solved

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

    enhancementstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions