miunsi63 / gflot

Automatically exported from code.google.com/p/gflot
0 stars 0 forks source link

PlotWithOverview doesn't obey different settings for different series (just global series options) #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a PlotWithOverview graph and add two series with different options.  
e.g:

PlotWithOverviewModel model = new 
PlotWithOverviewModel(PlotModelStrategy.defaultStrategy());

SeriesHandler series1 = model.addSeries(new Series("series1")
                .setPointsOptions(new PointsSeriesOptions().setShow(false))
                .setLineSeriesOptions(new LineSeriesOptions().setFill(true).setLineWidth(0.0)));

SeriesHandler series2 = model.addSeries(new Series("series2")
                .setPointsOptions(new PointsSeriesOptions().setShow(true))
                .setLineSeriesOptions(new LineSeriesOptions().setFill(false).setLineWidth(1.0)));

What is the expected output? What do you see instead?

Expect to see two different lines with different properties.  For the above 
example, would expect to see one series which is filled, but no line or points 
plotted, and a second series with a visible line, no fill, and points plotted.

Actually see two lines with the same formatting.

What version of the product are you using? On what operating system?

Please provide any additional information below.

This bug relates to how PlotWithOverviewModel creates a new series when a 
selection is made in the overview window.  It clears the SeriesHandler 
m_windowHandler and then copies over all of the data points to it.  This can be 
fixed by copying over all of the series options as well, but perhaps more is 
needed for a fully robust solution?

I fixed it in my local copy by changing the onSuccess method in 
PlotWithOverviewModel.java (starting line 224) to:

public void onSuccess( DataPoint[] result )
{
    for ( DataPoint point : result )
    {
        m_windowHandler.add( point );
    }

    m_windowHandler.getSeries().setBarsSeriesOptions(getSeries().getBarSeriesOptions());
    m_windowHandler.getSeries().setImageSeriesOptions(getSeries().getImageSeriesOptions());
    m_windowHandler.getSeries().setLineSeriesOptions(getSeries().getLineSeriesOptions());
    m_windowHandler.getSeries().setPieSeriesOptions(getSeries().getPieSeriesOptions());
    m_windowHandler.getSeries().setPointsOptions(getSeries().getPointsSeriesOptions());

    m_lockSelection = x2 >= m_lastDataPoint.getX();
    if ( toExcuteAfterSelection != null )
    {
        toExcuteAfterSelection.execute();
    }
}

Original issue reported on code.google.com by griffith...@gmail.com on 21 Mar 2012 at 3:52

GoogleCodeExporter commented 9 years ago
FWIW, the fix I suggested is certainly NOT robust, but I hope it will be useful 
to someone who knows the code well.

Original comment by griffith...@gmail.com on 21 Mar 2012 at 4:04

GoogleCodeExporter commented 9 years ago
I commited a quick fix for this. You can look at revision 130. This way, you 
can even specify specific options for overview series.

To use it, you just have to do an ugly cast, get the series and set your 
options :
PlotWithOverviewSeriesHandler series1 = (PlotWithOverviewSeriesHandler) 
model.addSeries( "Random Series 1" );
        LineSeriesOptions lineSeries1 =  new LineSeriesOptions().setFill( false ).setLineWidth( 3 );
        series1.getWindowSeries().setLineSeriesOptions( lineSeries1);
        series1.getOverviewSeries().setLineSeriesOptions( lineSeries1 );
        PlotWithOverviewSeriesHandler series2 = (PlotWithOverviewSeriesHandler) model.addSeries( "Random Series 2" );

Original comment by nmr.morel on 21 Mar 2012 at 9:34

GoogleCodeExporter commented 9 years ago

Original comment by nmr.morel on 25 Mar 2012 at 6:06