Initially I thought creating an array based upon the label location and data location would work. Unfortunately after a few hours of testing, when indifferent locations the settings for labels in first column get confused.
May look into this further in near future but initial reaction is it is not something simple.
Do have an optional workaround. Found this post → Controlling Chart Legend Entries
Instead of creating using strings, got the data from the cells:
oData2 = Array(oSheet.getCellRangeByName( "D3" ).String,_
oSheet.getCellRangeByName( "D4" ).String,_
oSheet.getCellRangeByName( "D5" ).String)
Your noted labels would be:
oData2 = Array(oSheet.getCellRangeByName( "D17" ).String,_
oSheet.getCellRangeByName( "D19" ).String)
I believe oData2 is a “sequence”. And based upon code from Graph in calc with star basic (noted in a previous post of yours) this will insert the information into the legend:
oChartDoc.HasLegend = 1
While the above works (kludge in my estimation) what I had been trying to accomplish was to use an array of the sequences. Originally with the title and data separated I seemed to have no issue. The problem arose when the rows were not contiguous as in the stated question. After much back & forth, it turns out the confusion within is because of the placement of where
DataSourceLabelsInFirstColumn is set. By placing this at the end of the routine, and clearing
DataSourceLabelsInFirstRow there also, the displays worked as originally expected.
Will attach your original sample with the macro enclosed. Did run the chart 3x’s on the first sheet. Once with SCHO, once with VGSH and finally with both. Intentionally did this as with both the graph lines appear straight because of the small amount of deviation. May be other ways to address this but I think this is my end to this post.
Returned sample ------- SplitLegend.ods