Macros/Basic/Calc/Gráficos

From The Document Foundation Wiki
Jump to navigation Jump to search
This page is a translated version of the page Macros/Basic/Calc/Graphs and the translation is 100% complete.
Other languages:
English • ‎español • ‎italiano

Regresar al índice

Gráficos en Calc

Columnas

De forma predeterminada, todos los nuevos gráficos son de Columnas

 1sub main()
 2dim mRangos(0)
 3dim rec as new com.sun.star.awt.Rectangle
 4
 5    doc = ThisComponent
 6    sheet = doc.CurrentController.ActiveSheet
 7    charts = sheet.charts
 8	
 9    chart_name = "MySuperGraph"
10    if charts.hasByName(chart_name) then
11        MsgBox "Chart exists"
12        exit sub
13    end if
14	
15    cell = sheet.getCellRangeByName("A1")
16    cursor = sheet.createCursorByRange(cell)
17    cursor.collapseToCurrentRegion()
18    mRangos(0) = cursor.RangeAddress	
19	
20    with rec
21        .X = 6000
22        .Y = 0         
23        .Width = 10000
24        .Height = 10000
25    end with
26	
27    charts.addNewByName(chart_name, rec, mRangos, True, True)	
28	
29end sub

Crear gráfico de columnas

Barras

Para cambiar a gráfico de Barras, solo cambiar la orientación.

1    charts.addNewByName(chart_name, rec, mRangos, True, True)	
2    chart = charts.getByName(chart_name).EmbeddedObject
3    chart.Diagram.Vertical = True

Crear gráfico de barras

Circular

1    charts.addNewByName(chart_name, rec, mRangos, True, True)	
2    chart = charts.getByName(chart_name).EmbeddedObject
3    chart.Diagram = chart.createInstance("com.sun.star.chart.PieDiagram")