具有第三个值的 XYdataset Jfreechart 标签图

XYdataset Jfreechart label plots with a third value

我正在制作一个图表,根据时间显示我的平均值。我构建了一个 XY 数据集 (TimeSeries),其中 x 轴是时间,y 轴是平均值。我从这个查询中得到平均值:

select hour, avg(localizations) as avg, count(distinct tag) as cnt from hourly_tag_summaries where hour >= ? and tag in ("+ids+") group by hour;

这就是我创建数据集的方式:

TimeSeries beacons_local = new TimeSeries("beacons-localizations");
String sql= "select hour, avg(localizations) as avg, count(distinct tag) as 
cnt from hourly_tag_summaries where hour >= ? and tag in ("+ids+") group by 
hour;";

    ResultSet rs1 = my_db.selectQuery(sql, Main.NOW - Main.DAYS);


    while (rs1.next()) {
        int avg = rs1.getInt("avg");
        long hour = rs1.getLong("hour");
        int cnt= rs1.getInt("cnt");
        beacons_local.add(new Millisecond(new Date(hour)),avg);

    }

我想保留 cnt 变量,这样当我将鼠标悬停在图表上时,我可以看到每个图的计数。我该怎么做?

每个 TimeSeries in your TimeSeriesCollection, maintain a List<Integer> of counts. Reference the relevant count in your custom XYToolTipGenerator, as shown here and here. The exact formulation depends on your use case; XYZDataset, and the corresponding XYZToolTipGenerator 都有示例,可作为指南。