The following example only gives the first primary key in the legend - due to the lack of
multiple datasets in the layers. The question is then, how to make the primary keys
available in the legend.
Dim data0() As Double = {23, 56, 35, 76, 45, 77}
Dim data1() As Double = {35, 76, 88, 76, 89, 90}
Dim labels() As String = {"Jan", "Feb", "Mar", "Apr", "May", "Jun"}
Dim keys() As String = {"pk1", "pk2"} ' corresponds to source of data "data0" and "data1"
Dim c As XYChart = New XYChart(300, 180)
c.setPlotArea(50, 20, 200, 130)
Dim LineLayer As ChartDirector.LineLayer = c.addLineLayer()
Dim BarLayer As BarLayer = c.addBarLayer()
LineLayer.addDataSet(data0, &HFF0000, "Source1")
BarLayer.addDataSet(data1, &HFF00, "Source2")
c.xAxis().setLabels(labels)
c.addExtraField(keys)
Dim legendBox As LegendBox = c.addLegend(50, 0, False, "Arial Bold", 8)
legendBox.setBackground(Chart.Transparent)
WebChartViewer1.Image = c.makeWebImage(Chart.PNG)
WebChartViewer1.ImageMap = legendBox.getHTMLImageMap("", " ", "title='Primary key for
{dataSetName}: {dsField0}'") |