ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How to make primary keys available in legend for multi layer chart
Posted by Eirik on Aug-13-2013 17:22
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}'")

  Re: How to make primary keys available in legend for multi layer chart
Posted by Peter Kwan on Aug-13-2013 23:36
Hi Eirik,

You may consider to add the extra field to the layers instead (using Layer.addExtraField).

LineLayer.addExtraField(New String() { keys(0) })
BarLayer.addExtraField(New String() { keys(1) })

Hope this can help.

Regards
Peter Kwan

  Re: How to make primary keys available in legend for multi layer chart
Posted by Eirik on Aug-14-2013 15:57
Brilliant! Works like a charm, thanks