Module: Asposeslidesjava::ChartProperties
- Defined in:
- lib/asposeslidesjava/Charts/chartproperties.rb
Instance Method Summary collapse
Instance Method Details
#initialize ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/asposeslidesjava/Charts/chartproperties.rb', line 3 def initialize() # Setting the RotationX, RotationY and DepthPercents properties of 3D Chart. set_rotation_and_depth() # Setting the GapWidth property of Chart Series set_gapwidth() end |
#set_gapwidth ⇒ Object
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 |
# File 'lib/asposeslidesjava/Charts/chartproperties.rb', line 67 def set_gapwidth() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate Presentation class that represents the presentation file pres = Rjb::import('com.aspose.slides.Presentation').new # Access first slide sld = pres.getSlides().get_Item(0) # Add chart with default data chart = sld.getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').StackedColumn3D, 0, 0, 500, 500) # Getting the chart data worksheet fact = chart.getChartData().getChartDataWorkbook() # Delete default generated series and categories chart.getChartData().getSeries().clear() chart.getChartData().getCategories().clear() # Adding new series chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType()) chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType()) # Adding new categories chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1")) chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2")) chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3")) # Take first chart series series = chart.getChartData().getSeries().get_Item(0) # Populating series data series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30)) # Take second chart series series = chart.getChartData().getSeries().get_Item(1) # Populating series data series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60)) # Set GapWidth value series.getParentSeriesGroup().setGapWidth(75) # Saving the presentation pres.save(data_dir + "SetGapWidth.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx) puts "Set Gapwidth property of chart series, please check the output file." end |
#set_rotation_and_depth ⇒ Object
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 |
# File 'lib/asposeslidesjava/Charts/chartproperties.rb', line 11 def set_rotation_and_depth() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate Presentation class that represents the presentation file pres = Rjb::import('com.aspose.slides.Presentation').new # Access first slide sld = pres.getSlides().get_Item(0) # Add chart with default data chart = sld.getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').StackedColumn3D, 0, 0, 500, 500) # Getting the chart data worksheet fact = chart.getChartData().getChartDataWorkbook() # Delete default generated series and categories chart.getChartData().getSeries().clear() chart.getChartData().getCategories().clear() # Adding new series chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType()) chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType()) # Adding new categories chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1")) chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2")) chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3")) # Set Rotation3D properties chart.getRotation3D().setRightAngleAxes(true) chart.getRotation3D().setRotationX(40) chart.getRotation3D().setRotationY(270) chart.getRotation3D().setDepthPercents(150) # Take first chart series series = chart.getChartData().getSeries().get_Item(0) # Populating series data series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30)) # Take second chart series series = chart.getChartData().getSeries().get_Item(1) # Populating series data series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10)) series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60)) # Saving the presentation pres.save(data_dir + "3Drotation.pptx", Rjb::import('com.aspose.slides.SaveFormat').Pptx) puts "Done with rotation, please check the output file." end |