JFreeChart生成的带状图 X轴 数据太密集怎么处理?求高手
主要代码如下publicstaticCategoryDatasetcreateDataset(){DefaultCategoryDatasetlocalDefaultCa...
主要代码如下
public static CategoryDataset createDataset() {
DefaultCategoryDataset localDefaultCategoryDataset = new DefaultCategoryDataset();
String[] chartname = { "备用容量", "符合计划", "临检容量", "检修容量" };
double[] value0 = { 1.0D, 2.0D, 3.0D, 4.0D };
String[] xtime = { "00:15", "00:30", "00:45", "01:00", "01:15",
"01:30", "01:45", "02:00", "02:15", "02:30", "02:45", "03:00",
"03:15", "03:30", "03:45", "04:00", "04:15", "04:30", "04:45",
"05:00", "05:15", "05:30", "05:45", "06:00", "06:15", "06:30",
"06:45", "07:00", "07:15", "07:30", "07:45", "08:00", "08:15",
"08:30", "08:45", "09:00", "09:15", "09:30", "09:45", "10:00",
"10:15", "10:30", "10:45", "11:00", "11:15", "11:30", "11:45",
"12:00", "12:15", "12:30", "12:45", "13:00", "13:15", "13:30",
"13:45", "14:00", "14:15", "14:30", "14:45", "15:00", "15:15",
"15:30", "15:45", "16:00", "16:15", "16:30", "16:45", "17:00",
"17:15", "17:30", "17:45", "18:00", "18:15", "18:30", "18:45",
"19:00", "19:15", "19:30", "19:45", "20:00", "20:15", "20:30",
"20:45", "21:00", "21:15", "21:30", "21:45", "22:00", "22:15",
"22:30", "22:45", "23:00", "23:15", "23:30", "23:45", "24:00" };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 96; j++) {localDefaultCategoryDataset.addValue(value0[i], chartname[i],
xtime[j]);
}
}
return localDefaultCategoryDataset;
}public static JFreeChart createChart(CategoryDataset paramCategoryDataset) {
JFreeChart localJFreeChart = ChartFactory.createStackedAreaChart(
"2011-1-24电力平衡(计划)", "时间", "容量", paramCategoryDataset,
PlotOrientation.VERTICAL, true, true, false);
CategoryPlot localCategoryPlot = (CategoryPlot) localJFreeChart
.getPlot();
localCategoryPlot.setForegroundAlpha(0.85F);
CategoryAxis localCategoryAxis = localCategoryPlot.getDomainAxis();
localCategoryAxis.setLowerMargin(0.0D);
localCategoryAxis.setUpperMargin(0.0D);
localCategoryAxis.setCategoryMargin(0.0D);
localCategoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); NumberAxis localNumberAxis = (NumberAxis) localCategoryPlot
.getRangeAxis();
localNumberAxis.setStandardTickUnits(NumberAxis
.createIntegerTickUnits());
CategoryItemRenderer localCategoryItemRenderer = localCategoryPlot
.getRenderer();
localCategoryItemRenderer.setBaseItemLabelsVisible(true);
return localJFreeChart;
}public static JPanel createDemoPanel() {
// JScrollPane jsp = new JScrollPane(StackedAreaChart.createDemoPanel());
JFreeChart localJFreeChart = createChart(createDataset());
return new ChartPanel(localJFreeChart);
}
public static void main(String[] paramArrayOfString) {
StackedAreaChart localStackedAreaChartDemo1 = new StackedAreaChart(
"电力平衡分析图");
localStackedAreaChartDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localStackedAreaChartDemo1);
loc........... 展开
public static CategoryDataset createDataset() {
DefaultCategoryDataset localDefaultCategoryDataset = new DefaultCategoryDataset();
String[] chartname = { "备用容量", "符合计划", "临检容量", "检修容量" };
double[] value0 = { 1.0D, 2.0D, 3.0D, 4.0D };
String[] xtime = { "00:15", "00:30", "00:45", "01:00", "01:15",
"01:30", "01:45", "02:00", "02:15", "02:30", "02:45", "03:00",
"03:15", "03:30", "03:45", "04:00", "04:15", "04:30", "04:45",
"05:00", "05:15", "05:30", "05:45", "06:00", "06:15", "06:30",
"06:45", "07:00", "07:15", "07:30", "07:45", "08:00", "08:15",
"08:30", "08:45", "09:00", "09:15", "09:30", "09:45", "10:00",
"10:15", "10:30", "10:45", "11:00", "11:15", "11:30", "11:45",
"12:00", "12:15", "12:30", "12:45", "13:00", "13:15", "13:30",
"13:45", "14:00", "14:15", "14:30", "14:45", "15:00", "15:15",
"15:30", "15:45", "16:00", "16:15", "16:30", "16:45", "17:00",
"17:15", "17:30", "17:45", "18:00", "18:15", "18:30", "18:45",
"19:00", "19:15", "19:30", "19:45", "20:00", "20:15", "20:30",
"20:45", "21:00", "21:15", "21:30", "21:45", "22:00", "22:15",
"22:30", "22:45", "23:00", "23:15", "23:30", "23:45", "24:00" };
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 96; j++) {localDefaultCategoryDataset.addValue(value0[i], chartname[i],
xtime[j]);
}
}
return localDefaultCategoryDataset;
}public static JFreeChart createChart(CategoryDataset paramCategoryDataset) {
JFreeChart localJFreeChart = ChartFactory.createStackedAreaChart(
"2011-1-24电力平衡(计划)", "时间", "容量", paramCategoryDataset,
PlotOrientation.VERTICAL, true, true, false);
CategoryPlot localCategoryPlot = (CategoryPlot) localJFreeChart
.getPlot();
localCategoryPlot.setForegroundAlpha(0.85F);
CategoryAxis localCategoryAxis = localCategoryPlot.getDomainAxis();
localCategoryAxis.setLowerMargin(0.0D);
localCategoryAxis.setUpperMargin(0.0D);
localCategoryAxis.setCategoryMargin(0.0D);
localCategoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); NumberAxis localNumberAxis = (NumberAxis) localCategoryPlot
.getRangeAxis();
localNumberAxis.setStandardTickUnits(NumberAxis
.createIntegerTickUnits());
CategoryItemRenderer localCategoryItemRenderer = localCategoryPlot
.getRenderer();
localCategoryItemRenderer.setBaseItemLabelsVisible(true);
return localJFreeChart;
}public static JPanel createDemoPanel() {
// JScrollPane jsp = new JScrollPane(StackedAreaChart.createDemoPanel());
JFreeChart localJFreeChart = createChart(createDataset());
return new ChartPanel(localJFreeChart);
}
public static void main(String[] paramArrayOfString) {
StackedAreaChart localStackedAreaChartDemo1 = new StackedAreaChart(
"电力平衡分析图");
localStackedAreaChartDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localStackedAreaChartDemo1);
loc........... 展开
2个回答
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询