在 JFreeChart 中组合 XYPlot 和 TimeSeries 元素

Combining XYPlot and TimeSeries elements in JFreeChart

我有兴趣在 JFreeChart 中混合 XY 图表和时间序列,其中 x 轴是一些 SimpleDateFormat 元素(例如,"yyyy-MM-dd HH:mm:ss.SSS"),开始和结束分别为这种格式的域和 y 轴是级别,比如 LOW、MEDIUM 和 HIGH。对于每个特定的 date/time,我想绘制这三个级别之一。我该怎么做呢?

您需要组合几个元素才能获得所需的效果:

  • ChartFactory.createXYBarChart(), as shown below and 开始。

  • 使用 DateAxis for the domain axis, as shown .

  • 在域轴上使用 setDateFormatOverride() 来应用您的 SimpleDateFormat

  • 使用 SymbolAxis for the range axis to replace integer values with your symbols, as shown here and here.