如何在JFreechart中的CategoryPlot(使用createStackedAreaChart()方法)中为x轴使用DateAxis

如何在JFreechart中的CategoryPlot(使用createStackedAreaChart()方法)中为x轴使用DateAxis,date,format,jfreechart,stacked-area-chart,Date,Format,Jfreechart,Stacked Area Chart,我使用值和日期轴生成了一个stackedAreaChart,它生成的很好,但我不想显示每个日期,因为它看起来不好,或者不可能长时间显示每个日期。 这是我的密码: ArrayList al_Main = (ArrayList)xyChartDetails.get("totalAlist"); ArrayList relativePriceMvmtOn = (ArrayList)xyChartDetails.get("recordName"); String strLegendMsg=(String

我使用值和日期轴生成了一个
stackedAreaChart
,它生成的很好,但我不想显示每个日期,因为它看起来不好,或者不可能长时间显示每个日期。 这是我的密码:

ArrayList al_Main = (ArrayList)xyChartDetails.get("totalAlist");
ArrayList relativePriceMvmtOn = (ArrayList)xyChartDetails.get("recordName");
String strLegendMsg=(String)xyChartDetails.get("LegendMsg");
String strFileName=(String)xyChartDetails.get("FileName");
String series = null;
String temp =null;
final CategoryDataset dataset =null;
double data[][]=null;
double date2[][]=null;
int height = 300;
int width = 750;
String xaxisLabel=(String)xyChartDetails.get("X-Axis");
String yaxisLabel=(String)xyChartDetails.get("Y-Axis");
SimpleDateFormat stformat = new SimpleDateFormat("dd-MMM-yyyy");
DefaultCategoryDataset line_chart_dataset = new DefaultCategoryDataset();
JFreeChart chart=null;
try{
    for(int i=0;i<al_Main.size();i++)
    {           
        series = (String)relativePriceMvmtOn.get(i);
        ArrayList al_under = (ArrayList) al_Main.get(i);
        String strName=null;
        double strVal=0.0;
        for(int j=0;j<al_under.size();j++)
        {
        temp=(String)al_under.get(j);
        if(temp != null) {
                strName=temp.substring(temp.indexOf(",")+1);

                strVal=Double.parseDouble(strName.substring(0,strName.indexOf("~")));

                String date =strName.substring(strName.indexOf("~")+1);

                    line_chart_dataset.addValue( strVal , series , df.parse(date) );

        }
        }
    }

    chart = createChart(line_chart_dataset,strLegendMsg,xaxisLabel,yaxisLabel);
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    final File file1 = new File(strFileName);       
    ChartUtilities.saveChartAsPNG(file1, chart, width , height, info);
任何线索都将不胜感激。 谢谢和问候, 贾维德·安萨里

public JFreeChart createChart(CategoryDataset dataset,String legendMsg,String xAxis,String yAxis) {

    final JFreeChart chart = ChartFactory.createStackedAreaChart(
            legendMsg,      // chart title
            xAxis,                // domain axis label
            yAxis,           // range axis label
        dataset,                   // data
        PlotOrientation.VERTICAL,  // orientation
        true,                      // include legend
        true,
        false
    );
    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(0.5f);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    //domainAxis.setTickLabelPaint(Color.white);


    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setItemLabelsVisible(true);
    //final DateAxis axis = (DateAxis) plot.getDomainAxis();
    //axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); 
    return chart;

}