- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
构建 XSSFScatterChartData
并使用方法 XSSFChart.plot(ChartData data, ChartAxis...chartAxis)
填充它后,该图包含标记,但通过线..
我认为问题来自于默认设置 STScatterStyle.LINE_MARKER
的方法 XSSFScatterChartData.addStyle
。
这是我用来生成图表的方法的副本:
private void setTrainingTimeGraph(Sheet trainingTimeSheet, Sheet resultsSheet) {
Drawing drawing = trainingTimeSheet.createDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 5, 5, 20, 30);
XSSFChart chart = (XSSFChart) drawing.createChart(anchor);
ChartLegend legend = chart.getOrCreateLegend();
legend.setPosition(LegendPosition.TOP_RIGHT);
chart.setTitleText("Training time over Fscore");
XSSFScatterChartData data = chart.getChartDataFactory().createScatterChartData();
ValueAxis bottomAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
setValueAxisTitle((XSSFChart) chart,0,"Fscore");
setValueAxisTitle((XSSFChart) chart,1, "Training Time");
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
bottomAxis.setCrosses(AxisCrosses.AUTO_ZERO);
ChartDataSource<Number> xs = DataSources.fromNumericCellRange(resultsSheet, new CellRangeAddress(16, 29, 10, 10));
ChartDataSource<Number> ys = DataSources.fromNumericCellRange(resultsSheet, new CellRangeAddress(16, 29, 18, 18));
data.addSerie(xs, ys);
chart.plot(data,bottomAxis, leftAxis);
}
因此添加 @AxelRichter 代码以在我的散点图数据系列中设置为不填充:
...
data.addSerie(xs, ys);
chart.plot(data,bottomAxis, leftAxis);
//set line properties of first scatter chart data serie to no fill:
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.addNewSpPr().addNewLn().addNewNoFill();
我设法摆脱了连接标记的线..终于!
但第二部分不是我想要的。让我更好地解释一下:
当我将鼠标悬停在散点图中的每个点时,会弹出一些文本(“label/x_value”
,x_value
,y_value
)。图例中的值与其“label/x_value”
相同。我想为每个数据点和图例中的每个值设置其“label/x_value”
。
提前致谢!
最佳答案
Excel
散点图的标记之间也始终有线条。如果您不想看到这条线,则必须将其填充颜色设置为无填充。
引用文献: CTScatterSer -> CTShapeProperties -> CTLineProperties -> CTLineProperties.addNewNoFill
为了拥有数据标签,该系列需要 CTDLbl设置。
完整示例:
import java.io.FileOutputStream;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.charts.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFChart;
import org.apache.poi.ss.util.CellRangeAddress;
public class CreateExcelScatterChart {
public static void main(String[] args) throws Exception {
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("chart");
final int NUM_OF_ROWS = 2;
final int NUM_OF_COLUMNS = 20;
Row row;
Cell cell;
for (int rowIndex = 0; rowIndex < 1; rowIndex++) {
row = sheet.createRow((short) rowIndex);
for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) {
cell = row.createCell((short) colIndex);
cell.setCellValue(4*colIndex * (rowIndex + 1));
}
}
for (int rowIndex = 1; rowIndex < NUM_OF_ROWS; rowIndex++) {
row = sheet.createRow((short) rowIndex);
for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) {
cell = row.createCell((short) colIndex);
cell.setCellValue(Math.sin(Math.PI*colIndex/10*2));
}
}
Drawing<?> drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 3, 13, 20);
Chart chart = drawing.createChart(anchor);
ChartLegend legend = chart.getOrCreateLegend();
legend.setPosition(LegendPosition.TOP_RIGHT);
ScatterChartData data = chart.getChartDataFactory().createScatterChartData();
ValueAxis bottomAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
bottomAxis.setCrosses(AxisCrosses.AUTO_ZERO);
ChartDataSource<Number> xs = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1));
ChartDataSource<Number> ys1 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1));
ScatterChartSeries chartSerie = data.addSerie(xs, ys1);
chartSerie.setTitle("My Title");
chart.plot(data, bottomAxis, leftAxis);
//set line properties of first scatter chart data serie to no fill:
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.addNewSpPr().addNewLn().addNewNoFill();
//set data labels for first scatter chart data serie
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.addNewDLbls()
.addNewNumFmt().setFormatCode("0.0");
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.getDLbls().getNumFmt()
.setSourceLinked(false);
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.getDLbls()
.addNewShowLegendKey().setVal(false);
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.getDLbls()
.addNewShowCatName().setVal(false);
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.getDLbls()
.addNewShowSerName().setVal(false);
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.getDLbls()
.addNewShowPercent().setVal(false);
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.getDLbls()
.addNewShowBubbleSize().setVal(false);
((XSSFChart)chart).getCTChart().getPlotArea().getScatterChartArray(0).getSerArray(0)
.getDLbls()
.addNewShowVal().setVal(true);
wb.write(new FileOutputStream("CreateExcelScatterChart.xlsx"));
wb.close();
}
}
此代码需要所有架构 ooxml-schemas-1.3.jar
的完整 jar,如 FAQ-N10025 中所述。 .
此代码使用当前最新的稳定版本 apache poi
版本 3.17
运行。注意:apache poi
的 Chart
代码目前正在高度开发中。因此该代码可能无法在以后的版本中工作。
关于java - ScatterChart 使用 LineMarker 作为 ScatterStyle 而不是仅使用 Marker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49690471/
我有一个名为 AnimalMarker 的类,它应该代表普通谷歌地图标记(纬度、经度、位置)和动物对象的最低限度。我正在使用 Firebase 实时数据库来存储这些 AnimalMarkers。 我想
我正在尝试创建一个准确的标记跟踪设备。我找到了 charuco 记号笔和钻石记号笔。 我能够通过charuco得到一个很好的校准结果。 现在,我必须将 3d 模型放在正确的位置。在我学习的过程中,我可
我有一张 map ,上面有根据数据库中的值以编程方式放置的标记。当您单击标记时,它将转到该位置的详细信息页面。 我的问题是,本地图充分缩小时,彼此足够接近的标记会显示为单个标记,实际上隐藏了一些标记。
所以我有一个带有很多标记的 MapView,其中大部分都集中在一英里宽的集群中。缩放时,标记重叠并且看起来只有一个。我想要实现的是在某个缩放级别将重叠标记替换为将显示标记密度的组标记,并且 onCli
我的编程非常基础,并且只需要针对一个特定项目的该选项。我很想通过单击不同的标记来更改一个主弹出窗口的内容。问题是,我不知道如何使用 .on('dblclick') 我的标记来获取不同标记上弹出窗口的
目前正在将一个使用 Google map 的 Android 应用程序迁移到 Google Maps Android v2;我希望 map 显示内置位置标记以及自定义标记。在以前的库中,我曾经在自定义
我喜欢使用 Google map 创建可以处理大量标记(超过 10,000 个)的 map 。为了不减慢 map 速度,我创建了一个 XML 文件,它只输出当前视口(viewport)内的标记。 首先
我有要在 map 中呈现的标记列表,但我想要一个一个地显示。第一次点击我想制作新的标记。然后当我点击另一个位置时,我希望我的标记只移动到新的 latLng 而不是创建另一个标记。这是我的代码: fun
有时在 Eclipse 中使用“Source > Sort Members”时,我会收到此警告消息。我假设“标记”指的是 these ,但是是什么造就了它们? 我不会手动制作它们。插件、FindBug
我有一张带有几种不同类型图标的 Google map 。我在每个图标上都有一个阴影。如何调整标记阴影与标记的偏移量? 在构建每个标记的循环中,我有: var icon = customIcons[ty
我发现下面的函数只创建一个标记 - 这正是我想要的。但是如何更改标记选项,例如html - 不创建一个新的? 即下面的代码将使用 setPosition 移动现有标记,但如果我还想更改其 html 和
当我使用 marker.setMap(null) 删除标记时,它一直可见,直到我缩小,此时 Google map 将其删除。 在与 Windows 上的 Chrome 相同的 HTML 页面上删除后,
我有一个弹出表单,当单击传单 map 中的某些标记时会出现该表单。表单完成后,我想将输入的字段以及有关标记的一些详细信息发送到单独的函数。我现在开始只是发送标记来测试它,但遇到了问题。 但是当我通过函
更新:我已经通过添加一个 previousMarker 对象解决了性能问题。因此只有之前点击的标记会被删除并替换为默认图标。然而,当我点击标记时,信息窗口仍然没有显示。 我有一个 map View 并
我正在使用 videojs-marker 插件 ( http://www.sampingchuang.com/videojs-markers ) 来构建一个自定义播放器,用户可以通过它来注释(命名一个
我想知道,免费版本...我可以绘制更多默认标记(来自 maps.google.com)。点击后会提供输入行车路线和其他从谷歌搜索的商家信息(例如:评论)的选项。 最佳答案 可以通过向信息窗口添加链接来
我想清除 Google map 上的标记。 marker.setVisible(false) 和有什么区别和 marker.setMap(null) ? 但我不知道,哪个是正确的? 最佳答案 这两种方
我正在使用 react-native-maps 但是我遇到了一个问题,在谷歌搜索了很多没有答案之后我不得不在这里问。我正在尝试使用自定义标记作为 map 中的标记,如下图所示 我在搜索中发现需要使用C
我在我的 Rails 应用程序中使用 Gmaps4Rails 加载谷歌地图。一切正常。我有一个标记,我想在加载谷歌地图时默认打开信息窗口(不点击标记)。请帮助我如何使用 Gmaps4Rails gem
我需要使用 Jackson 反序列化一个 json 对象. 经过多次努力和上网搜索,一切努力解决错误: Exception in thread "main" com.fasterxml.jackson
我是一名优秀的程序员,十分优秀!