Ask Your Question
0

how do i set colors of datarows in a linechart by macro?

asked 2017-02-23 11:47:02 +0200

ghon gravatar image

i can set axis colors like this: Chart.Diagram.XMainGrid.LineColor = RGB(192, 192, 192) (where Chart is ThisComponent.Sheets(0).Charts(0).EmbeddedObject) but how do i set the colors of the datalines ?

i've found "interface XColorScheme" with "getColorByIndex" in the docs but calling it like "Chart.Diagram.getColorByIndex(1)" gives me an error, not sure if "scheme" is the right thing to use in this case either.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2017-02-23 19:12:29 +0200

Ratslinger gravatar image

You can set line colors with:

    'Get first chart on specified sheet'
    oChart = thisComponent.Sheets.getByName("YOUR_SHEET").getCharts().getByIndex(0)
    oEmbeddedObject = oChart.getEmbeddedObject()
    oFirstDiagram = oEmbeddedObject.getFirstDiagram()
    oCoordinateSystems = oFirstDiagram.getCoordinateSystems()
    oXCoordinateSystem = oCoordinateSystems(0)
    oChartTypes = oXCoordinateSystem.getChartTypes()
    oXChartType = oChartTypes(0)
    oDataSeries = oXChartType.getDataSeries()
'Index indicates which line you are working with'
    oXDataSeries = oDataSeries(0)
'Line color to be used'
    oXDataSeries.Color = RGB(192, 192, 192)
edit flag offensive delete link more

Comments

@Ratslinger: well done!!
deep insight of the "API-Hell"

karolus gravatar imagekarolus ( 2017-02-23 20:07:33 +0200 )edit

@karolus Much appreciated.

Ratslinger gravatar imageRatslinger ( 2017-02-23 20:11:47 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-02-23 11:47:02 +0200

Seen: 78 times

Last updated: Feb 23 '17