Bug: setAllowNegativesFlag(true) causes 'wacked' graphs

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

Bug: setAllowNegativesFlag(true) causes 'wacked' graphs

Post by purduephotog » Mon Mar 21, 2005 10:19 pm

Hello-

The following code snippet is used to produce a graph for a project. There is one line commented out: when this is enabled the graph is completely hosed.

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++) {
            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
        //as requested by Jim L.
        ((LogarithmicAxis)rangeAxis).setExpTickLabelsFlag(false);
        ((LogarithmicAxis)rangeAxis).setLog10TickLabelsFlag(false);

        //FOLLOWING LINE A BUG!!!!!
        //((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();
        renderer.setSeriesLinesVisible(0,true);
        //renderer.setSeriesShapesVisible(1, false);
        plot.setRenderer(renderer);

        return chart;
Any ideas as to why allowing negative values prevent any number smaller than 1 for showing up on the axis?

Locked