ok, found the solution by myself - but it's a little bit tricky:
- for the color fields i just added a XYAreaRenderer
- the draggable lines were not very easy:
first of all you need a entity for a mouse-listener. that's why a line chart with two points and a line inbetween doesn't work.
two things work but both arent perfect: a) a slim area-chart works fine but you can't specify a specific line-width. you need to specify 2 x-valuues here. if you take a %age from the x-range the line width variies by zooming in and out.
b) a fixed line with can bre realized by a simple point with a very big shape. that works for me - however a shape height (given in pixels) is a dirty implementation (i just added a 2000px shape height)
then i realized that the ChartMouseListener only uses mousemoved and mouseclicked, but not mouse dragged.
so i decided to use the standard mouselistener and translate the coordinates:
Code: Select all
public void mouseDragged(MouseEvent e) {
if (!canDrag)
return;
Point2D p = e.getPoint();
Rectangle2D plotArea = getScreenDataArea();
XYPlot plot = (XYPlot) this.getChart().getPlot();
double xValue = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge());
...
}
I check the xValue with the values in my data-model which are used to fill the chartmodel/the vertical lines and alter the mouse-cursor, implement the dragging etc.
the good thing now is: i dont need an entity for the mouselistener. so i switched back to a line with two points to draw the vertical lines,
due to not needing an entity any more you could also youse ValueMarker
so i actually go by coordinates and not by object but that makes it a lot more easy in this case.
the only problem here is that you need to specify a range for hte mouseover (can drag flag). but using 1% o the range ireally like the look%feel making it easy to "grab" the lines