📄 freechart.java
字号:
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
{
vCategoryPlot=vFreeChart.getCategoryPlot();
if(vCategoryPlot!=null)
{
vLineAndShapeRenderer=new LineAndShapeRenderer();
vLineAndShapeRenderer.setBaseOutlinePaint(Color.GRAY);
if(bRender)
{
//设置线条颜色
if(strCategoryArray.length>0)
{
for(int iIndex=0;iIndex<strCategoryArray.length;iIndex++)
{
vLineAndShapeRenderer.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));
vLineAndShapeRenderer.setSeriesOutlinePaint(0,Color.BLACK);
}
}
//设置X轴、Y轴的显示位置
vCategoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
vCategoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
}
vCategoryPlot.setRenderer(vLineAndShapeRenderer);
//背景表格线
vCategoryPlot.setDomainGridlinesVisible(true);
}
}
catch(Exception e)
{}
break;
case 13:
vFreeChart=ChartFactory.createLineChart3D(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getCategoryDataset(),PlotOrientation.VERTICAL,true,false,false);
try
{
vCategoryPlot=vFreeChart.getCategoryPlot();
if(vCategoryPlot!=null)
{
vLineRenderer3D=new LineRenderer3D();
vLineRenderer3D.setBaseOutlinePaint(Color.GRAY);
if(bRender)
{
//设置线面颜色
if(strCategoryArray.length>0)
{
for(int iIndex=0;iIndex<strCategoryArray.length;iIndex++)
{
vLineRenderer3D.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));
vLineRenderer3D.setSeriesFillPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));
vLineRenderer3D.setSeriesOutlinePaint(0,Color.BLACK);
}
}
//设置X轴、Y轴的显示位置
vCategoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
vCategoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
}
vCategoryPlot.setRenderer(vLineRenderer3D);
//背景表格线
vCategoryPlot.setDomainGridlinesVisible(true);
}
}
catch(Exception e)
{}
break;
case 14:
vFreeChart=ChartFactory.createGanttChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getIntervalCategoryDataset(),true,false,false);
break;
case 15:
vFreeChart=ChartFactory.createWaterfallChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getCategoryDataset(),PlotOrientation.VERTICAL,true,false,false);
try
{
vCategoryPlot=vFreeChart.getCategoryPlot();
if(vCategoryPlot!=null)
{
vWaterfallBarRenderer=new WaterfallBarRenderer();
vWaterfallBarRenderer.setBaseOutlinePaint(Color.GRAY);
if(bRender)
{
//设置柱颜色
if(strCategoryArray.length>0)
{
for(int iIndex=0;iIndex<strCategoryArray.length;iIndex++)
{
vWaterfallBarRenderer.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));
vWaterfallBarRenderer.setSeriesFillPaint(iIndex,new Color(0,0+iIndex*(255/strCategoryArray.length),255));
vWaterfallBarRenderer.setSeriesOutlinePaint(0,Color.BLACK);
}
}
//设置X轴、Y轴的显示位置
vCategoryPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
vCategoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
}
vCategoryPlot.setRenderer(vWaterfallBarRenderer);
//背景表格线
vCategoryPlot.setDomainGridlinesVisible(true);
//设置区域透明度
vCategoryPlot.setForegroundAlpha(0.5f);
}
}
catch(Exception e)
{}
break;
case 16:
vFreeChart=ChartFactory.createPolarChart(strFreeChartInfo,this.getXYDataset(),true,false,false);
break;
case 17:
vFreeChart=ChartFactory.createScatterPlot(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getXYDataset(),PlotOrientation.VERTICAL,true,false,false);
break;
case 18:
vFreeChart=ChartFactory.createXYBarChart(strFreeChartInfo,strFreeChartXInfo,false,strFreeChartYInfo,this.getIntervalXYDataset(),PlotOrientation.VERTICAL,true,false,false);
break;
case 19:
vFreeChart=ChartFactory.createXYAreaChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getXYDataset(),PlotOrientation.VERTICAL,true,false,false);
break;
case 20:
vFreeChart=ChartFactory.createStackedXYAreaChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getTableXYDataset(),PlotOrientation.VERTICAL,true,false,false);
break;
case 21:
vFreeChart=ChartFactory.createXYLineChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getXYDataset(),PlotOrientation.VERTICAL,true,false,false);
try
{
vXYPlot=(XYPlot)vFreeChart.getXYPlot();
if(vXYPlot!=null)
{
vXYItemRenderer=vXYPlot.getRenderer();
vXYItemRenderer.setBaseOutlinePaint(Color.GRAY);
if(bRender)
{
//设置线面颜色
if(strItemArray.length>0)
{
for(int iIndex=0;iIndex<strItemArray.length;iIndex++)
{
vXYItemRenderer.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strItemArray.length),255));
vXYItemRenderer.setSeriesOutlinePaint(0,Color.BLACK);
}
}
//设置X轴、Y轴的显示位置
vXYPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
vXYPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
}
//设置线条颜色
vXYItemRenderer.setPaint(new Color(0,100,255));
vXYPlot.setRenderer(vXYItemRenderer);
//背景表格线
vXYPlot.setDomainGridlinesVisible(true);
}
}
catch(Exception e)
{}
break;
case 22:
vFreeChart=ChartFactory.createXYStepChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getXYDataset(),PlotOrientation.VERTICAL,true,false,false);
break;
case 23:
vFreeChart=ChartFactory.createXYStepAreaChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getXYDataset(),PlotOrientation.VERTICAL,true,false,false);
break;
case 24:
vFreeChart=ChartFactory.createTimeSeriesChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getXYDataset(),true,false,false);
try
{
vXYPlot=(XYPlot)vFreeChart.getXYPlot();
if(vXYPlot!=null)
{
vXYItemRenderer=vXYPlot.getRenderer();
vXYItemRenderer.setBaseOutlinePaint(Color.GRAY);
if(bRender)
{
//设置线面颜色
if(strItemArray.length>0)
{
for(int iIndex=0;iIndex<strItemArray.length;iIndex++)
{
vXYItemRenderer.setSeriesPaint(iIndex,new Color(0,0+iIndex*(255/strItemArray.length),255));
vXYItemRenderer.setSeriesOutlinePaint(0,Color.BLACK);
}
}
//设置X轴、Y轴的显示位置
vXYPlot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
vXYPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
//设置线条颜色
vXYItemRenderer.setPaint(new Color(0,100,255));
vXYPlot.setRenderer(vXYItemRenderer);
}
//背景表格线
vXYPlot.setDomainGridlinesVisible(true);
SimpleDateFormat vSimpleDateFormat=null;
if(strTimeAxis.equals("Hour"))
{
vSimpleDateFormat=new SimpleDateFormat("dd日HH点");
}
else
{
vSimpleDateFormat=new SimpleDateFormat("MM月dd日");
}
vDateAxis=(DateAxis)vXYPlot.getDomainAxis();
vDateAxis.setDateFormatOverride(vSimpleDateFormat);
}
}
catch(Exception e)
{}
break;
case 25:
vFreeChart=ChartFactory.createCandlestickChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getOHLCDataset(),true);
break;
case 26:
vFreeChart=ChartFactory.createHighLowChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getOHLCDataset(),true);
break;
case 27:
vFreeChart=ChartFactory.createHighLowChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getOHLCDataset(),true);
break;
case 28:
//vFreeChart=ChartFactory.createCandlestickChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getSignalsDataset(),true);
break;
case 29:
vFreeChart=ChartFactory.createBubbleChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getXYZDataset(),PlotOrientation.VERTICAL,true,false,false);
break;
case 30:
vFreeChart=ChartFactory.createHistogram(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getIntervalXYDataset(),PlotOrientation.VERTICAL,true,false,false);
break;
case 31:
vFreeChart=ChartFactory.createBoxAndWhiskerChart(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getBoxAndWhiskerXYDataset(),true);
break;
case 32:
vFreeChart=ChartFactory.createWindPlot(strFreeChartInfo,strFreeChartXInfo,strFreeChartYInfo,this.getWindDataset(),true,false,false);
break;
case 33:
vFreeChart=ChartFactory.createWaferMapChart(strFreeChartInfo,this.getWaferMapDataset(),PlotOrientation.VERTICAL,true,false,false);
break;
default:
vFreeChart=ChartFactory.createPieChart(strFreeChartInfo,this.getPieDataset(),true,false,false);
break;
}
//图表背景颜色
vFreeChart.setBackgroundPaint(new Color(212,234,243));
}
public JFreeChart getChart()
{
return this.vFreeChart;
}
public void createImageFile(int iWidth,int iHeight,HttpSession session)
{
try
{
java.util.Date vDate=new java.util.Date(System.currentTimeMillis());
java.text.SimpleDateFormat vSimpleDateFormat=new SimpleDateFormat("yyyyMMddHHmmss");
java.util.Date vFileDate=null;
File[] vFileList=(new File(session.getServletContext().getRealPath("/"))).listFiles();
for(int kIndex=0;kIndex<vFileList.length;kIndex++)
{
if(vFileList[kIndex].isFile())
{
if(vFileList[kIndex].getName().indexOf(".jpg")!=-1)
{
vFileDate=vSimpleDateFormat.parse(vFileList[kIndex].getName().substring(0,vFileList[kIndex].getName().length()-4));
//十分钟前的临时文件删除
if(vDate.getTime()-vFileDate.getTime()>60*10*1000)
{
vFileList[kIndex].delete();
}
}
}
}
String strTime=vSimpleDateFormat.format(vDate);
strFileName=session.getServletContext().getRealPath("/")+"http://www.java-asp.net/java/200601/\\"+strTime+".jpg";
ChartUtilities.saveChartAsJPEG(new File(strFileName),100,this.getChart(),iWidth,iHeight);
strFileName="/"+getApplicationName(session.getServletContext().getRealPath("/"))+"/"+strTime+".jpg";
}
catch(Exception e)
{}
}
public String getImageFile()
{
return this.strFileName;
}
public String getApplicationName(String strRealPath)
{
String[] strAppArray=strRealPath.split("\\\\");
return strAppArray[strAppArray.length-1];
}
public boolean getRender()
{
return bRender;
}
public void setRender(boolean bRender)
{
this.bRender=bRender;
}
public String getTimeAxis()
{
return this.strTimeAxis;
}
public void setTimeAxis(String strTimeAxis)
{
this.strTimeAxis=strTimeAxis;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -