使用日期轴设置范围颜色堆叠的条形图

时间:2020-07-07 03:16:53

标签: java jfreechart

我尝试了JFreeChart - horizontal stacked bar chart with date axis中的代码

private CategoryDataset createDataset() {
  .....
                    // if data event time is in the range of the chart then show it
                    // THIS DOES NOT WORK PROPERLY!!!!
                    if (eventTime >= chartStartDate.getTime() && eventTime < chartEndDate.getTime()) {
                        // create series and categories
                        if (es.getStatus() == STANDBY_SERIES_INDEX) {
                            dataset.addValue(new Double(es.getTime()), STANDBY_SERIES, es.getName());
                        } else if (es.getStatus() == HEATING_SERIES_INDEX) {
                            dataset.addValue(new Double(es.getTime()), HEATING_SERIES, es.getName());
                        } else if (es.getStatus() == HOLDING_SERIES_INDEX) {
                            dataset.addValue(new Double(es.getTime()), HOLDING_SERIES, es.getName());
                        } else if (es.getStatus() == COOLING_SERIES_INDEX) {
                            dataset.addValue(new Double(es.getTime()), COOLING_SERIES, es.getName());
                        } else if (es.getStatus() == LOWERING_SERIES_INDEX) {
                            dataset.addValue(new Double(es.getTime()), LOWERING_SERIES, es.getName());
                        } else {
                            dataset.addValue(chartRange.getUpperBound() - chartRange.getLowerBound(), STANDBY_SERIES, es.getName());
                        }
                    } else {
                        continue;
                    }
                }
            }
        }
    } else {
        plot.setNoDataMessage("NO DATA AVAILABLE");
    }

    return dataset;
}

但是这些范围时间数据显示不正确 enter image description here

请帮助我如何获取

0 个答案:

没有答案