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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/asposeslidesjava/Charts/formattingchartentities.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
slide = pres.getSlides().get_Item(0)
chart = slide.getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').LineWithMarkers, 50, 50, 500, 400)
chart.hasTitle(true)
chart.getChartTitle().addTextFrameForOverriding("")
chartTitle = chart.getChartTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0)
chartTitle.setText("Sample Chart")
chartTitle.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
chartTitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').GRAY)
chartTitle.getPortionFormat().setFontHeight (20)
chartTitle.getPortionFormat().setFontBold(Rjb::import('com.aspose.slides.NullableBool').True)
chartTitle.getPortionFormat().setFontItalic(Rjb::import('com.aspose.slides.NullableBool').True)
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLUE)
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().setWidth(5)
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().setDashStyle(Rjb::import('com.aspose.slides.LineDashStyle').DashDot)
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').RED)
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().setWidth(3)
chart.getAxes().getVerticalAxis().isNumberFormatLinkedToSource(false)
chart.getAxes().getVerticalAxis().setDisplayUnit(Rjb::import('com.aspose.slides.DisplayUnitType').Thousands)
chart.getAxes().getVerticalAxis().setNumberFormat("0.0%")
chart.getAxes().getVerticalAxis().isAutomaticMajorUnit(false)
chart.getAxes().getVerticalAxis().isAutomaticMaxValue(false)
chart.getAxes().getVerticalAxis().isAutomaticMinorUnit(false)
chart.getAxes().getVerticalAxis().isAutomaticMinValue(false)
chart.getAxes().getVerticalAxis().setMaxValue(15)
chart.getAxes().getVerticalAxis().setMinValue(-2)
chart.getAxes().getVerticalAxis().setMinorUnit(0.5)
chart.getAxes().getVerticalAxis().setMajorUnit(2.0)
txtVal = chart.getAxes().getVerticalAxis().getTextFormat().getPortionFormat()
txtVal.setFontBold(Rjb::import('com.aspose.slides.NullableBool').True)
txtVal.setFontHeight(16)
txtVal.setFontItalic(Rjb::import('com.aspose.slides.NullableBool').True)
txtVal.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
txtVal.getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').new(Rjb::import('com.aspose.slides.PresetColor').DarkGreen))
txtVal.setLatinFont(Rjb::import('com.aspose.slides.FontData').new("Times New Roman"))
chart.getAxes().getVerticalAxis().hasTitle(true)
chart.getAxes().getVerticalAxis().getTitle().addTextFrameForOverriding("")
valtitle = chart.getAxes().getVerticalAxis().getTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0)
valtitle.setText("Primary Axis")
valtitle.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
valtitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').GRAY)
valtitle.getPortionFormat().setFontHeight(20)
valtitle.getPortionFormat().setFontBold(Rjb::import('com.aspose.slides.NullableBool').True)
valtitle.getPortionFormat().setFontItalic(Rjb::import('com.aspose.slides.NullableBool').True)
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').GREEN)
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().setWidth(5)
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').YELLOW)
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().setWidth(3)
txtCat = chart.getAxes().getHorizontalAxis().getTextFormat().getPortionFormat()
txtCat.setFontBold(Rjb::import('com.aspose.slides.NullableBool').True)
txtCat.setFontHeight(16)
txtCat.setFontItalic(Rjb::import('com.aspose.slides.NullableBool').True)
txtCat.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
txtCat.getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLUE)
txtCat.setLatinFont(Rjb::import('com.aspose.slides.FontData').new("Arial"))
chart.getAxes().getHorizontalAxis().hasTitle(true)
chart.getAxes().getHorizontalAxis().getTitle().addTextFrameForOverriding("")
catTitle = chart.getAxes().getHorizontalAxis().getTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getPortions().get_Item(0)
catTitle.setText("Sample Category")
catTitle.getPortionFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
catTitle.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').GRAY)
catTitle.getPortionFormat().setFontHeight(20)
catTitle.getPortionFormat().setFontBold(Rjb::import('com.aspose.slides.NullableBool').True)
catTitle.getPortionFormat().setFontItalic(Rjb::import('com.aspose.slides.NullableBool').True)
chart.getAxes().getHorizontalAxis().setTickLabelPosition(Rjb::import('com.aspose.slides.TickLabelPositionType').Low)
chart.getAxes().getHorizontalAxis().setTickLabelRotationAngle(45)
txtleg = chart.getLegend().getTextFormat().getPortionFormat()
txtleg.setFontBold(Rjb::import('com.aspose.slides.NullableBool').True)
txtleg.setFontHeight(16)
txtleg.setFontItalic(Rjb::import('com.aspose.slides.NullableBool').True)
txtleg.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
txtleg.getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').new(Rjb::import('com.aspose.slides.PresetColor').DarkRed))
chart.getLegend().setOverlay(true)
chart.getChartData().getSeries().get_Item(0).setPlotOnSecondAxis(true)
chart.getAxes().getSecondaryVerticalAxis().isVisible(true)
chart.getAxes().getSecondaryVerticalAxis().getFormat().getLine().setStyle(Rjb::import('com.aspose.slides.LineStyle').ThickBetweenThin)
chart.getAxes().getSecondaryVerticalAxis().getFormat().getLine().setWidth(20)
chart.getAxes().getSecondaryVerticalAxis().isNumberFormatLinkedToSource(false)
chart.getAxes().getSecondaryVerticalAxis().setDisplayUnit(Rjb::import('com.aspose.slides.DisplayUnitType').Hundreds)
chart.getAxes().getSecondaryVerticalAxis().setNumberFormat ("0.0%")
chart.getAxes().getSecondaryVerticalAxis().isAutomaticMajorUnit(false)
chart.getAxes().getSecondaryVerticalAxis().isAutomaticMaxValue(false)
chart.getAxes().getSecondaryVerticalAxis().isAutomaticMinorUnit(false)
chart.getAxes().getSecondaryVerticalAxis().isAutomaticMinValue(false)
chart.getAxes().getSecondaryVerticalAxis().setMaxValue(20)
chart.getAxes().getSecondaryVerticalAxis().setMinValue(-5)
chart.getAxes().getSecondaryVerticalAxis().setMinorUnit(0.5)
chart.getAxes().getSecondaryVerticalAxis().setMajorUnit(2.0)
chart.getBackWall().setThickness(1)
chart.getBackWall().getFormat().getFill().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
chart.getBackWall().getFormat().getFill().getSolidFillColor().setColor(Rjb::import('java.awt.Color').ORANGE)
chart.getFloor().getFormat().getFill().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
chart.getFloor().getFormat().getFill().getSolidFillColor().setColor(Rjb::import('java.awt.Color').RED)
chart.getPlotArea().getFormat().getFill().setFillType(Rjb::import('com.aspose.slides.FillType').Solid)
chart.getPlotArea().getFormat().getFill().getSolidFillColor().setColor(Rjb::import('java.awt.Color').new(Rjb::import('com.aspose.slides.PresetColor').LightCyan))
pres.save(data_dir + "FormattedChart.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx)
puts "Formatted chart entities, please check the output file."
end
|