I have a line chart with a decent smooth curve option.
It displays 2 data columns as separate lines (against an X axis by Date).
I thought it would be useful to be able to change the line colours and make dashes and dots.
However, I can't see any way of linking the Data Source to a set of modifiable Line Properties.
For example
range = a2:c13
column A is Date Logged (X axis)
column B is curve 1 (data source 1) (Y axis)
column C is curve 2 (data source 2) (Y axis)
Both B and C are Foreign Exchange Rates. The idea is to see how well one data source tracks the other.
I have a solid blue line for curve 1 and a solid red line for curve 2. It would be ideal, for the sake of presentation, if they could be made dashed or dotted.
How can I tell Charts that the line for Data Source 1 has to have "These" Line Properties, and that for Data Source 2 "Some Other" Properties?
Or is this not possible in macros?
Thanks in advance
David
Referring, if necessary, or for curiosity, to this earlier Post which has more detail but I marked it "Solved" because it was asking too high a level question to be useful and probably causing a bit of wasted time that way.
[Solved] Possible to program Line Properties in Chart?
[Solved] Possible to program Line Properties in Chart?
Last edited by misitu on Tue Jun 21, 2016 3:28 pm, edited 1 time in total.
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
Re: Is It Possible to program Line Properties in Chart?
This code works but it seems to have a problem when used more than once. The second data series, the one whose properties get modified, doesn't get plotted the second time and I haven't found a consistent way to fix that. I hope it gets you started on modifying line properties.
Code: Select all
Dim Rect As New com.sun.star.awt.Rectangle
Dim RangeAddress(0) As New com.sun.star.table.CellRangeAddress
Rect.X = 8000
Rect.Y = 1000
Rect.Width = 25000
Rect.Height = 10000
RangeAddress(0).Sheet = 0
RangeAddress(0).StartColumn = 0
RangeAddress(0).StartRow = 0
RangeAddress(0).EndColumn = 2
RangeAddress(0).EndRow = 12
Charts = ThisComponent.Sheets(1).Charts
'charts.removeByName("MyChart")
Charts.addNewByName("MyChart", Rect, RangeAddress(), True, True)
Chart = Charts.getByName("MyChart").EmbeddedObject
Chart.Diagram = Chart.createInstance("com.sun.star.chart.LineDiagram")
DataRowProp1 = Chart.Diagram.getDataRowProperties(1)
DataRowProp1.LineStyle = com.sun.star.drawing.LineStyle.DASH
DataRowProp1.LineDashName = "Fine Dashed"
DataRowProp1.LineColor = RGB(100,100,100)
DataRowProp1.LineWidth = 120
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.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Is It Possible to program Line Properties in Chart?
Thanks! I will follow that up.
I had recently and accidentally burrowed into a page I hadn't found earlier about Data Row Properties and was going to start work on that. Your example has given me a step forward.
Best regards, David
I had recently and accidentally burrowed into a page I hadn't found earlier about Data Row Properties and was going to start work on that. Your example has given me a step forward.
Best regards, David
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
Re: Is It Possible to program Line Properties in Chart?
A great help, FJCC.
I might have got there in another week! I didn't have a clue how to tie up the "data source" with its line properties.
I have a few more tasks that this is going to accelerate.
After
I added
with thanks and appreciation of your time taken to help
Best regards
David
I might have got there in another week! I didn't have a clue how to tie up the "data source" with its line properties.
I have a few more tasks that this is going to accelerate.
After
Code: Select all
ChartDoc.Diagram = ChartDoc.createInstance("com.sun.star.chart.LineDiagram") 'add copy of chart with B-spline Resolution 6 Polynomials
oDiagram = ChartDoc.getDiagram()
with oDiagram
.HasXAxisTitle = true
.XAxisTitle.String = "Transaction Month"
.HasYAxisTitle = true
.YAxisTitle.String = "Rate of Exchange"
.DataCaption = com.sun.star.chart.ChartDataCaption.NONE
.DataRowSource = com.sun.star.chart.ChartDataRowSource.COLUMNS
Code: Select all
DataRowProp0 = .getDataRowProperties(0)
with DataRowProp0
.LineStyle = com.sun.star.drawing.LineStyle.DASH
.LineDashName = "Fine Dashed"
.LineColor = RGB(100,0,0)
.LineWidth = 50
end with
DataRowProp1 = .getDataRowProperties(1)
with DataRowProp1
.LineStyle = com.sun.star.drawing.LineStyle.DASH
.LineDashName = "Fine Dotted"
.LineColor = RGB(100,100,100)
.LineWidth = 120
end with
Best regards
David
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic