apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.51k stars 19.61k forks source link

[Bug] Zoom (Panning) outside last data in series #20219

Open MariiieP opened 3 months ago

MariiieP commented 3 months ago

Version

5.5.1

Steps to Reproduce

I want to shift the data on the axis beyond the date. After the shift, get new data and redraw the data on the graph. See ER.

I tried to do this using the current capabilities and attaching the configuration below. If you set a large percentage, it starts to work in a similar way. But it is unrealistic to select a percentage for the gap between the data every time Also, this solution allows you to shift the axis only in one direction, and not in two at once.

Example:

option = {
  xAxis: {
        type: 'time',
        splitNumber: 5,
    },
  dataZoom: {
    start: 99.9992, // !!! 
    type: "inside",
    moveOnMouseMove: "ctrl",
  // rangeMode: [1570627800000, 50]
  },
    yAxis: {
        type: 'value',
         splitNumber: 3,
         min: 0,
         max: 5,
         alignWithLabel: true
    },
    series: [
      {
        data: [[1721906700000, 0], [1721906400000, 1], [1721906100000, 2], [1721905800000, 0], [1721905500000, 1]],
        type: 'line',
        zoom: 0.15, // !!!
      },
      {
        type: 'scatter',
        data: [
          [1570627800000, 2]
        ]
      }
    ]
}

Current Behavior

I can't achieve this behavior at the moment. rangeMode allows you to change the axis only inside the current segment 0-100. Behavior with the configuration above: 2

Expected Behavior

ER:

The highcharts library allows you to do this: 1

simplified example: https://jsfiddle.net/BlackLabel/uab5mw0d/

Environment

- OS: windows
- Browser: Chrome 126.0.6478.185
- Framework: React 18

Any additional comments?

Is it possible to achieve ER with current capabilities?

helgasoft commented 2 months ago

Panning can be achieved with xAxis.min and xAxis.max - Demo

this issue is not a Bug or a Feature, but a "how-to" question 🚩 Please follow Official posting guidelines (below). This is not a good place to ask questions about usage, "how to" or extensive debugging assistance.


The issue list is reserved exclusively for bug reports and feature requests. For usage questions, please use the following resources:

Another good resource is website makeapie.cn with many code examples.

MariiieP commented 2 months ago

I already wrote above, min / max does not work, as start, rangeMode. The data needs to be requested AFTER scrolling the axis, pls look at the ER carefully.

more detailed example:

also, you do not know what data you will receive, what min/max you will have.

@helgasoft

helgasoft commented 2 months ago

Detailed explanation helps. It's about using the dataZoom as data selector. Not easy but feasible - link.

BTW, the Highcharts code example uses xAxis.max, same as ECharts 😉