⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 freechart.java

📁 jfreechart不错的教程例子谢谢!
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
       if(strItemArray.length>0)
       {
        for(int iIndex=0;iIndex<strItemArray.length;iIndex++)
        {
         // 指定Section色彩
         vPiePlot.setSectionPaint(iIndex,new Color(0,0+iIndex*(255/strItemArray.length),255));
         // 指定Section轮廓线颜色
         vPiePlot.setSectionOutlinePaint(0,Color.BLACK);
        }
        // 抽取指定块
        vPiePlot.setExplodePercent(0,1.00);
       }
      }
      // 指定Section标签格式
      vStandardPieItemLabelGenerator=new StandardPieItemLabelGenerator("{1}");
      vPiePlot.setLabelGenerator(vStandardPieItemLabelGenerator);
            
      vPiePlot.setForegroundAlpha(0.5f);
     }
    }
    catch(Exception e)
    {}
    break;
   case 3:
    

vFreeChart=ChartFactory.createMultiplePieChart(strFreeChartInfo,this.getCategoryDataset(),TableOrder.BY_ROW,true,false,false);
    try
    {
     vMultiplePiePlot=(MultiplePiePlot)vFreeChart.getPlot();
     if(vMultiplePiePlot!=null)
     {
      vFreeChartExtend=vMultiplePiePlot.getPieChart();
      vPiePlot=(PiePlot)vFreeChartExtend.getPlot();
      if(bRender)
      {
       if(strItemArray.length>0)
       {
        for(int iIndex=0;iIndex<strItemArray.length;iIndex++)
        {
         // 指定Section色彩
         vPiePlot.setSectionPaint(iIndex,new Color(0,0+iIndex*(255/strItemArray.length),255));
         // 指定Section轮廓线颜色
         vPiePlot.setSectionOutlinePaint(0,Color.BLACK);
        }
       }
      }
      // 指定Section标签格式
      vStandardPieItemLabelGenerator=new StandardPieItemLabelGenerator("{1}");
      vPiePlot.setLabelGenerator(vStandardPieItemLabelGenerator);
      vPiePlot.setForegroundAlpha(0.5f);      
     }
    }
    catch(Exception e)
    {}
    break;
   case 4:
    vFreeChart=ChartFactory.createPieChart3D(strFreeChartInfo,this.getPieDataset(),true,false,false);
    try
    {     
     vPiePlot3D=(PiePlot3D)vFreeChart.getPlot();
     if(vPiePlot!=null)
     {
      if(bRender)
      {
       if(strItemArray.length>0)
       {
        for(int iIndex=0;iIndex<strItemArray.length;iIndex++)
        {
         // 指定Section色彩
         vPiePlot3D.setSectionPaint(iIndex,new Color(0,0+iIndex*(255/strItemArray.length),255));
         // 指定Section轮廓线颜色
         vPiePlot3D.setSectionOutlinePaint(0,Color.BLACK);
        }
       }
      }
      // 指定Section标签格式
      vStandardPieItemLabelGenerator=new StandardPieItemLabelGenerator("{1}");
      vPiePlot3D.setLabelGenerator(vStandardPieItemLabelGenerator);
      //
      vPiePlot3D.setForegroundAlpha(0.8f);
     }
    }
    catch(Exception e)
    {}
    break;
   case 5:
    

vFreeChart=ChartFactory.createMultiplePieChart3D(strFreeChartInfo,this.getCategoryDataset(),TableOrder.BY_ROW,true,false,false);
    try
    {
     vMultiplePiePlot=(MultiplePiePlot)vFreeChart.getPlot();
     if(vMultiplePiePlot!=null)
     {
      vFreeChartExtend=vMultiplePiePlot.getPieChart();
      vPiePlot3D=(PiePlot3D)vFreeChartExtend.getPlot();
      if(bRender)
      {       
       if(strItemArray.length>0)
       {
        for(int iIndex=0;iIndex<strItemArray.length;iIndex++)
        {
         // 指定Section色彩
         vPiePlot3D.setSectionPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));
         // 指定Section轮廓线颜色
         vPiePlot3D.setSectionOutlinePaint(0,Color.BLACK);
        }
       }       
      }
      // 指定Section标签格式
      vStandardPieItemLabelGenerator=new StandardPieItemLabelGenerator("{1}");
      vPiePlot3D.setLabelGenerator(vStandardPieItemLabelGenerator);
      //
      vPiePlot3D.setForegroundAlpha(0.8f);
     }
    }
    catch(Exception e)
    {}
    break;
   case 6:
    

vFreeChart=ChartFactory.createBarChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getCategoryDataset(),PlotOrientation.VERTICAL,true,false,false);
    try
    {
     vCategoryPlot=vFreeChart.getCategoryPlot();
     if(vCategoryPlot!=null)
     {
      if(bRender)
      {
       vBarRenderer=new BarRenderer();
       vBarRenderer.setBaseOutlinePaint(Color.GRAY);
       // 设置X轴代表的柱的颜色
       if(strCategoryArray.length>0)
       {
        for(int iIndex=0;iIndex<strCategoryArray.length;iIndex++)
        {
         vBarRenderer.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));        
         vBarRenderer.setSeriesOutlinePaint(0,Color.BLACK);
        }
       }
       vBarRenderer.setItemMargin(0.1);   
       vCategoryPlot.setRenderer(vBarRenderer);
       // 设置X轴、Y轴的显示位置
       vCategoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
       vCategoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
      }
      // 设置柱的透明度
      vCategoryPlot.setForegroundAlpha(0.5f);
     }
    }
    catch(Exception e)
    {}
    break;
   case 7:
    

vFreeChart=ChartFactory.createStackedBarChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getCategoryDataset(),PlotOrientation.VERTICAL,true,false,false);
    try
    {
     vCategoryPlot=vFreeChart.getCategoryPlot();
     if(vCategoryPlot!=null)
     {
      if(bRender)
      {
       vStackedBarRenderer=new StackedBarRenderer();
       vStackedBarRenderer.setBaseOutlinePaint(Color.GRAY);
       // 设置X轴代表的柱的颜色
       if(strCategoryArray.length>0)
       {
        for(int iIndex=0;iIndex<strCategoryArray.length;iIndex++)
        {
         vStackedBarRenderer.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));
         vStackedBarRenderer.setSeriesOutlinePaint(0,Color.BLACK);
        }
       }      
   
       vCategoryPlot.setRenderer(vStackedBarRenderer);       
       // 设置X轴、Y轴的显示位置
       vCategoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
       vCategoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
      }
      // 设置柱的透明度
      vCategoryPlot.setForegroundAlpha(0.5f);
     }
    }
    catch(Exception e)
    {}
    break;
   case 8:
    

vFreeChart=ChartFactory.createBarChart3D(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getCategoryDataset(),PlotOrientation.VERTICAL,true,false,false);
    try
    {
     vCategoryPlot=vFreeChart.getCategoryPlot();
     if(vCategoryPlot!=null)
     {
      if(bRender)
      {
       vBarRenderer3D=new BarRenderer3D();
       vBarRenderer3D.setBaseOutlinePaint(Color.GRAY);
       // 设置X轴代表的柱的颜色
       if(strCategoryArray.length>0)
       {
        for(int iIndex=0;iIndex<strCategoryArray.length;iIndex++)
        {
         vBarRenderer3D.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));        
         vBarRenderer3D.setSeriesOutlinePaint(0,Color.BLACK);
        }
       }
       vBarRenderer3D.setItemMargin(0.1);
   
       vCategoryPlot.setRenderer(vBarRenderer3D);       
       // 设置X轴、Y轴的显示位置
       vCategoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
       vCategoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
      }
      // 设置柱的透明度
      vCategoryPlot.setForegroundAlpha(0.8f);
     }
    }
    catch(Exception e)
    {}
    break;
   case 9:
    

vFreeChart=ChartFactory.createStackedBarChart3D(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getCategoryDataset(),PlotOrientation.VERTICAL,true,false,false);
    try
    {
     vCategoryPlot=vFreeChart.getCategoryPlot();
     if(vCategoryPlot!=null)
     {
      if(bRender)
      {
       vStackedBarRenderer3D=new StackedBarRenderer3D();
       vStackedBarRenderer3D.setBaseOutlinePaint(Color.GRAY);
       // 设置X轴代表的柱的颜色
       if(strCategoryArray.length>0)
       {
        for(int iIndex=0;iIndex<strCategoryArray.length;iIndex++)
        {
         vStackedBarRenderer3D.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));
         vStackedBarRenderer3D.setSeriesOutlinePaint(0,Color.BLACK);
        }
       }      
   
       vCategoryPlot.setRenderer(vStackedBarRenderer3D);
       
       // 设置X轴、Y轴的显示位置
       vCategoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
       vCategoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
      }
      // 设置柱的透明度
      vCategoryPlot.setForegroundAlpha(0.8f);
     }
    }
    catch(Exception e)
    {}    
    break;
   case 10:
    

vFreeChart=ChartFactory.createAreaChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getDefaultCategoryDataset(),

PlotOrientation.VERTICAL,true,false,false);
    try
    {
     vCategoryPlot=vFreeChart.getCategoryPlot();
     if(vCategoryPlot!=null)
     {
      if(bRender)
      {
       vStackedAreaRenderer=new StackedAreaRenderer();
       vStackedAreaRenderer.setBaseOutlinePaint(Color.GRAY);
       // 设置区域颜色
       if(strItemArray.length>0)
       {
        for(int iIndex=0;iIndex<strItemArray.length;iIndex++)
        {
         vStackedAreaRenderer.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strItemArray.length),255));
         vStackedAreaRenderer.setSeriesOutlinePaint(0,Color.BLACK);
        }
       }      
   
       vCategoryPlot.setRenderer(vStackedAreaRenderer);
       
       // 设置X轴、Y轴的显示位置
       vCategoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
       vCategoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
      }
      // 设置区域透明度
      vCategoryPlot.setForegroundAlpha(0.5f);
      // 背景表格线
      vCategoryPlot.setDomainGridlinesVisible(true);
     }
    }
    catch(Exception e)
    {}
    break;
   case 11:
    

vFreeChart=ChartFactory.createStackedAreaChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getCategoryDataset(),

PlotOrientation.VERTICAL,true,false,false);
    try
    {
     vCategoryPlot=vFreeChart.getCategoryPlot();
     if(vCategoryPlot!=null)
     {
      if(bRender)
      {
       vStackedAreaRenderer=new StackedAreaRenderer();
       vStackedAreaRenderer.setBaseOutlinePaint(Color.GRAY);
       // 设置区域颜色
       if(strCategoryArray.length>0)
       {
        for(int iIndex=0;iIndex<strCategoryArray.length;iIndex++)
        {
         vStackedAreaRenderer.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));
         vStackedAreaRenderer.setSeriesOutlinePaint(0,Color.BLACK);
        }
       }      
   
       vCategoryPlot.setRenderer(vStackedAreaRenderer);
       
       // 设置X轴、Y轴的显示位置
       vCategoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
       vCategoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
      }
      // 设置区域透明度
      vCategoryPlot.setForegroundAlpha(0.5f);
     }
    }
    catch(Exception e)
    {}    
    break;
   case 12:
    

vFreeChart=ChartFactory.createLineChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getCategoryDataset(),PlotOrientation.VERTICAL,true,false,false);
    try
    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -