Zoom is partially reset after adding new series to XYChart
メンテナーはふだん 4 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 57/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java
調査の方向性
Start by tracing how XYChart stores zoom ranges and updates axis limits when addSeries is called; the issue provides a Java Swing reproduction using XChartPanel. Reproduce the sequence of adding series, zooming, and adding more series, then check existing chart tests for coverage of zoom and series updates. Done means the chosen behavior is consistent: either all series are shown after resetting zoom, or the zoom range remains applied to every series.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When some zoom range is set to the XYChart, it is partially reset after adding new series to the chart. Xaxis range and yaxis ranges are set to ones matching newly added series but for existing series only points matching original zoom range are displayed. Chart as a whole looks strange. Full new series are displayed but only partial old series are displayed.
It would be consistent to either reset fully zoom and display all series fully or to keep zoom range and display only matching point from newly added series (my prefered behaviour).
To Reproduce
To reproduce issue perform steps:
Create chart
Add series A, B, C
Set zoom to some sub range (i.e. single point of charts A, B, C)
Add new series D, E
Now chart (xaxis, yaxis) is resized and chart shows full series D, E and still partial series A, B, C (single points).
It is required to click "Reset zoom" button to see full series A, B, C.
Sample chart code:
package example;
import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.text.ParseException;
import javax.swing.JFrame;
import org.knowm.xchart.XChartPanel;
import org.knowm.xchart.XYChart;
import org.knowm.xchart.XYChartBuilder;
public class XChartBugZoomAfterAddingSerie extends JFrame{
private static final long serialVersionUID = 1L;
double[] xValuesA = new double[] {10, 20, 30};
double[] yValuesA = new double[] {10, 20, 30};
double[] xValuesB = new double[] {11, 21, 31};
double[] yValuesB = new double[] {10, 20, 30};
double[] xValuesC = new double[] {12, 22, 32};
double[] yValuesC = new double[] {10, 20, 30};
double[] xValuesD = new double[] {13, 23, 33};
double[] yValuesD = new double[] {10, 20, 30};
double[] xValuesE = new double[] {14, 24, 34};
double[] yValuesE = new double[] {10, 20, 30};
private XYChart chart;
XChartPanel<XYChart> chartPanel;
public static void main(String[] args) throws ParseException {
XChartBugZoomAfterAddingSerie app = new XChartBugZoomAfterAddingSerie();
app.setSize(600,400);
app.setVisible(true);
app.zoomAndAddSerie();
}
public void zoomAndAddSerie() {
Runnable r = new Runnable() {
@Override
public void run() {
try {
Thread.sleep(3000);
simulateZoom();
Thread.sleep(3000);
chart.addSeries("D", xValuesD, yValuesD);
chart.addSeries("E", xValuesE, yValuesE);
chartPanel.repaint();
}
catch(InterruptedException ie) {
return;
} catch (AWTException e) {
return;
}
}
};
new Thread(r).start();
}
public void simulateZoom() throws AWTException {
Robot robot = new Robot();
// Convert coordinates relative to JFrame into screen coordinates
Point framePos = getLocationOnScreen();
int x1 = framePos.x + 250;
int y1 = framePos.y + 50;
int x2 = framePos.x + 350;
int y2 = framePos.y + 50;
// Move mouse to starting position
robot.mouseMove(x1, y1);
// Press left mouse button
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
// Optional: simulate actual dragging instead of instant movement
int steps = 20;
for (int i = 1; i <= steps; i++) {
int x = x1 + (x2 - x1) * i / steps;
int y = y1 + (y2 - y1) * i / steps;
robot.mouseMove(x, y);
robot.delay(10);
}
// Release at destination
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
public XChartBugZoomAfterAddingSerie() {
chart = getXYChart();
chartPanel = new XChartPanel<>(chart);
chartPanel.setZoomEnabled(true);
setLayout(new BorderLayout());
add(chartPanel, BorderLayout.CENTER);
}
public XYChart getXYChart() {
XYChart chart =
new XYChartBuilder()
.width(720)
.height(480)
.title("Zoom partially reset after adding series")
.xAxisTitle("Count")
.yAxisTitle("Value")
.build();
chart.addSeries("A", xValuesA, yValuesA);
chart.addSeries("B", xValuesB, yValuesB);
chart.addSeries("C", xValuesC, yValuesC);
return chart;
}
}
Screenshots
After chart creation with series A, B, C
After setting zoom to range covering only single points of series A, B, C:
After adding new series D, E (series D, E displayed fulle, series A, B, C partially)
Expected behavior
It would be consistent to either reset fully zoom after adding new serie and display all series fully.
or
Keep zoom range and display only matching point from newly added series (my prefered behaviour).
- 主要言語
- Java
- スター
- 1.6k
- フォーク
- 400
- 平均マージ
- 3日 9時間
- マージ済み PR(30日)
- 7
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
knowm/XChart のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 4 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
メンテナーはふだん 4 日以内に返信
-
Cleanup: generate axis ticks in-range instead of pruning after the fact (follow-up to #634)対応中かも @Sinkleberg が 20 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 4 日以内に返信
-
`CategoryChart.addSeries` could support additional call signature for interoperability with Scala対応中かも @Sinkleberg が 20 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
メンテナーはふだん 4 日以内に返信
-
Annotationsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
メンテナーはふだん 4 日以内に返信
似ている issue
-
documentation good first issue help wanted
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信
-
bug key bindings
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
Android Bug Core Drape
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
organicmaps/organicmaps#14449 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
openhab/openhab-addons#22512 ·
メンテナーはふだん 1 日以内に返信