3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/asposeslidesjava/Charts/charttrendlines.rb', line 3
def initialize()
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
pres = Rjb::import('com.aspose.slides.Presentation').new
chart = pres.getSlides().get_Item(0).getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').ClusteredColumn, 20, 20, 500, 400)
tredLinep = chart.getChartData().getSeries().get_Item(0).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Exponential)
tredLinep.setDisplayEquation(false)
tredLinep.setDisplayRSquaredValue(false)
tredLineLin = chart.getChartData().getSeries().get_Item(0).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Linear)
tredLineLin.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').Linear)
tredLineLin.getFormat().getLine().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
tredLineLin.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').RED)
tredLineLog = chart.getChartData().getSeries().get_Item(1).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Logarithmic)
tredLineLog.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').Logarithmic)
tredLineLog.addTextFrameForOverriding("New log trend line")
tredLineMovAvg = chart.getChartData().getSeries().get_Item(1).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').MovingAverage)
tredLineMovAvg.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').MovingAverage)
tredLineMovAvg.setPeriod(3)
tredLineMovAvg.setTrendlineName("New TrendLine Name")
tredLinePol = chart.getChartData().getSeries().get_Item(2).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Polynomial)
tredLinePol.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').Polynomial)
tredLinePol.setForward(1)
tredLinePol.setOrder(3)
tredLinePower = chart.getChartData().getSeries().get_Item(1).getTrendLines().add(Rjb::import('com.aspose.slides.TrendlineType').Power)
tredLinePower.setTrendlineType(Rjb::import('com.aspose.slides.TrendlineType').Power)
tredLinePower.setBackward(1)
save_format = Rjb::import('com.aspose.slides.SaveFormat')
pres.save(data_dir + "ChartTrendLines.pptx", save_format.Pptx)
puts "Done with chart trend lines, please check the output file."
end
|