-2

i'm working on a java swing app and i found a problem to put a Chart3D in a jpanel or a frame, this is my code

private void initChart(){

  CategoryDataset3D dataset = createDataset();
        Chart3D chart = Chart3DFactory.createStackedBarChart(
                "Personnel répartition,", 
                "repartition pour 480 personnel ", 
                dataset, null, 
                "Class", "Personnel");
     ImageIcon icon = new ImageIcon("/Users/dgilbert/Desktop/iStock_000003105870Small.jpg"); 
        RectanglePainter background = new StandardRectanglePainter(Color.WHITE, 
                icon.getImage(), new Fit2D(TitleAnchor.CENTER, 
                Scale2D.SCALE_BOTH));
            chart.setChartBoxColor(new Color(255, 255, 255, 155));
               CategoryPlot3D plot = (CategoryPlot3D) chart.getPlot();
//        StackedBarRenderer3D renderer = (StackedBarRenderer3D) plot.getRenderer();
//        renderer.setColorSource(new StandardCategoryColorSource( new Color[] { new Color(50, 200, 50),new Color(200, 50, 50) }));
            final ChartPanel chartPanel = new ChartPanel(chart);
            Frame frame = new ChartFrame("tokens pert time", chart);
            frame.setSize(550,450);

the problem is : final ChartPanel chartPanel = new ChartPanel(chart); Frame frame = new ChartFrame("tokens pert time", chart); in those two lines , it appears an error "Chart3D cannor be converted to j freeChart" –

trashgod
  • 203,806
  • 29
  • 246
  • 1,045

1 Answers1

1

As you appear to be using , you may be looking for Chart3DPanel, as shown in Getting Started.

Chart3DPanel chartPanel = new Chart3DPanel(chart); 
trashgod
  • 203,806
  • 29
  • 246
  • 1,045