开发者

OpenOffice Calc automation how alter a chart label of a scatter diagram

Hello could you please help me with the following. I have created a scattered chart and draw a chart from data of a column. The used data is not just after the cell which determines the label:

Column O:

Pwm1   <-- This is the cell I want to see as the label
27114  <-- not used data for graph
27055  <-- etc
27092
27070  <-- data for graph starts here
27105
27024
27092  <-- data for graph ends here

I would like the LABEL cell to app开发者_JAVA技巧ear as the Y column label name (Is now 'Column O'), but how? This as far as I got (code is Delphi but if someone could help me with a basic example that's ok too):

(* Turn the symbol of the data points off *)
oChart.Diagram.SymbolType := _chartChartSymbolTypeNONE;

oDataSeries := oChart.getUsedData;
oDataSequences := oDataSeries.getDataSequences;
ShowMessage(oDataSequences[1].Label.SourceRangeRepresentation);

SourceRangeRepresentation returns the current label, but how to change?

Thanks Ad


This did it:

(*
creat new DataSequence from range representaion
that provides real data and its role in the series
oDataProvider: com.sun.star.chart2.data.XDataProvider
sRangeRepresentation: range address e.g. Sheet1.A1:B2
sRole: role is defined in com.sun.star.chart2.data.DataSequenceRole
*)
Function CreateDataSequence( oDataProvider : Variant; sRangeRepresentation : String; sRole :String ) : Variant;
Var
        oDataSequence : Variant;

Begin
 (* create .chart2.data.DataSequence from range representation *)
 oDataSequence := oDataProvider.createDataSequenceByRangeRepresentation(sRangeRepresentation);
 If NOT VarIsEmpty(oDataSequence) Then
  oDataSequence.Role := sRole;

 Result := oDataSequence;
End;


oNewLabel := CreateDataSequence(oChart.getDataProvider, '$Sheet1.$O$7', 'label');
oDataSequences[1].setLabel(oNewLabel);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜