1.0.0.pre2 breaks ItemLabels for XYRenderer (labelGenerator)

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
purduephotog
Posts: 17
Joined: Wed Nov 10, 2004 11:29 pm

1.0.0.pre2 breaks ItemLabels for XYRenderer (labelGenerator)

Post by purduephotog » Mon May 09, 2005 3:44 pm

Hello-

While I've not been able to solve my visible ticks and visible data values problem, I just gave 1.0.0pre2 a run with the graphs I had gotten working (values only).

What has happened is the label generator code is not working anymore. For example:

Code: Select all

    public JFreeChart createLogBigYbyPatch_jFree() {
        //System.err.println("Here");
        XYSeriesCollection dataset = new XYSeriesCollection();
        XYSeries series = new XYSeries("Series 1");

        //Get the data that this will use and add them in the proper form
        double values0[]= this.getPatchArrayDouble();
        double values1[]= this.getBigYArray();

        for (int xLooper=0; xLooper < values0.length; xLooper++) {
            if (values1[xLooper] == 0) { //check for bug in graphing code that doesn't display 'allow negs' correctly
                series.add(values0[xLooper], values1[xLooper]+0.001);//roundoff error and bug in 'display 0's'.
            } else {
                series.add(values0[xLooper], values1[xLooper]);
            }
        }

        DisplayDevice Device = new DisplayDevice();
        java.util.Date curDate = new java.util.Date(System.currentTimeMillis());

        TextTitle myTitle0 = new TextTitle("Display: " + findHostName() + ":0." + Device.getCurrentDevice());
        TextTitle myTitle1 = new TextTitle( curDate.toString() );
        //TextTitle myTitle2 = new TextTitle("test1");
        //TextTitle myTitle3 = new TextTitle("test1");

        dataset.addSeries(series);
        JFreeChart chart = ChartFactory.createXYLineChart(
            "Luminance Response", // chart title
            "Code Value", // x axis label
            "Luminance (fL)", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL,
            false, // include legend
            true, // tooltips
            false // urls
        );

        chart.addSubtitle(myTitle0);
        chart.addSubtitle(myTitle1);
        //chart.addSubtitle(myTitle2);
        //chart.addSubtitle(myTitle3);

        NumberAxis rangeAxis = new LogarithmicAxis("Luminance (fL)");
        rangeAxis.setAutoRangeIncludesZero(true);
        //Make the Y-Axis into 'normal' non-scientific non-engineering notation numbers
        ((LogarithmicAxis)rangeAxis).setExpTickLabelsFlag(false);
        ((LogarithmicAxis)rangeAxis).setLog10TickLabelsFlag(false);

        //FOLLOWING LINE A BUG!!!!!
//Graph will not display properly if used- truncates the low end data values
        //((LogarithmicAxis)rangeAxis).setAllowNegativesFlag(true);
        ((LogarithmicAxis)rangeAxis).setStrictValuesFlag(false);

        XYPlot plot=(XYPlot)chart.getPlot();
        plot.setRangeAxis(rangeAxis);

        NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
        domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

        //XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        
        XYItemRenderer renderer  = plot.getRenderer();

        //renderer.setSeriesLinesVisible(0,true);
        //renderer.setShape(Shape.
        //renderer.setSeriesVisible(true);

        //http://www.jfree.org/phpBB2/viewtopic.php?t=12658&highlight=setitemlabelsvisible+xyitemrenderer
        //StandardXYLabelGenerator labelGenerator = new StandardXYLabelGenerator("{2}", new DecimalFormat("0.00"), new DecimalFormat("0.00"));
        StandardXYLabelGenerator labelGenerator = new StandardXYLabelGenerator("{2}", new DecimalFormat("0.00"), new DecimalFormat("0.00"));
        renderer.setLabelGenerator(labelGenerator);
        renderer.setItemLabelFont(new Font("Arial", Font.BOLD, 9));
        renderer.setItemLabelsVisible(true);
        renderer.setSeriesVisible(new Boolean(true) );

        System.out.println("Tried Labels");
        plot.setRenderer(renderer);

        return chart;
    }
All labels disappear from the graph and, of course, I still do not have any ticks... which leaves a semi smooth line only.

1) How do I enable labels again?
2) (Continuing) How do I enable tick marks?

And yes, I bought the manual.... and it's not helping.

Jason

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue May 10, 2005 9:37 pm

Any chance you could post some code that I could just cut, paste, run and debug? I'm feeling lazy, but I'd like to help.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked