gillius / jfxutils

JavaFX Utilities - Zoom and Pan Charts and Pane Scaling
Apache License 2.0
68 stars 22 forks source link

LineChart<String, Number> not supported. #11

Open ghost opened 8 years ago

ghost commented 8 years ago

Using a LineChart with a String in either x or y axis will cause the ChartZoomManager to break.

Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: javafx.scene.chart.CategoryAxis cannot be cast to javafx.scene.chart.ValueAxis at org.gillius.jfxutils.chart.ChartZoomManager.(ChartZoomManager.java:137)

gillius commented 8 years ago

Right now the library is meant to work with numerical axes only, so I assume value axis. I'm not sure it makes sense to zoom on category axes, but perhaps it could make sense to allow zooming constrained to the one ValueAxis if only X or Y is a value axis. That would be quite useful for charts showing states over time (like on/off, etc.) Is that what you are looking for?

gforman44 commented 7 years ago

Jason, I just added a right-click context menu to my chart.  Unfortunately, when I drag the chart around with the right button, it ends the drag by opening the context menu.  Oops.  I think  have a solution, but I haven't tested it. org.gillius.jfxutils.chart.ChartPanManager line 82 should        mouseEvent.consume()   IF in fact we were doing a drag.   Unconsumed, the system pops up the menu.   release() could return a boolean so we know whether to consume the event. I know--- back burner.  Me too.   George

On Saturday, May 28, 2016 8:31 PM, Jason Winnebeck <notifications@github.com> wrote:

Right now the library is meant to work with numerical axes only, so I assume value axis. I'm not sure it makes sense to zoom on category axes, but perhaps it could make sense to allow zooming constrained to the one ValueAxis if only X or Y is a value axis. That would be quite useful for charts showing states over time (like on/off, etc.) Is that what you are looking for?— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

gillius commented 7 years ago

Are you using the default mouse event filter that only handles primary button drags and ignores right clicks? But it sounds like you want it to pan with the right button if you drag but open menu if you don't. If I recall, jfxutils doesn't consume the events in most places.

gforman44 commented 7 years ago

Hi, Jason,

 If I recall, jfxutils doesn't consume the events in most places. Righto.  I'm using a mouse event filter that uses left-drag for zooming and right-drag for panning.  I just now added a pop-up menu, and it springs to life after a pan.  Oops.   My workaround is to use middle-drag for panning instead.  Good enough for me for now, but I'm thinking that the right solution is to consume the right-drag release events, and don't consume the right-nodrag release events.  Then the JavaFx can fire up the pop-up menu if not consumed.   George

Just thought I'd mention one other thing for the eventual re-write ;)---  the mouse event filter's logic is a bit backward-- it consumes the event to tell JfxUtil NOT to act.  /* A JfxUtil filter that accepts only a simple, single-click MIDDLE drag without modifiers. consume() tells JfxUtils.jar to reject, oddly! / public static final EventHandler SIMPLE_MIDDLE = ev -> { if (!JfxUtil.isDrag(ev, MouseButton.MIDDLE, 1)) ev.consume(); };

On Tuesday, October 18, 2016 7:09 PM, Jason Winnebeck <notifications@github.com> wrote:

Are you using the default mouse event filter that only handles primary button drags and ignores right clicks? But it sounds like you want it to pan with the right button if you drag but open menu if you don't. If I recall, jfxutils doesn't consume the events in most places.— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.