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

Message ListMessage List     Post MessagePost Message

  Extra field legend mapping on stacked axis across multiple layers
Posted by Eirik on Nov-12-2013 20:59
Hi,
I have the following code (simplified):

Dim data0() As Double = {9.2, 9.1, 9.1, 9.1, 9.1, 9.2}
Dim data1() As Double = {100, 125, 100, 147, 67, 105}
Dim data2() As Double = {120, 105, 100, 127, 87, 90}
Dim labels() As String = {"Jan", "Feb", "Mar", "Apr", "May", "Jun"}

Dim c As XYChart = New XYChart(300, 300)
c.setPlotArea(50, 50, 200, 150)

Dim areaLayer1 As AreaLayer = c.addAreaLayer2(Chart.Side)
Dim areaLayer2 As AreaLayer = c.addAreaLayer2(Chart.Stack)
areaLayer1.setUseYAxis2(True)
areaLayer2.setUseYAxis2(False)

areaLayer1.addDataSet(data0, -1, "Series0")
areaLayer1.addExtraField(New String() {"ID0"})

areaLayer2.addDataSet(data1, -1, "Series1")
areaLayer2.addExtraField(New String() {"ID1"})

areaLayer2.addDataSet(data2, -1, "Series2")
areaLayer2.addExtraField(New String() {"ID2"})

c.xAxis().setLabels(labels)

Dim legendBox As LegendBox = c.addLegend(50, 0, False, "Arial", 7)

WebChartViewer1.Image = c.makeWebImage(Chart.PNG)

Dim url As String = [String].Format("javascript:alert('{0}');", "{dsField0}")
Dim legendImageMap As String = legendBox.getHTMLImageMap(url, " ", "title='Click for
additional information about [{dataSetName}]'")

WebChartViewer1.ImageMap = legendImageMap


It is a graph with two area layers with one dataset on the first layer and two datasets on
the second layer. The problem is the mapping of the extrafields (dsField0) to the
legendbox. The first series of each layer is mapped but not the second series (dataset)
on the second layer (apparently dsField0 is not indexed on multiple datasets across
layers). Using one layer for each dataset will work, but the stacked axis is lost.
Any suggestions on how to overcome this i.e. get the mapping for each series and have
stacked axis?

  Re: Extra field legend mapping on stacked axis across multiple layers
Posted by Peter Kwan on Nov-12-2013 23:54
Hi Eirik,

The code should be:

areaLayer1.addDataSet(data0, -1, "Series0")
areaLayer1.addExtraField(New String() {"ID0"})

areaLayer2.addDataSet(data1, -1, "Series1")
areaLayer2.addDataSet(data2, -1, "Series2")
areaLayer2.addExtraField(New String() {"ID1", "ID2"})

In other words, there is only one extra field for each layer, and the extra field is indexed by the data set number.

Hope this can help.

Regards
Peter Kwan

  Re: Extra field legend mapping on stacked axis across multiple layers
Posted by Eirik on Nov-13-2013 18:56
Thanks Peter for your info, i managed to make it work now.