[Solved] LineDiagram in Calc - How to change the line width

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Marzio
Posts: 2
Joined: Thu May 27, 2010 5:40 pm

[Solved] LineDiagram in Calc - How to change the line width

Post by Marzio »

Hi to all,

I've a Basic macro that create a LineDiagram based on series of data stored in a Calc sheet.
Everything is ok but I'm not be able to change the width of the line that paint the diagram.
Can somebody help me ?

Here are my code:

Code: Select all

sub drawTrend(oSheetTrend as object, _
              oSheetData as object, _
              sTrendTitle as string, _
              sRange as string _
              )

   dim oCharts, oChart, oDiagram, oCellRangeAddress as object
   
   
   oCellRangeAddress = oSheetData.getCellRangeByName(sRange).getRangeAddress()
   'xray oCellRangeAddress
   
   oCharts = oSheetTrend.getCharts()
   'xray oCharts  
   oCharts.addNewByName("Trend", MakeRectangle(0000, 0000, 24800, 15200 ), Array( oCellRangeAddress ),True, True )

   oChart = oCharts.getByName( "Trend" ).getEmbeddedObject()
   oDiagram = oChart.createInstance("com.sun.star.chart.LineDiagram")

   oChart.HasMainTitle = True
   oChart.Title.String = sTrendTitle
   'oChart.HasSubTitle = True
   'oChart.Subtitle.String = "Subtitle String"
   oChart.HasLegend = True 
   oChart.Legend.Alignment = com.sun.star.chart.ChartLegendPosition.BOTTOM
   'oChart.Legend.FillStyle = com.sun.star.drawing.FillStyle.SOLID
   'oChart.Legend.FillColor = RGB(210, 210, 210)
   oChart.Legend.CharHeight = 7
   'oChart.Area.FillStyle = com.sun.star.drawing.FillStyle.BITMAP
   'oChart.Area.FillBitmapName = "Sky"
   'oChart.Area.FillBitmapMode = com.sun.star.drawing.BitmapMode.REPEAT
 
   'oChart.Diagram.Wall.FillStyle = com.sun.star.drawing.FillStyle.SOLID
   'oChart.Diagram.Wall.FillColor = RGB(00,132,209)
   
   ' Asse X
   oDiagram.HasXAxisGrid = false
   oDiagram.XMainGrid.LineColor = RGB(192, 192, 192)
   'oChart.Diagram.XAxis.Min = 0 
   'oChart.Diagram.XAxis.Max = 2000
   oDiagram.HasXAxisDescription = true
   oDiagram.HasXAxisTitle = false
   oDiagram.XAxisTitle.String = "Time"
   oDiagram.XAxis.StepMain = 50
   
   ' Asse Y
   oDiagram.HasYAxisGrid = True
   oDiagram.YMainGrid.LineColor = RGB(192, 192, 192)
   oDiagram.YAxis.Min = 0 
   oDiagram.YAxis.Max = 120
   oDiagram.HasYAxisTitle = true
   oDiagram.YAxisTitle.String = "Temperature °C"
   oDiagram.YAxis.StepMain = 5.0

end sub
Last edited by Marzio on Fri May 28, 2010 11:46 am, edited 1 time in total.
OpenOffice.org 3.2.0
Windows XP Sp2
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Chart LineDiagram in Calc - How to change the line width

Post by FJCC »

I found information here: http://www.oooforum.org/forum/viewtopic.phtml?t=12322 that I think answers your question. To change the line width (or any other property) of the line drawn for a data series, you can do the following. In this case the chart has two lines and I changed the width of each.

Code: Select all

Chart.Diagram = Chart.createInstance("com.sun.star.chart.LineDiagram")
DataRow0 = Chart.Diagram.getDataRowProperties(0)
DataRow0.LineWidth = 150
DataRow1 = Chart.Diagram.getDataRowProperties(1)
DataRow1.LineWidth = 200
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Marzio
Posts: 2
Joined: Thu May 27, 2010 5:40 pm

Re: Chart LineDiagram in Calc - How to change the line width

Post by Marzio »

Thanks you, it works :)
OpenOffice.org 3.2.0
Windows XP Sp2
Post Reply