欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java 在PPT中添加混合圖表過程詳解

 更新時(shí)間:2019年09月18日 08:28:42   作者:Miaonly  
這篇文章主要介紹了Java 在PPT中添加混合圖表過程詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

本文將介紹通過Java程序在PPT幻燈片中添加混合圖表的方法,即,將不同類型的圖表類型放置在同一圖表中,用于展示同一時(shí)期或階段的數(shù)據(jù)在不同參數(shù)標(biāo)準(zhǔn)下的變化情況,便于對數(shù)據(jù)的綜合分析。

使用工具:Free Spire.Presentation for Java(免費(fèi)版)

Jar文件獲取及導(dǎo)入:

方法1:通過官網(wǎng)下載jar文件包。下載后,解壓文件,并將lib文件夾下的Spire.Presentation.jar導(dǎo)入java程序。參考如下導(dǎo)入效果:

方法2:通過maven倉庫安裝導(dǎo)入??蓞⒖?a target="_blank" href="http://www.dbjr.com.cn/article/164716.htm">導(dǎo)入方法。

Java代碼示例(供參考)

import com.spire.presentation.*;
import com.spire.presentation.charts.ChartType;
import com.spire.presentation.charts.IChart;
import com.spire.presentation.drawing.FillFormatType;
import java.awt.geom.Rectangle2D;
public class Chart {
  public static void main(String[] args) throws Exception{
    //創(chuàng)建PowerPoint文檔
    Presentation presentation = new Presentation();

    //添加一個(gè)柱狀圖
    Rectangle2D.Double rect = new  Rectangle2D.Double(60, 100, 600, 350);
    IChart chart = presentation.getSlides().get(0).getShapes().appendChart(ChartType.COLUMN_CLUSTERED, rect);

    //設(shè)置圖表名稱
    chart.getChartTitle().getTextProperties().setText("上半年銷量");
    chart.getChartTitle().getTextProperties().isCentered(true);
    chart.getChartTitle().setHeight(30);
    chart.hasTitle(true);

    //寫入圖表數(shù)據(jù)
    chart.getChartData().get(0,0).setText("月份");
    chart.getChartData().get(0,1).setText("銷量");
    chart.getChartData().get(0,2).setText("環(huán)比增長(%)");
    chart.getChartData().get(1,0).setText("1月");
    chart.getChartData().get(1,1).setNumberValue(120);
    chart.getChartData().get(1,2).setNumberValue(12);
    chart.getChartData().get(2,0).setText("2月");
    chart.getChartData().get(2,1).setNumberValue(100);
    chart.getChartData().get(2,2).setNumberValue(10);
    chart.getChartData().get(3,0).setText("3月");
    chart.getChartData().get(3,1).setNumberValue(80);
    chart.getChartData().get(3,2).setNumberValue(9);
    chart.getChartData().get(4,0).setText("4月");
    chart.getChartData().get(4,1).setNumberValue(120);
    chart.getChartData().get(4,2).setNumberValue(15);
    chart.getChartData().get(5,0).setText("5月");
    chart.getChartData().get(5,1).setNumberValue(90);
    chart.getChartData().get(5,2).setNumberValue(11);
    chart.getChartData().get(6,0).setText("6月");
    chart.getChartData().get(6,1).setNumberValue(110);
    chart.getChartData().get(6,2).setNumberValue(10.5);

    //設(shè)置系列標(biāo)簽數(shù)據(jù)來源
    chart.getSeries().setSeriesLabel(chart.getChartData().get("B1", "C1"));

    //設(shè)置分類標(biāo)簽數(shù)據(jù)來源
    chart.getCategories().setCategoryLabels(chart.getChartData().get("A2", "A7"));

    //設(shè)置系列的數(shù)據(jù)來源
    chart.getSeries().get(0).setValues(chart.getChartData().get("B2", "B7"));
    chart.getSeries().get(1).setValues(chart.getChartData().get("C2", "C7"));
    chart.getSeries().get(1).getDataLabels().setLabelValueVisible(true);//設(shè)置顯示系列2的數(shù)據(jù)標(biāo)簽值
    chart.getSeries().get(1).setType(ChartType.LINE_MARKERS);//將系列2的圖表類型設(shè)置為折線圖
    chart.getSeries().get(1).setUseSecondAxis(true);//將系列2繪制在次坐標(biāo)軸
    chart.getSecondaryValueAxis().getMajorGridTextLines().setFillType(FillFormatType.NONE);//不顯示次坐標(biāo)軸的網(wǎng)格線

    //設(shè)置系列重疊
    chart.setOverLap(-30);

    //設(shè)置分類間距
    chart.setGapDepth(200);

    //保存文檔
    presentation.saveToFile("chart.pptx", FileFormat.PPTX_2013);
    presentation.dispose();
  }
}

圖表添加效果:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • java中DecimalFormat四舍五入用法詳解

    java中DecimalFormat四舍五入用法詳解

    這篇文章主要為大家詳細(xì)介紹了java中DecimalFormat四舍五入的用法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-03-03
  • 基于Java Socket實(shí)現(xiàn)一個(gè)簡易在線聊天功能(一)

    基于Java Socket實(shí)現(xiàn)一個(gè)簡易在線聊天功能(一)

    這篇文章主要給大家介紹基于Java Socket實(shí)現(xiàn)一個(gè)簡易在線聊天功能(一),分為客戶端和服務(wù)端兩段代碼,非常具有參考價(jià)值,感興趣的朋友一起學(xué)習(xí)吧
    2016-05-05
  • Springboot2.7+Minio8 實(shí)現(xiàn)大文件分片上傳

    Springboot2.7+Minio8 實(shí)現(xiàn)大文件分片上傳

    本文主要介紹了Springboot2.7+Minio8 實(shí)現(xiàn)大文件分片上傳,通過文件切片上傳,我們能夠提高文件上傳的速度,優(yōu)化用戶體驗(yàn),具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-12-12
  • JavaCV使用ffmpeg實(shí)現(xiàn)錄屏功能

    JavaCV使用ffmpeg實(shí)現(xiàn)錄屏功能

    這篇文章主要介紹了JavaCV如何使用ffmpeg實(shí)現(xiàn)錄屏功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-06-06
  • Spring?BOOT?AOP基礎(chǔ)應(yīng)用教程

    Spring?BOOT?AOP基礎(chǔ)應(yīng)用教程

    這篇文章主要介紹了Spring?BOOT?AOP的使用,文章從相關(guān)問題展開全文內(nèi)容詳情,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-07-07
  • Spring工作原理簡單探索

    Spring工作原理簡單探索

    這篇文章主要介紹了Spring工作原理簡單探索,涉及Springaop與IOC,動(dòng)態(tài)代理靜態(tài)代理,反射等相關(guān)內(nèi)容,具有一定參考價(jià)值,需要的朋友可以了解下。
    2017-11-11
  • Spring Security Remember me使用及原理詳解

    Spring Security Remember me使用及原理詳解

    這篇文章主要介紹了Spring Security Remember me使用及原理詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-09-09
  • 解決異常處理問題:getReader()?has?already?been?called?for?this

    解決異常處理問題:getReader()?has?already?been?called?for?this

    這篇文章主要介紹了解決異常處理:getReader()?has?already?been?called?for?this問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • 基于jstree使用JSON數(shù)據(jù)組裝成樹

    基于jstree使用JSON數(shù)據(jù)組裝成樹

    這篇文章主要為大家詳細(xì)介紹了基于jstree使用JSON數(shù)據(jù)組裝成樹,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • 非常實(shí)用的java自動(dòng)答題計(jì)時(shí)計(jì)分器

    非常實(shí)用的java自動(dòng)答題計(jì)時(shí)計(jì)分器

    這篇文章主要為大家詳細(xì)介紹了非常實(shí)用的java自動(dòng)答題計(jì)時(shí)計(jì)分器的實(shí)現(xiàn)方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-01-01

最新評論