- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
据我所知,DateTickUnitType 是一个无法在完全替换之外扩展或更改的枚举,它只指定天、月、年、分钟、小时、秒和毫秒的单位,但不是周,尽管有一个TimePeriod 的周类型。
这导致的问题是,当我被迫使用 DAY 刻度单位绘制一周的单个数据点时,与在 DAY 刻度单位或每月数据上绘制每日点相比,我的条形宽度非常窄指向 MONTH 刻度单位。
根据我的数据范围(我以编程方式计算),我创建了具有最合适的 TimePeriod 的 TimeSeriesDataItem:
// create the correct TimeSeriesDataItem based on the gap of this data set
switch (gap) {
case WEEK:
item = new TimeSeriesDataItem(new Week(targetDate.getTime()), dataPoint);
break;
case DAY:
item = new TimeSeriesDataItem(new Day(targetDate.getTime()), dataPoint);
break;
case MONTH:
default:
item = new TimeSeriesDataItem(new Month(targetDate.getTime()), dataPoint);
break;
}
然后在构建图表后,我尝试对其进行自定义,使每个数据点的条形尽可能宽。如果数据是天,则刻度单位是天。如果数据是月,则刻度单位是月。但如果数据以周为单位,那么由于没有周滴答单位,我不得不选择以天或月为单位。
JFreeChart barChart = ChartFactory.createXYBarChart(
model.getTitle(),
model.getDomainTitle(),
true,
model.getRangeTitle(),
dataset,
model.getOrientation() == SimpleBarChartModel.Orientation.VERTICAL ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL,
model.getShowLegend(),
false,
false);
// ...
DateAxis domainAxis = (DateAxis)plot.getDomainAxis();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
if (model.getDomainLabels() != null && model.getDomainLabels().size() > 1) {
// create three different sets of TickUnits for the three ranges (day, week, month)
// JFreeChart will select the smallest unit that doesn't overlap labels.
TickUnits tickUnits = new TickUnits();
tickUnits.add(new DateTickUnit(DateTickUnitType.MONTH, 1, new SimpleDateFormat("MMM")));
tickUnits.add(new DateTickUnit(DateTickUnitType.DAY, 7, dateFormat));
tickUnits.add(new DateTickUnit(DateTickUnitType.DAY, 1, dateFormat));
domainAxis.setStandardTickUnits(tickUnits);
}
domainAxis.setAutoRange(true);
domainAxis.setVerticalTickLabels(true);
domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
前者创建非常细的条形图,因为它每个刻度单位绘制 7 列。
有什么方法可以让我为 WEEK 制作一个自定义 DateTickUnitType,这样我每周只绘制一个点而不是 7 个(因为我只有一个数据点)?
最佳答案
关于jfreechart - 在 JFreeChart 中为一周的单位创建自定义 DateTickUnitType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8010663/
我需要从图例中隐藏第二/第三/第四项。有没有办法在jFreeChart中实现这一目标? 谢谢! 最佳答案 我已经尝试了上述建议,但似乎对我没有用。如果您只想从图例中删除系列,则可以使用setSerie
我对 JFreeChart 中的异常值规则有一些疑问: 是否可以影响 JFreeChart 箱线图中的异常值规则? 我假设异常值的默认设置是 Q3+1.5*IQR 和 Q1-1.5*IQR? 对于 Q
使用的 JFreeChart 版本:1.5.0 我尝试了以下方法来获得散点图中的空心形状: PlotFrame.java文件内容: package javaapplication1; import j
如何自定义 JFreeChart 图形的颜色。 让我们看看我的 Java 代码: private StreamedContent chartImage ; public void init(){
在 JFreeChart , 是否可以将图例嵌入图表本身? 图例可以设置在图表的顶部、底部、左侧、右侧,如下所示,但是否可以将其嵌入图表中? LegendTitle legend=chart.getL
大家好,我是 jfreechart 的新手。 我想删除为 jfreechart 中的折线图图表面板的标题分配的空间。 因为我需要将图表面板的高度和宽度设置为包含图表面板的顶部面板的 10 像素边框。
在 JFreeChart 图形中,如果调整应用程序窗口的大小,图形将根据应用程序窗口大小重新绘制。是否可以将图表大小设置为固定值? 最佳答案 好。 我想建议一种不同的方法。不用担心在 jfreecha
我在 JFreeChart 中创建了一个饼图。但是,数值没有出现在“切片”上。我如何让它出现在那里? 最佳答案 在 PiePlot 上,可以使用 setter setSimpleLabels。 假设您
我正在使用 JFreeChart 生成 StackedBarChart。根据输入数据,我可以有很多类别(通常在 20 到 40 之间),导致标签重叠。在下面的屏幕截图中,您可以看到类别从 1 到 38
我正在尝试实现 a timeseries chart在 JFreeChart 中有一个特殊的要求。我可以绘制图表,但我不知道如何在图表中的最后一个值处实现垂直红线。它应该始终在同一个位置,并且应该始终
如何在 jfreechart 中加粗 x 和 y 轴值? 最佳答案 你试过其中之一吗: yourAxis.setTickLabelFont(new Font("Arial", Font.BOLD, 1
据我所知,DateTickUnitType 是一个无法在完全替换之外扩展或更改的枚举,它只指定天、月、年、分钟、小时、秒和毫秒的单位,但不是周,尽管有一个TimePeriod 的周类型。 这导致的问题
我需要使用 JFreeChart 生成图表然后使用 Apache PDFBOX 将它们导出为 PDF .我不想使用 iText,因为它不能用于专有软件。 我搜索了整个 Google,但没有成功!有人做
我刚刚发现,当我将 ChartPanel 添加到 JFrame 时,当 JFrame 拖动更大或更小时,ChartPanel 将调整大小以适应框架。但是,当我将 ChartPanel 添加到 JPan
我是 Java 新手,正在尝试掌握 JFreeChart。我正在尝试从该网站运行一些演示代码:https://www.tutorialspoint.com/jfreechart/jfreechart_
我正在尝试使用 DefaultCategoryDataset 绘制 LineChart 并且我面临的问题是, 当我尝试在两个值之间绘制一个空值时,两个点之间的连接丢失(即没有出现连接两个点的线),或者
是否可以将图像/BufferedImage 转换为 JFreeChart? 最佳答案 将图像转换到 JFree 是不可能的。要从 JFreechart 创建图像,您可以执行以下操作: Buffered
有人知道如何在Jfreechart中在给定坐标处绘制垂直虚线吗? 谢谢 最佳答案 Example 5显示图表的一系列虚线。这样设置您的行程: plot.getRenderer().setSeriesS
如我在图片中所示,我想将列标签(值 434、2562,....)稍微向上移动。有什么方法可以配置吗?我最初的问题是,由于列之间的差异,最后两列上的标签不再可见(它们实际上是 15 和 24 或类似的
如本模型所示: 我知道可以使用 org.jfree.chart.plot.CombinedDomainXYPlot 使图表彼此相邻显示,但是是否可以将它们重叠,可能使用不同的 Y 轴(一个)用于图表左
我是一名优秀的程序员,十分优秀!