1

现在似乎没有人在使用 Ubercharts,我认为它很棒,因为我可以用 Java 编写所有代码。Ubercharts 是 highcharts 的 java 版本。

我今天的问题是,在 UI 创建图表后,我似乎找不到添加点的方法。通常在 highcharts 中这很容易使用AddPoint(),但现在使用 UberCharts 我不知道。

private static ISeries<?> a;
private static ISeries<?> b;
private static ISeries<?> c;

public ServerloadPanel(String id) {
    super(id);

    String pBackgroundColor = "rgba(0, 0, 0, 0.9)";
    Align pAlign = Align.center;
    Layout pLayout = Layout.horizontal;
    Integer pHeight = 200;
    VerticalAlign valign = VerticalAlign.bottom;

    a = new PointSeries("Pong").setData(new Point[] { new Point(serverLoadRestService.getLatestPoint("Pong").getEpoch(), serverLoadRestService
            .getLatestPoint("Pong").getLoad()) });

    b = new PointSeries("Doom").setData(new Point[] { new Point(serverLoadRestService.getLatestPoint("Doom").getEpoch(), serverLoadRestService
            .getLatestPoint("Doom").getLoad()) });

    c = new PointSeries("Zork").setData(new Point[] { new Point(serverLoadRestService.getLatestPoint("Zork").getEpoch(), serverLoadRestService
            .getLatestPoint("Zork").getLoad()) });

    final Highcharts highchart2 = new Highcharts(new SplineChart(), a, b, c);
    highchart2.getXAxis().setType(AxisType.datetime);
    // .setTickPixelInterval(150);
    // .setMaxZoom(20 * 1000);

    highchart2.getYAxis().setTitle(new AxisTitle("population"));
    // .setMin(0).setMax(4);

    highchart2.getChart().setPlotBackgroundColor("rgba(0, 0, 0, 0.9)").setBackgroundColor(pBackgroundColor);

    highchart2.getChart().setHeight(pHeight);
    highchart2.setColors(new String[] { "rgba(0, 0, 0, 0.9)" });
    Legend pLegend = new Legend();
    highchart2.setLegend(pLegend);

    highchart2.getLegend().setLayout(pLayout).setAlign(pAlign).setVerticalAlign(valign).setFloating(true);

    add(new HighchartsPanel("chart2", highchart2));

    add(new AbstractAjaxTimerBehavior(Duration.seconds(AJAX_QUOTE_REFRESH_MIN)) {
        @Override
        protected final void onTimer(AjaxRequestTarget target) {
                    // ADD NEW POINT
        }
    });

}

我想在 AJAX 调用中添加一个点。但这在 Ubercharts 中是如何完成的呢?

4

0 回答 0