hover highlight does not match Series position (is offset)

42 views
Skip to first unread message

Guillem PG

unread,
Oct 18, 2013, 7:33:50 AM10/18/13
to gf...@googlegroups.com
Hello,

I've built a SimplePlot with Gflot v 3.1.1 that has two bars series plotted, one blue aligned to the left and another red aligned to the right:

            SeriesHandler absoluteFrequencies = model.addSeries( Series.of(nameOfAbsolute)
                                                                       .setColor("blue")
                                                                       .setBarsSeriesOptions(BarSeriesOptions.create()
                                                                                                             .setOrder(0)
                                                                                                             .setAlignment(BarAlignment.LEFT)));
           
            SeriesHandler metabolizedFrequencies = model.addSeries( Series.of(nameOfMetabolized)
                                                                          .setColor("red")
                                                                          .setBarsSeriesOptions(BarSeriesOptions.create()
                                                                                                             .setOrder(1)
                                                                                                             .setAlignment(BarAlignment.RIGHT)));


The SimplePlot has the following PlotHoverListener which simply displays the X Axis label String:

            SimplePlot chart = new SimplePlot(model,options);
           
            final PopupPanel popup = new PopupPanel();
            final Label label = new Label();
            popup.add(label);
           
            // add hover listener
            chart.addHoverListener( new PlotHoverListener() {
                public void onPlotHover( Plot plot, PlotPosition position, PlotItem item )
                {
                    if (item != null ) {
                       
                        List<String> selectedSubstructuresInRange = new ArrayList<String>();
                        if (plotInXAxis.equals(PLOT_SUBSTRUCTURES)){
                            selectedSubstructuresInRange = retrieveSelectedInRange(substructuresFilter, null, plotInXAxis);
                        }
                        else if (plotInXAxis.equals(PLOT_REACTION_MECHANISMS)){
                            selectedSubstructuresInRange = retrieveSelectedInRange(reactionMechanismsFilter, null, plotInXAxis);
                        }
                           
                        label.setText(selectedSubstructuresInRange.get(item.getDataIndex()));
                        popup.setPopupPosition(item.getPageX() + 10, item.getPageY() - 25 );
                        popup.show();
                    }
                }
            }, false );

When I hover on any of the Series, it is highlighted, but the highlighting (and the popup position) for the red series is offset to the right of where the actual bar is (see image):


I think this might be because of the different BarAlignment (LEFT for blue series, RIGHT for red), which I'd prefer not to change because it looks nicer.

Is there any way of controlling the highlighting position when I hover on, or to switch it off ?

Thank you very much!

Guillem

Nicolas Morel

unread,
Oct 19, 2013, 10:36:52 AM10/19/13
to gf...@googlegroups.com
Hi, 

To disable the highlighting, you can set the grid option "autoHighlight" to false :

plotOptions.setGridOptions( GridOptions.create().setHoverable( true ).setAutoHighlight( false ) );

I don't know a way to control the translucent overlay position.

Guillem PG

unread,
Oct 21, 2013, 2:46:44 AM10/21/13
to gf...@googlegroups.com

Thank you Nicolas, I somehow missed that option in the documentation!


Guillem
Reply all
Reply to author
Forward
0 new messages