问题
I am interested in making a sort of hybrid between an XY Chart and Time Series in JFreeChart, where the x-axis is some SimpleDateFormat element (say, "yyyy-MM-dd HH:mm:ss.SSS"), with a respective start and end in the domain that is in this format, and the y-axis are levels, say LOW, MEDIUM, and HIGH. For each specific date/time, I would like to plot one of these three levels. How might I go about doing this?
回答1:
You'll need to combine several elements to get the desired effect:
Start with ChartFactory.createXYBarChart(), as shown below and here.
Use a DateAxis for the domain axis, as shown here.
Use
setDateFormatOverride()
on the domain axis to apply yourSimpleDateFormat
.Use a SymbolAxis for the range axis to replace integer values with your symbols, as shown here and here.
来源:https://stackoverflow.com/questions/45018974/combining-xyplot-and-timeseries-elements-in-jfreechart