scale for dial plot not showing

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
webcoder
Posts: 2
Joined: Sat Dec 11, 2010 3:42 am
antibot: No, of course not.

scale for dial plot not showing

Post by webcoder » Wed Jan 12, 2011 7:20 pm

I set up a simple program to display a dial chart/plot.

The chart is displaying. However, the scale on the chart is not showing at all.

Attached is my code.

I'm using the latest jfreechart jar files (jfreechart-1.0.13.jar and jcommon-1.0.16.jar).

Any help would be appreciated.

Code: Select all

    public class DialChartDemo extends ApplicationFrame {

    private static DefaultValueDataset dataset;
   
    public DialChartDemo(String title)
    {
        super(title);
        
        // create a data set
        dataset = new DefaultValueDataset(20.0);
        
        // create a chart
        JFreeChart chart = createChart(dataset);
        
        // add the chart to the panel
	    ChartPanel chartPanel = new ChartPanel(chart);
	    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
	    setContentPane(chartPanel);
    }
   

    private JFreeChart createChart(ValueDataset dataset)
    {
	    // create the chart...
        DialPlot dialPlot   = new DialPlot(dataset);
        
        JFreeChart chart = new JFreeChart("Dial Demo",
                           JFreeChart.DEFAULT_TITLE_FONT, dialPlot, false);
    	
        DialBackground sdb = new DialBackground(Color.white);
        dialPlot.addLayer(sdb);
        
        StandardDialScale scale = new StandardDialScale(0.0, 50.0, 225.0, -270.0, 0.0, 0);
        scale.setTickRadius(0.82);
        scale.setTickLabelOffset(-0.04);
        scale.setMajorTickIncrement(10.0);
        scale.setMinorTickCount(10);
        scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 5));
	scale.setMajorTickStroke(new BasicStroke(5f));
	scale.setMinorTickStroke(new BasicStroke(5f));
	scale.setMajorTickPaint(Color.BLUE);
	scale.setMinorTickPaint(Color.BLUE);
	scale.setTickLabelsVisible(true);
	scale.setFirstTickLabelVisible(true);
        dialPlot.addScale(0, scale);
        
        DialPointer.Pin needle = new DialPointer.Pin();
        needle.setRadius(0.84);
        dialPlot.addPointer(needle);

        return chart;
    }

    public static void main(String[] args) {
        DialChartDemo demo = new DialChartDemo("Dial Chart Demo");
        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);
    }
}

Locked