OpenOffice Calc 自动化如何更改散点图的图表标签
Posted
技术标签:
【中文标题】OpenOffice Calc 自动化如何更改散点图的图表标签【英文标题】:OpenOffice Calc automation how alter a chart label of a scatter diagram 【发布时间】:2010-11-16 10:27:16 【问题描述】:您好,请您帮我解决以下问题。我创建了一个散点图并从列的数据中绘制了一个图表。使用的数据不只是在确定标签的单元格之后:
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
我希望 LABEL 单元格显示为 Y 列标签名称(现在是 'Column O'),但是如何? 据我所知(代码是 Delphi,但如果有人可以帮助我提供一个基本示例也可以):
(* Turn the symbol of the data points off *)
oChart.Diagram.SymbolType := _chartChartSymbolTypeNONE;
oDataSeries := oChart.getUsedData;
oDataSequences := oDataSeries.getDataSequences;
ShowMessage(oDataSequences[1].Label.SourceRangeRepresentation);
SourceRangeRepresentation 返回当前标签,但是如何更改?
感谢广告
【问题讨论】:
【参考方案1】:做到了:
(*
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);
【讨论】:
以上是关于OpenOffice Calc 自动化如何更改散点图的图表标签的主要内容,如果未能解决你的问题,请参考以下文章
如何根据公式自动选择 OpenOffice Calc 单元格?
在 OpenOffice Calc 中以编程方式更改打印区域