0

I tried code from 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;
}

But These range time data is incorrectly rendered enter image description here

Please help me how to get it

ELIP
  • 311
  • 6
  • 19
  • 1
    Use `setRange()`, suggested in comments [here](https://stackoverflow.com/q/62636908/230513), or `XYIntervalBarChart`, suggested [here](https://stackoverflow.com/a/40305146/230513). – trashgod Jul 08 '20 at 00:10
  • 1
    Also consider `XYTaskDataset`, discussed [here](http://www.jfree.org/forum/search.php?keywords=XYTaskDataset). – trashgod Jul 08 '20 at 08:32

0 Answers0