MBS Chart Director change legend icon CDLineLayerMBS

Hi Christian! And all,

I have a plot that consists of several CDLineLayers that is representing the “average” of some results. There is a similar plot with actual data points that includes scatter layers, and the legend of that one has line segments as the legend icon. The one with just linelayer has square symbols as legend icon. How can I use segments instead?


My plot code looks like the following, with one segment being the difference (plotting the actual data layers). I tried to add one scatterlayer outside the bounds of the plot but that didnt seem to set the legend:

[code]Dim c As New CDXYChartMBS(830, 440)

// Set the plotarea
Dim plotArea As CDPlotAreaMBS
plotArea = c.setPlotArea(60, 5, 585, 390)

//add legend
Dim legendArea As CDLegendBoxMBS
legendArea = c.addLegend(655, 150)

//set bg color
c.setBackground(&hf0f0f0) //bg xojo grey
plotArea.SetBackground(&hffffff) //plot area white

// use a loop to plot the actual data layers. This step is all that is different between the two plot types.
call c.addScatterLayer(xPlotArray, yPlotArray, SourceArray(x),c.kDiamondSymbol, 9, colorArray(x), colorArray(x)) ', “”, c.kDiamondSymbol, 11, colorArray(x), -1 )


Dim layerMean As CDLineLayerMBS
layerMean = c.AddLineLayer(K_EQ_P0, color.Black, “Mean”)

If DrawPM1 = True AND K_EQ_M1(0) > 0 Then // some have 0 or inf values for any +/- sigma s

Dim layerP1 As CDLineLayerMBS
layerP1 = c.AddLineLayer(K_EQ_P1, color.Gray, “+1?”)

Dim layerM1 As CDLineLayerMBS
layerM1 = c.AddLineLayer(K_EQ_M1, color.Gray, “-1?”)

drawSum = drawSum + 2

xBlankPlot = Array(-100.00)
yBlankPlot = Array(-100.00)

//added to try and get plot to use segments
call c.addScatterLayer(xBlankPlot, yBlankPlot, “”, c.kDiamondSymbol, 9, color.Red, color.Red)


Sorry, do you have some screenshots to show how this looks like and what you need?
And maybe a test project to work on?

[quote=429365:@Christian Schmitz]Sorry, do you have some screenshots to show how this looks like and what you need?
And maybe a test project to work on?[/quote]

Sure, here is a reproduction. Seems to not be an option to change legend icon when there are only line layers. Looking to make the icon into the same line segments as the lineLayer. Not a huge deal, I think it looks fine like this and works as just a color swatch so dont even need the segments. Just making an effort to appease a client. Thanks!

Here’s the full dataset with diamond tick legend icon

and the dataset with only averages/uncertainty bounds

First it may not good to confuse Xojo with naming control trackLineLegend and method trackLineLegend the same. Xojo things it may be the constructor. I’ll look into it

Sounds like you just need


for second graph.

Yes this is true, I copied this from the trackLineLegend example and just built on it, never bothered to change/thought it was intentional. Does indeed give a warning every time we open the project. And thanks again!