Hi Dilip,
You may use BaseChart.addLegend2 to create a LegendBox with two columns. By default, the legend entry will be filled from left to right, top to bottom, ordered by the layer, then by the dataset within the layer. So it probably will not be one column for each layer.
For your case, the easiest way I can think of is to disable ChartDirector from automatically inserting the legend entry. For example:
'No automatic legend entry
Call myAreaLayer.setLegendOrder(cd.NoLegend)
Call myLineLayer.setLegendOrder(cd.NoLegend)
Then you add the legend entry using your own code:
Set legendBox = c.addLegend(c.getPlotArea().getBottomY() + 40, c.getWidth() / 2, 2, "arial.ttf", 8)
Call legendBox.setLineStyleKey()
Call legendBox.setAlignment(cd.TopCenter)
Call legendBox.addKey("aaa", areaDataSet1Color)
Call legendBox.addKey("bbb", lineDataSet1Color, 2)
Call legendBox.addKey("ccc", areaDataSet2Color)
Call legendBox.addKey("ddd", lineDataSet2Color, 2)
In brief, you need to add an legend entry for a data set for the area layer, then for a data set for the line layer, then for the area layer, then for the line layer, and so on. If you have different number of datasets for the line and area layers, you would need to add an empty entry to fill the position that has no data set. An empty entry is:
Call legendBox.addKey("", cd.Transparent, 2)
Hope this can help.
Regards
Peter Kwan |