Sha256: 988d2f4b03a2890a5d30a18ab801953537d7b198021327302f4d42444b373de0

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

module Asposeslidesjava
  module ChartLegend
    def initialize()
        # Setting Custom Location and Size for Chart legend
        set_location_and_size()
    end 

    def set_location_and_size()
        data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
                
        # Creating empty presentation
        pres = Rjb::import('com.aspose.slides.Presentation').new

        # Get reference of the slide
        slide = pres.getSlides().get_Item(0)

        # Add a clustered column chart on the slide
        chart = slide.getShapes().addChart(Rjb::import('com.aspose.slides.ChartType').ClusteredColumn, 50, 50, 500, 500)

        # Set Legend Properties
        chart.getLegend().setX(50 / chart.getWidth())
        chart.getLegend().setY (50 / chart.getHeight())
        chart.getLegend().setWidth(100 / chart.getWidth())
        chart.getLegend().setHeight(100 / chart.getHeight())

        # Saving the presentation
        save_format = Rjb::import('com.aspose.slides.SaveFormat')
        pres.save(data_dir + "Legend.pptx", save_format.Pptx)

        puts "Set custom location and size of chart legend, please check the output file."       
    end   
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asposeslidesjava-0.0.2 lib/asposeslidesjava/Charts/chartlegend.rb
asposeslidesjava-0.0.1 lib/asposeslidesjava/Charts/chartlegend.rb