jfreechart如何让两条线用同一个x轴。
publicclassTest2extendsApplicationFrame{publicTest2(Strings){super(s);}privatestaticC...
public class Test2 extends ApplicationFrame{
public Test2(String s){
super(s);
}
private static CategoryDataset createDataset(){
DefaultCategoryDataset defaultcategorydataset=new DefaultCategoryDataset();
defaultcategorydataset.addValue(3000, "销售收入", "10%(3000)");
defaultcategorydataset.addValue(6500, "销售收入", "25%(6500)");
defaultcategorydataset.addValue(14700, "销售收入", "50%(14700)");
defaultcategorydataset.addValue(37300, "销售收入", "75%(37300)");
defaultcategorydataset.addValue(113700, "销售收入", "90%(113700)");
defaultcategorydataset.addValue(2000, "总收入", "10%(2000)");
defaultcategorydataset.addValue(4000, "总收入", "25%(4000)");
defaultcategorydataset.addValue(8000, "总收入", "50%(8000)");
defaultcategorydataset.addValue(11000, "总收入", "75%(11000)");
defaultcategorydataset.addValue(123000, "总收入", "90%(123000)");
return defaultcategorydataset;
}
public static void main(String args[]) throws IOException{
CategoryDataset dataset=createDataset();
JFreeChart jfreechart=ChartFactory.createLineChart("白酒企业销售收入图","分位点","销售收入",dataset,PlotOrientation.VERTICAL,true,false,false);
jfreechart.setBackgroundPaint(Color.white);
CategoryPlot categoryplot=(CategoryPlot)jfreechart.getPlot();
categoryplot.setBackgroundPaint(Color.lightGray);
categoryplot.setRangeGridlinePaint(Color.white);
NumberAxis numberaxis=(NumberAxis)categoryplot.getRangeAxis();
numberaxis.setAutoRangeIncludesZero(true);
LineAndShapeRenderer lineandshaperenderer=(LineAndShapeRenderer)categoryplot.getRenderer();
lineandshaperenderer.setShapesVisible(true);
lineandshaperenderer.setSeriesStroke(2, new BasicStroke(2.0F,1,1,1.0F,new float[]{10F,6F},0.0F));
FileOutputStream fos_jpg=null;
try{
fos_jpg=new FileOutputStream("D:/fruit.jpg");
ChartUtilities.writeChartAsJPEG(fos_jpg,0.8f,jfreechart,600,400,null);
}catch(Exception ex){
System.out.println(ex.getMessage());
}finally{
fos_jpg.close();
}
}
}
生成的图片中两条线虽然是共用一个X轴,但是不共用X轴的值,怎么才能解决这个问题。另外怎么才能让折点的数值在图中显示出来?? 展开
public Test2(String s){
super(s);
}
private static CategoryDataset createDataset(){
DefaultCategoryDataset defaultcategorydataset=new DefaultCategoryDataset();
defaultcategorydataset.addValue(3000, "销售收入", "10%(3000)");
defaultcategorydataset.addValue(6500, "销售收入", "25%(6500)");
defaultcategorydataset.addValue(14700, "销售收入", "50%(14700)");
defaultcategorydataset.addValue(37300, "销售收入", "75%(37300)");
defaultcategorydataset.addValue(113700, "销售收入", "90%(113700)");
defaultcategorydataset.addValue(2000, "总收入", "10%(2000)");
defaultcategorydataset.addValue(4000, "总收入", "25%(4000)");
defaultcategorydataset.addValue(8000, "总收入", "50%(8000)");
defaultcategorydataset.addValue(11000, "总收入", "75%(11000)");
defaultcategorydataset.addValue(123000, "总收入", "90%(123000)");
return defaultcategorydataset;
}
public static void main(String args[]) throws IOException{
CategoryDataset dataset=createDataset();
JFreeChart jfreechart=ChartFactory.createLineChart("白酒企业销售收入图","分位点","销售收入",dataset,PlotOrientation.VERTICAL,true,false,false);
jfreechart.setBackgroundPaint(Color.white);
CategoryPlot categoryplot=(CategoryPlot)jfreechart.getPlot();
categoryplot.setBackgroundPaint(Color.lightGray);
categoryplot.setRangeGridlinePaint(Color.white);
NumberAxis numberaxis=(NumberAxis)categoryplot.getRangeAxis();
numberaxis.setAutoRangeIncludesZero(true);
LineAndShapeRenderer lineandshaperenderer=(LineAndShapeRenderer)categoryplot.getRenderer();
lineandshaperenderer.setShapesVisible(true);
lineandshaperenderer.setSeriesStroke(2, new BasicStroke(2.0F,1,1,1.0F,new float[]{10F,6F},0.0F));
FileOutputStream fos_jpg=null;
try{
fos_jpg=new FileOutputStream("D:/fruit.jpg");
ChartUtilities.writeChartAsJPEG(fos_jpg,0.8f,jfreechart,600,400,null);
}catch(Exception ex){
System.out.println(ex.getMessage());
}finally{
fos_jpg.close();
}
}
}
生成的图片中两条线虽然是共用一个X轴,但是不共用X轴的值,怎么才能解决这个问题。另外怎么才能让折点的数值在图中显示出来?? 展开
1个回答
展开全部
#include<string.h>
#include<stdio.h>
#include<iostream.h>
string str(string &strn);
main()
{
int a;
string str1 = "string1aaa",str3 ;
str3 = str(str1);
cout<<str1<<endl<<str3<<endl;
cin>>a;
}
string str(string &strn)
{
return(strn);
}
#include<stdio.h>
#include<iostream.h>
string str(string &strn);
main()
{
int a;
string str1 = "string1aaa",str3 ;
str3 = str(str1);
cout<<str1<<endl<<str3<<endl;
cin>>a;
}
string str(string &strn)
{
return(strn);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询