asposeslidesjava 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/asposeslidesjava.gemspec +27 -0
- data/config/aspose.yml +5 -0
- data/data/Aspose.html +55 -0
- data/data/Aspose.pptx +0 -0
- data/data/AsposeChart.pptx +0 -0
- data/data/Bass-Drum.wav +0 -0
- data/data/HelloWorld.pptx +0 -0
- data/data/Presentation1.ppt +0 -0
- data/data/Shapes/OleEmbed.pptx +0 -0
- data/data/Shapes/Wildlife.mp4 +0 -0
- data/data/Shapes/sample.xlsx +0 -0
- data/data/Source.odp +0 -0
- data/data/Tables/aspose-logo.jpg +0 -0
- data/data/Tables/demotable.pptx +0 -0
- data/data/Text/Welcome.pptx +0 -0
- data/data/Text/import.html +119 -0
- data/data/Text/input.pptx +0 -0
- data/data/Wildlife.mp4 +0 -0
- data/data/WithActiveX.pptm +0 -0
- data/data/aspose-logo.jpg +0 -0
- data/data/demo.pptx +0 -0
- data/data/night.jpg +0 -0
- data/data/vbamacro.pptx +0 -0
- data/lib/asposeslidesjava.rb +71 -0
- data/lib/asposeslidesjava/ActiveX/addactivex.rb +21 -0
- data/lib/asposeslidesjava/Charts/chartlegend.rb +33 -0
- data/lib/asposeslidesjava/Charts/chartproperties.rb +120 -0
- data/lib/asposeslidesjava/Charts/chartseries.rb +28 -0
- data/lib/asposeslidesjava/Charts/charttrendlines.rb +53 -0
- data/lib/asposeslidesjava/Charts/createchart.rb +163 -0
- data/lib/asposeslidesjava/Charts/errorbars.rb +84 -0
- data/lib/asposeslidesjava/Charts/existingchart.rb +66 -0
- data/lib/asposeslidesjava/Charts/formattingchartentities.rb +163 -0
- data/lib/asposeslidesjava/Charts/setlabeldistance.rb +24 -0
- data/lib/asposeslidesjava/Charts/setpiechartcolors.rb +118 -0
- data/lib/asposeslidesjava/Presentation/convertingtohtml.rb +25 -0
- data/lib/asposeslidesjava/Presentation/convertingtonotes.rb +37 -0
- data/lib/asposeslidesjava/Presentation/convertingtopdf.rb +16 -0
- data/lib/asposeslidesjava/Presentation/convertingtotiff.rb +62 -0
- data/lib/asposeslidesjava/Presentation/convertingtoxps.rb +43 -0
- data/lib/asposeslidesjava/Presentation/odptopptx.rb +16 -0
- data/lib/asposeslidesjava/Presentation/ppttopptx.rb +16 -0
- data/lib/asposeslidesjava/Presentation/properties.rb +106 -0
- data/lib/asposeslidesjava/Presentation/zoom.rb +20 -0
- data/lib/asposeslidesjava/Shapes/addellipseshape.rb +60 -0
- data/lib/asposeslidesjava/Shapes/addinglineshape.rb +65 -0
- data/lib/asposeslidesjava/Shapes/addrectangleshape.rb +58 -0
- data/lib/asposeslidesjava/Shapes/cloneshape.rb +32 -0
- data/lib/asposeslidesjava/Shapes/connectshapes.rb +83 -0
- data/lib/asposeslidesjava/Shapes/embedvideo.rb +32 -0
- data/lib/asposeslidesjava/Shapes/fillingshapes.rb +98 -0
- data/lib/asposeslidesjava/Shapes/findshape.rb +30 -0
- data/lib/asposeslidesjava/Shapes/formatlines.rb +99 -0
- data/lib/asposeslidesjava/Shapes/frame.rb +85 -0
- data/lib/asposeslidesjava/Shapes/groupshape.rb +35 -0
- data/lib/asposeslidesjava/Shapes/oleobject.rb +26 -0
- data/lib/asposeslidesjava/Shapes/rotatingshapes.rb +25 -0
- data/lib/asposeslidesjava/Shapes/shapeproperties.rb +30 -0
- data/lib/asposeslidesjava/Shapes/shapethumbnail.rb +18 -0
- data/lib/asposeslidesjava/Slides/accessslides.rb +38 -0
- data/lib/asposeslidesjava/Slides/addslides.rb +28 -0
- data/lib/asposeslidesjava/Slides/background.rb +76 -0
- data/lib/asposeslidesjava/Slides/changingposition.rb +22 -0
- data/lib/asposeslidesjava/Slides/cloneslides.rb +72 -0
- data/lib/asposeslidesjava/Slides/creatingsvg.rb +27 -0
- data/lib/asposeslidesjava/Slides/hyperlinks.rb +19 -0
- data/lib/asposeslidesjava/Slides/removeslides.rb +46 -0
- data/lib/asposeslidesjava/Slides/sizeandlayout.rb +55 -0
- data/lib/asposeslidesjava/Slides/thumbnail.rb +113 -0
- data/lib/asposeslidesjava/Slides/transitions.rb +24 -0
- data/lib/asposeslidesjava/SmartArt/addsmartart.rb +26 -0
- data/lib/asposeslidesjava/SmartArt/fillformat.rb +28 -0
- data/lib/asposeslidesjava/Tables/addimage.rb +34 -0
- data/lib/asposeslidesjava/Tables/aligntext.rb +48 -0
- data/lib/asposeslidesjava/Tables/clonerowcolumn.rb +76 -0
- data/lib/asposeslidesjava/Tables/createtable.rb +61 -0
- data/lib/asposeslidesjava/Tables/removerowcolumn.rb +27 -0
- data/lib/asposeslidesjava/Text/createtextbox.rb +79 -0
- data/lib/asposeslidesjava/Text/exporttexttohtml.rb +30 -0
- data/lib/asposeslidesjava/Text/importhtml.rb +51 -0
- data/lib/asposeslidesjava/Text/managefont.rb +30 -0
- data/lib/asposeslidesjava/Text/managetext.rb +128 -0
- data/lib/asposeslidesjava/Text/paragraphs.rb +260 -0
- data/lib/asposeslidesjava/Text/replacetext.rb +23 -0
- data/lib/asposeslidesjava/Text/shadoweffects.rb +37 -0
- data/lib/asposeslidesjava/Text/textfont.rb +130 -0
- data/lib/asposeslidesjava/Text/wordart.rb +45 -0
- data/lib/asposeslidesjava/VBAMacros/removevbamacro.rb +18 -0
- data/lib/asposeslidesjava/activex.rb +1 -0
- data/lib/asposeslidesjava/asposeslides.rb +10 -0
- data/lib/asposeslidesjava/charts.rb +9 -0
- data/lib/asposeslidesjava/helloworld.rb +38 -0
- data/lib/asposeslidesjava/presentation.rb +9 -0
- data/lib/asposeslidesjava/shapes.rb +15 -0
- data/lib/asposeslidesjava/slides.rb +11 -0
- data/lib/asposeslidesjava/smartart.rb +2 -0
- data/lib/asposeslidesjava/tables.rb +5 -0
- data/lib/asposeslidesjava/text.rb +10 -0
- data/lib/asposeslidesjava/vbamacros.rb +1 -0
- data/lib/asposeslidesjava/version.rb +3 -0
- data/samples/test.rb +8 -0
- metadata +206 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module ChartProperties
|
3
|
+
def initialize()
|
4
|
+
# Setting the RotationX, RotationY and DepthPercents properties of 3D Chart.
|
5
|
+
set_rotation_and_depth()
|
6
|
+
|
7
|
+
# Setting the GapWidth property of Chart Series
|
8
|
+
set_gapwidth()
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_rotation_and_depth()
|
12
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
13
|
+
|
14
|
+
# Instantiate Presentation class that represents the presentation file
|
15
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
16
|
+
|
17
|
+
# Access first slide
|
18
|
+
sld = pres.getSlides().get_Item(0)
|
19
|
+
|
20
|
+
# Add chart with default data
|
21
|
+
chart = sld.getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').StackedColumn3D, 0, 0, 500, 500)
|
22
|
+
|
23
|
+
# Getting the chart data worksheet
|
24
|
+
fact = chart.getChartData().getChartDataWorkbook()
|
25
|
+
|
26
|
+
# Delete default generated series and categories
|
27
|
+
chart.getChartData().getSeries().clear()
|
28
|
+
chart.getChartData().getCategories().clear()
|
29
|
+
|
30
|
+
# Adding new series
|
31
|
+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType())
|
32
|
+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType())
|
33
|
+
|
34
|
+
# Adding new categories
|
35
|
+
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1"))
|
36
|
+
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2"))
|
37
|
+
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3"))
|
38
|
+
|
39
|
+
# Set Rotation3D properties
|
40
|
+
chart.getRotation3D().setRightAngleAxes(true)
|
41
|
+
chart.getRotation3D().setRotationX(40)
|
42
|
+
chart.getRotation3D().setRotationY(270)
|
43
|
+
chart.getRotation3D().setDepthPercents(150)
|
44
|
+
|
45
|
+
# Take first chart series
|
46
|
+
series = chart.getChartData().getSeries().get_Item(0)
|
47
|
+
|
48
|
+
# Populating series data
|
49
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20))
|
50
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50))
|
51
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30))
|
52
|
+
|
53
|
+
# Take second chart series
|
54
|
+
series = chart.getChartData().getSeries().get_Item(1)
|
55
|
+
|
56
|
+
# Populating series data
|
57
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30))
|
58
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10))
|
59
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60))
|
60
|
+
|
61
|
+
# Saving the presentation
|
62
|
+
pres.save(data_dir + "3Drotation.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
63
|
+
|
64
|
+
puts "Done with rotation, please check the output file."
|
65
|
+
end
|
66
|
+
|
67
|
+
def set_gapwidth()
|
68
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
69
|
+
|
70
|
+
# Instantiate Presentation class that represents the presentation file
|
71
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
72
|
+
|
73
|
+
# Access first slide
|
74
|
+
sld = pres.getSlides().get_Item(0)
|
75
|
+
|
76
|
+
# Add chart with default data
|
77
|
+
chart = sld.getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').StackedColumn3D, 0, 0, 500, 500)
|
78
|
+
|
79
|
+
# Getting the chart data worksheet
|
80
|
+
fact = chart.getChartData().getChartDataWorkbook()
|
81
|
+
|
82
|
+
# Delete default generated series and categories
|
83
|
+
chart.getChartData().getSeries().clear()
|
84
|
+
chart.getChartData().getCategories().clear()
|
85
|
+
|
86
|
+
# Adding new series
|
87
|
+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType())
|
88
|
+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType())
|
89
|
+
|
90
|
+
# Adding new categories
|
91
|
+
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1"))
|
92
|
+
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2"))
|
93
|
+
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3"))
|
94
|
+
|
95
|
+
# Take first chart series
|
96
|
+
series = chart.getChartData().getSeries().get_Item(0)
|
97
|
+
|
98
|
+
# Populating series data
|
99
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20))
|
100
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50))
|
101
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30))
|
102
|
+
|
103
|
+
# Take second chart series
|
104
|
+
series = chart.getChartData().getSeries().get_Item(1)
|
105
|
+
|
106
|
+
# Populating series data
|
107
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30))
|
108
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10))
|
109
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60))
|
110
|
+
|
111
|
+
# Set GapWidth value
|
112
|
+
series.getParentSeriesGroup().setGapWidth(75)
|
113
|
+
|
114
|
+
# Saving the presentation
|
115
|
+
pres.save(data_dir + "SetGapWidth.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
116
|
+
|
117
|
+
puts "Set Gapwidth property of chart series, please check the output file."
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module ChartSeries
|
3
|
+
def initialize()
|
4
|
+
# Adding Chart Series Overlap for Charts
|
5
|
+
add_overlap_for_chart()
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_overlap_for_chart()
|
9
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
10
|
+
|
11
|
+
# Instantiate Presentation class that represents the presentation file
|
12
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
13
|
+
|
14
|
+
# Adding chart
|
15
|
+
chart = pres.getSlides().get_Item(0).getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').ClusteredColumn, 50, 50, 600, 400, true)
|
16
|
+
series = chart.getChartData().getSeries()
|
17
|
+
if series.get_Item(0).getOverlap() == 0
|
18
|
+
# Setting series overlap
|
19
|
+
series.get_Item(0).getParentSeriesGroup().setOverlap(-30)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Saving the presentation
|
23
|
+
pres.save(data_dir + "Overlap.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
24
|
+
|
25
|
+
puts "Added chart series overlap for charts, please check the output file."
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module ChartTrendLines
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Creating empty presentation
|
7
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
8
|
+
|
9
|
+
# Creating a clustered column chart
|
10
|
+
chart = pres.getSlides().get_Item(0).getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').ClusteredColumn, 20, 20, 500, 400)
|
11
|
+
|
12
|
+
# Adding ponential trend line for chart series 1
|
13
|
+
tredLinep = chart.getChartData().getSeries().get_Item(0).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Exponential)
|
14
|
+
tredLinep.setDisplayEquation(false)
|
15
|
+
tredLinep.setDisplayRSquaredValue(false)
|
16
|
+
|
17
|
+
# Adding Linear trend line for chart series 1
|
18
|
+
tredLineLin = chart.getChartData().getSeries().get_Item(0).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Linear)
|
19
|
+
tredLineLin.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').Linear)
|
20
|
+
tredLineLin.getFormat().getLine().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
21
|
+
tredLineLin.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').RED)
|
22
|
+
|
23
|
+
|
24
|
+
# Adding Logarithmic trend line for chart series 2
|
25
|
+
tredLineLog = chart.getChartData().getSeries().get_Item(1).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Logarithmic)
|
26
|
+
tredLineLog.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').Logarithmic)
|
27
|
+
tredLineLog.addTextFrameForOverriding("New log trend line")
|
28
|
+
|
29
|
+
# Adding MovingAverage trend line for chart series 2
|
30
|
+
tredLineMovAvg = chart.getChartData().getSeries().get_Item(1).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').MovingAverage)
|
31
|
+
tredLineMovAvg.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').MovingAverage)
|
32
|
+
tredLineMovAvg.setPeriod(3)
|
33
|
+
tredLineMovAvg.setTrendlineName("New TrendLine Name")
|
34
|
+
|
35
|
+
# Adding Polynomial trend line for chart series 3
|
36
|
+
tredLinePol = chart.getChartData().getSeries().get_Item(2).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Polynomial)
|
37
|
+
tredLinePol.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').Polynomial)
|
38
|
+
tredLinePol.setForward(1)
|
39
|
+
tredLinePol.setOrder(3)
|
40
|
+
|
41
|
+
# Adding Power trend line for chart series 3
|
42
|
+
tredLinePower = chart.getChartData().getSeries().get_Item(1).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Power)
|
43
|
+
tredLinePower.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').Power)
|
44
|
+
tredLinePower.setBackward(1)
|
45
|
+
|
46
|
+
# Saving the presentation
|
47
|
+
save_format = Rjb::import('com.aspose.slides.SaveFormat')
|
48
|
+
pres.save(data_dir + "ChartTrendLines.pptx", save_format.Pptx)
|
49
|
+
|
50
|
+
puts "Done with chart trend lines, please check the output file."
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module CreateChart
|
3
|
+
def initialize()
|
4
|
+
# Creating Normal Charts
|
5
|
+
create_normal_chart()
|
6
|
+
|
7
|
+
# Creating Scattered Chart with multiple series and different series markers
|
8
|
+
create_scatter_chart()
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_normal_chart()
|
12
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
13
|
+
|
14
|
+
# Instantiate Presentation class that represents the presentation file
|
15
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
16
|
+
|
17
|
+
# Access first slide
|
18
|
+
sld = pres.getSlides().get_Item(0)
|
19
|
+
|
20
|
+
# Add chart with default data
|
21
|
+
chart = sld.getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').ClusteredColumn, 0, 0, 500, 500)
|
22
|
+
|
23
|
+
# Setting chart Title
|
24
|
+
# chart.ChartTitle.TextFrameForOverriding.Text = "Sample Title";
|
25
|
+
chart.getChartTitle().addTextFrameForOverriding("Sample Title")
|
26
|
+
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(Rjb::import('com.aspose.slides.NullableBool').True)
|
27
|
+
chart.getChartTitle().setHeight (20)
|
28
|
+
chart.hasTitle(true)
|
29
|
+
|
30
|
+
# Set first series to Show Values
|
31
|
+
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true)
|
32
|
+
|
33
|
+
# Setting the index of chart data sheet
|
34
|
+
defaultWorksheetIndex = 0
|
35
|
+
|
36
|
+
# Getting the chart data worksheet
|
37
|
+
fact = chart.getChartData().getChartDataWorkbook()
|
38
|
+
|
39
|
+
# Delete default generated series and categories
|
40
|
+
chart.getChartData().getSeries().clear()
|
41
|
+
chart.getChartData().getCategories().clear()
|
42
|
+
s = chart.getChartData().getSeries().size()
|
43
|
+
s = chart.getChartData().getCategories().size()
|
44
|
+
|
45
|
+
# Adding new series
|
46
|
+
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType())
|
47
|
+
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.getType())
|
48
|
+
|
49
|
+
# Adding new categories
|
50
|
+
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"))
|
51
|
+
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"))
|
52
|
+
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"))
|
53
|
+
|
54
|
+
# Take first chart series
|
55
|
+
series = chart.getChartData().getSeries().get_Item(0)
|
56
|
+
|
57
|
+
# Now populating series data
|
58
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20))
|
59
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 50))
|
60
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 30))
|
61
|
+
|
62
|
+
# Setting fill color for series
|
63
|
+
series.getFormat().getFill().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
64
|
+
series.getFormat().getFill().getSolidFillColor().setColor(Rjb::import('java.awt.Color').RED)
|
65
|
+
|
66
|
+
|
67
|
+
# Take second chart series
|
68
|
+
series = chart.getChartData().getSeries().get_Item(1)
|
69
|
+
|
70
|
+
# Now populating series data
|
71
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 30))
|
72
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10))
|
73
|
+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 60))
|
74
|
+
|
75
|
+
# Setting fill color for series
|
76
|
+
series.getFormat().getFill().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
|
77
|
+
series.getFormat().getFill().getSolidFillColor().setColor(Rjb::import('java.awt.Color').GREEN)
|
78
|
+
|
79
|
+
# create custom labels for each of categories for new series
|
80
|
+
# first label will be show Category name
|
81
|
+
lbl = series.getDataPoints().get_Item(0).getLabel()
|
82
|
+
lbl.getDataLabelFormat().setShowCategoryName(true)
|
83
|
+
|
84
|
+
lbl = series.getDataPoints().get_Item(1).getLabel()
|
85
|
+
lbl.getDataLabelFormat().setShowSeriesName(true)
|
86
|
+
|
87
|
+
# Show value for third label
|
88
|
+
lbl = series.getDataPoints().get_Item(2).getLabel()
|
89
|
+
lbl.getDataLabelFormat().setShowValue(true)
|
90
|
+
lbl.getDataLabelFormat().setShowSeriesName(true)
|
91
|
+
lbl.getDataLabelFormat().setSeparator ("/")
|
92
|
+
|
93
|
+
# Save presentation with chart
|
94
|
+
pres.save(data_dir + "NormalChart.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
95
|
+
|
96
|
+
puts "Created normal chart, please check the output file."
|
97
|
+
end
|
98
|
+
|
99
|
+
def create_scatter_chart()
|
100
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
101
|
+
|
102
|
+
# Instantiate Presentation class that represents the presentation file
|
103
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
104
|
+
|
105
|
+
slide = pres.getSlides().get_Item(0)
|
106
|
+
|
107
|
+
# Creating the default chart
|
108
|
+
chart = slide.getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').ScatterWithSmoothLines, 0, 0, 400, 400)
|
109
|
+
|
110
|
+
# Getting the default chart data worksheet index
|
111
|
+
defaultWorksheetIndex = 0
|
112
|
+
|
113
|
+
# Getting the chart data worksheet
|
114
|
+
fact = chart.getChartData().getChartDataWorkbook()
|
115
|
+
|
116
|
+
# Delete demo series
|
117
|
+
chart.getChartData().getSeries().clear()
|
118
|
+
|
119
|
+
# Add new series
|
120
|
+
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.getType())
|
121
|
+
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.getType())
|
122
|
+
|
123
|
+
# Take first chart series
|
124
|
+
series = chart.getChartData().getSeries().get_Item(0)
|
125
|
+
|
126
|
+
# Add new point (1:3) there.
|
127
|
+
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 1), fact.getCell(defaultWorksheetIndex, 2, 2, 3))
|
128
|
+
|
129
|
+
# Add new point (2:10)
|
130
|
+
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 2), fact.getCell(defaultWorksheetIndex, 3, 2, 10))
|
131
|
+
|
132
|
+
# Edit the type of series
|
133
|
+
series.setType(Rjb::import('com.aspose.slides.ChartType').ScatterWithStraightLinesAndMarkers)
|
134
|
+
|
135
|
+
# Changing the chart series marker
|
136
|
+
series.getMarker().setSize(10)
|
137
|
+
series.getMarker().setSymbol(Rjb::import('com.aspose.slides.MarkerStyleType').Star)
|
138
|
+
|
139
|
+
# Take second chart series
|
140
|
+
series = chart.getChartData().getSeries().get_Item(1)
|
141
|
+
|
142
|
+
# Add new point (5:2) there.
|
143
|
+
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 2, 3, 5), fact.getCell(defaultWorksheetIndex, 2, 4, 2))
|
144
|
+
|
145
|
+
# Add new point (3:1)
|
146
|
+
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 3, 3, 3), fact.getCell(defaultWorksheetIndex, 3, 4, 1))
|
147
|
+
|
148
|
+
# Add new point (2:2)
|
149
|
+
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 4, 3, 2), fact.getCell(defaultWorksheetIndex, 4, 4, 2))
|
150
|
+
|
151
|
+
# Add new point (5:1)
|
152
|
+
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 5, 3, 5), fact.getCell(defaultWorksheetIndex, 5, 4, 1))
|
153
|
+
|
154
|
+
# Changing the chart series marker
|
155
|
+
series.getMarker().setSize(10)
|
156
|
+
series.getMarker().setSymbol(Rjb::import('com.aspose.slides.MarkerStyleType').Circle)
|
157
|
+
|
158
|
+
pres.save(data_dir + "AsposeScatterChart.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
159
|
+
|
160
|
+
puts "Created scatter chart, please check the output file."
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Asposeslidesjava
|
2
|
+
module ErrorBars
|
3
|
+
def initialize()
|
4
|
+
# Adding Fixed Error Bar Value for Chart
|
5
|
+
add_fixed_error_bar_value()
|
6
|
+
|
7
|
+
# Adding Custom Error Bar Value for Chart
|
8
|
+
add_custom_error_bar_value()
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_fixed_error_bar_value()
|
12
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
13
|
+
|
14
|
+
# Instantiate Presentation class that represents the presentation file
|
15
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
16
|
+
|
17
|
+
# Creating a bubble chart
|
18
|
+
chart = pres.getSlides().get_Item(0).getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').Bubble, 50, 50, 400, 300, true)
|
19
|
+
|
20
|
+
# Adding Error bars and setting its format
|
21
|
+
error_bar_x = chart.getChartData().getSeries().get_Item(0).getErrorBarsXFormat()
|
22
|
+
error_bar_y = chart.getChartData().getSeries().get_Item(0).getErrorBarsYFormat()
|
23
|
+
|
24
|
+
#error_bar_x.isVisible(true)
|
25
|
+
#error_bar_y.isVisible(true)
|
26
|
+
error_bar_x.setValueType(Rjb::import('com.aspose.slides.ErrorBarValueType').Fixed)
|
27
|
+
error_bar_x.setValue(0.1)
|
28
|
+
error_bar_y.setValueType(Rjb::import('com.aspose.slides.ErrorBarValueType').Percentage)
|
29
|
+
error_bar_y.setValue(5)
|
30
|
+
error_bar_x.setType(Rjb::import('com.aspose.slides.ErrorBarType').Plus)
|
31
|
+
error_bar_y.getFormat().getLine().setWidth(2.0)
|
32
|
+
#error_bar_x.hasEndCap(true)
|
33
|
+
|
34
|
+
# Save presentation with chart
|
35
|
+
pres.save(data_dir + "ErrorBar.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
36
|
+
|
37
|
+
puts "Added fixed error bar value for chart, please check the output file."
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_custom_error_bar_value()
|
41
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
42
|
+
|
43
|
+
# Instantiate Presentation class that represents the presentation file
|
44
|
+
pres = Rjb::import('com.aspose.slides.Presentation').new
|
45
|
+
|
46
|
+
slide = pres.getSlides().get_Item(0)
|
47
|
+
|
48
|
+
# Creating a bubble chart
|
49
|
+
chart = pres.getSlides().get_Item(0).getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').Bubble, 50, 50, 400, 300, true)
|
50
|
+
|
51
|
+
# Adding custom Error bars and setting its format
|
52
|
+
error_bar_value_type = Rjb::import('com.aspose.slides.ErrorBarValueType')
|
53
|
+
series = chart.getChartData().getSeries().get_Item(0)
|
54
|
+
error_bar_x = series.getErrorBarsXFormat()
|
55
|
+
error_bar_y = series.getErrorBarsYFormat()
|
56
|
+
#error_bar_x.isVisible(true)
|
57
|
+
#error_bar_y.isVisible(true)
|
58
|
+
error_bar_x.setValueType(error_bar_value_type.Custom)
|
59
|
+
error_bar_y.setValueType(error_bar_value_type.Custom)
|
60
|
+
|
61
|
+
#Accessing chart series data point and setting error bars values for individual point
|
62
|
+
data_source_type = Rjb::import('com.aspose.slides.DataSourceType')
|
63
|
+
points = series.getDataPoints()
|
64
|
+
points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForXPlusValues(data_source_type.DoubleLiterals)
|
65
|
+
points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForXMinusValues(data_source_type.DoubleLiterals)
|
66
|
+
points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForYPlusValues(data_source_type.DoubleLiterals)
|
67
|
+
points.getDataSourceTypeForErrorBarsCustomValues().setDataSourceTypeForYMinusValues(data_source_type.DoubleLiterals)
|
68
|
+
|
69
|
+
# Setting error bars for chart series points
|
70
|
+
i = 0
|
71
|
+
while i < points.size()
|
72
|
+
points.get_Item(i).getErrorBarsCustomValues().getXMinus().setAsLiteralDouble(i + 1)
|
73
|
+
points.get_Item(i).getErrorBarsCustomValues().getXPlus().setAsLiteralDouble(i + 1)
|
74
|
+
points.get_Item(i).getErrorBarsCustomValues().getYMinus().setAsLiteralDouble(i + 1)
|
75
|
+
points.get_Item(i).getErrorBarsCustomValues().getYPlus().setAsLiteralDouble(i + 1)
|
76
|
+
i +=1
|
77
|
+
end
|
78
|
+
|
79
|
+
pres.save(data_dir + "ErrorBarsCustomValues.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
|
80
|
+
|
81
|
+
puts "Added custom error bars values for chart, please check the output file."
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|