gpt4 book ai didi

java - 如何了解 JfreeChart 鼠标悬停或鼠标单击事件上每个数据集的值

转载 作者:行者123 更新时间:2023-11-30 05:08:51 27 4
gpt4 key购买 nike

我想知道当我站在 XY 图上的曲线(数据集)上方时,如何知道它的值。

我已经实现了用于了解轴上刻度值的代码:

    int mouseX = event.getTrigger().getX();
int mouseY = event.getTrigger().getY();

Point mousePoint = new Point(mouseX, mouseY);

// convert the Java2D coordinate to axis coordinates...

ChartRenderingInfo chartInfo = chart.getChartRenderingInfo();
Point2D java2DPoint = chart.translateScreenToJava2D(mousePoint);
PlotRenderingInfo plotInfo = chartInfo.getPlotInfo();

Rectangle2D panelArea = chart.getScreenDataArea(mouseX, mouseY);

double yy = Math.round(plot.getRangeAxis().java2DToValue(
mousePoint.getY(), panelArea, plot.getRangeAxisEdge()));

StringBuffer stringB = new StringBuffer();
stringB.append("Profundidad : " + yy);

// the x coordinate is the same for all subplots
Rectangle2D dataArea = plotInfo.getDataArea();

List<Long> curvas = pista.getCurvas();

for (int i = 0, j = curvas.size(); i < j; i++) {
if (curvas.get(i) != null) {
double puntoXX = plot.getDomainAxis(i)
.java2DToValue(java2DPoint.getX(), dataArea,
plot.getDomainAxisEdge(i));

double xx = (Math.ceil((puntoXX + 0.05d) * 100)) / 100;

MDCurva curva = BuscadoresLista.buscarEnListaCurvas(curvas
.get(i));
stringB.append(" " + curva.getNombreCurva() + " " + xx);
}
}

PBarraEstado.getInstance().getTextoSubEstado2().setText(
stringB.toString());

但是,现在我想知道图中每条曲线的值。谁能帮我解决这个问题

最佳答案

我将从 examples 开始可以在 JFreeChart Demo 中的Miscellaneous > Crosshairs 下找到.

关于java - 如何了解 JfreeChart 鼠标悬停或鼠标单击事件上每个数据集的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4194557/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com