In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "Java in PPT to create scatter plot what is the implementation method", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Java in PPT to create scatter chart what is the implementation method" it!
Before creating a chart
You need to import the jar package Free Spire.Presentation for Java, which is used to manipulate PPT, in the Java program. You can refer to the following two methods for import:
Method 1: import the jar package manually. You need to download the jar package locally, extract it, and find the jar file in the lib folder. Then follow these steps to import:
Method 2:maven warehouse download and import. You need to configure the maven repository path in the pom.xml file and specify dependencies. The configuration is as follows:
When com.e-iceblue https://repo.e-iceblue.cn/repository/maven-public/ e-iceblue spire.presentation.free 3.9.0 creates a chart
Insert the chart at the specified coordinate location in the slide by specifying the data source. The Jar package provides ShapeCollection.appendChart (ChartType type, Rectangle2D rectangle, boolean init) methods to add specific types of charts to slides, and the ChartType enumeration predefines 73 chart types, including but not limited to scatter charts, column charts, pie charts, and so on.
The creation of a scatter chart is mainly accomplished through the following steps:
Create an instance of the Presentation class.
Use the ShapeCollection.appendChart () method to attach a scatter chart to a specific slide.
Set the chart data through the ChartData.get (). SetValue () method.
Use the method provided by IChart interface to set chart title, axis title, series label, and so on.
Set gridline style and data dotted line style.
Use the Presentation.saveToFile () method to save the document to the specified path.
Java code example
Import com.spire.presentation.FileFormat;import com.spire.presentation.Presentation;import com.spire.presentation.SlideSizeType;import com.spire.presentation.TextLineStyle;import com.spire.presentation.charts.ChartType;import com.spire.presentation.charts.IChart;import com.spire.presentation.charts.entity.ChartDataLabel;import com.spire.presentation.drawing.FillFormatType;import java.awt.*;import java.awt.geom.Rectangle2D Public class ScatterChart {public static void main (String [] args) throws Exception {/ / create an instance of the Presentation class Presentation presentation = new Presentation (); presentation.getSlideSize () .setType (SlideSizeType.SCREEN_16_X_9) / / add the scatter chart to the first slide IChart chart = presentation.getSlides (). Get (0). GetShapes (). AppendChart (ChartType.SCATTER_MARKERS,new Rectangle2D.Float (180,80,550,320), false); / / set the chart title chart.getChartTitle (). GetTextProperties (). SetText ("scatter chart"); chart.getChartTitle (). GetTextProperties (). IsCentered (true) Chart.getChartTitle (). SetHeight (20f); chart.hasTitle (true); / / set the chart data source Double [] xData = new Double [] {1.0,2.4,5.0,8.9}; Double [] yData = new Double [] {5.3,15.2, 6.7,8.0}; chart.getChartData (). Get (0d0) .setText ("X-value") Chart.getChartData (). Get (0jue 1). SetText ("Y-value"); for (int I = 0; I)
< xData.length; i++) { chart.getChartData().get(i+1,0).setValue(xData[i]); chart.getChartData().get(i+1,1).setValue(yData[i]); } //设置系列标签 chart.getSeries().setSeriesLabel(chart.getChartData().get("B1","B1")); //设置X和Y轴值 chart.getSeries().get(0).setXValues(chart.getChartData().get("A2","A5")); chart.getSeries().get(0).setYValues(chart.getChartData().get("B2","B5")); //添加数据标签 for (int i = 0; i < 4; i++) { ChartDataLabel dataLabel = chart.getSeries().get(0).getDataLabels().add(); dataLabel.setLabelValueVisible(true); } //设置主轴标题和次轴标题 chart.getPrimaryValueAxis().hasTitle(true); chart.getPrimaryValueAxis().getTitle().getTextProperties().setText("X-轴 标题"); chart.getSecondaryValueAxis().hasTitle(true); chart.getSecondaryValueAxis().getTitle().getTextProperties().setText("Y-轴 标题"); //设置网格线 chart.getSecondaryValueAxis().getMajorGridTextLines().setFillType(FillFormatType.SOLID); chart.getSecondaryValueAxis().getMajorGridTextLines().setStyle(TextLineStyle.THIN_THIN); chart.getSecondaryValueAxis().getMajorGridTextLines().getSolidFillColor().setColor(Color.GRAY); chart.getPrimaryValueAxis().getMajorGridTextLines().setFillType(FillFormatType.NONE); //设置数据点线 chart.getSeries().get(0).getLine().setFillType(FillFormatType.SOLID); chart.getSeries().get(0).getLine().setWidth(0.1f); chart.getSeries().get(0).getLine().getSolidFillColor().setColor(Color.BLUE); //保存文档 presentation.saveToFile("ScatterChart.pptx", FileFormat.PPTX_2013); presentation.dispose(); }} 图表效果图:Thank you for your reading, the above is the "Java in PPT to create scatter plot of what is the implementation method" of the content, after the study of this article, I believe you on the Java in PPT to create scatter plot of what is the realization of this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.