|
HBar Missing Labels |
Posted by Bob Wood on May-14-2013 13:12 |
|
My hbar chart is arbitrarily hiding labels depending on the number h bars. If I have 2 or 3 it display all of the labels. 5-7 bars displays 3 or 4 labels. 19 bars display only 3 labels. I need to display all labels because they are the legend. I thought all labels were displayed by default unless specified with .SetLabelStep().
What am I missing?
Set oChartDirector = CreateObject("ChartDirector.API")
With oChartDirector
Set oChart = .XYChart(chartWidth, chartHeight, .metalColor(&Hccccff, 0), .Transparent, 1)
End With
With oChart
Call .setRoundedFrame( &Hffffff, 20)
Call .setDropShadow()
'Set the plot area
Call .setPlotArea (plotMarginLeft, plotMarginTop, plotWidth, plotHeight, &Hffffff, -1, -1, &Hcccccc, &Hcccccc)
'Add a bar chart layer using the given data.
Set layer = .addBarLayer(data, .gradientColor(100, 0, chartWidth, 0, &Hff0000, &Hffffff))
Call layer.setBarGap(0.20)
Call layer.set3D(5)
Call .swapXY(True)
'Set the labels on the x axis
Set textbox = .xAxis().setLabels(labels)
Call .xAxis().setLabelStep(1)
'Set the x axis label font to 10pt Arial Bold Italic
Call textbox.setFontStyle("arialbi.ttf")
Call textbox.setFontSize(8)
'Use the format passed in
Call layer.setAggregateLabelFormat("{value} ({gpercent|0.}%)")
End With
|
Re: HBar Missing Labels |
Posted by Peter Kwan on May-14-2013 22:55 |
|
Hi Bob,
Yes. By default, all labels are displayed. Is the code you have included already the exact and complete code? Is it possible there are some other lines of code that can affect the x-axis labelling?
I have perform a test with your code using hard coded data for 19 bars, and in my case, all labels are displayed. If you need further help, is it possible to create an example with hard coded data (eg. by modifying the data in my code), so I may try to reproduce the problem?
<%@ language="vbscript" %>
<%
Set oChartDirector = CreateObject("ChartDirector.API")
' The data for the bar chart
data = Array(3.9, 8.1, 10.9, 14.2, 18.1, 19.0, 21.2, 23.2, 25.7, 36, 3.9, 8.1, 10.9, 14.2, 18.1, 19.0, 21.2, 23.2, 25.7)
' The labels for the bar chart
labels = Array("Bastic Group", "Simpa", "YG Super", "CID", "Giga Tech", _
"Indo Digital", "Supreme", "Electech", "THP Thunder", "Flash Light", _
"Indo Digital", "Supreme", "Electech", "THP Thunder", "Flash Light", _
"Indo Digital", "Supreme", "Electech", "THP Thunder")
chartWidth = 700
chartHeight = 400
plotMarginLeft = 100
plotMarginTop = 20
plotWidth = 550
plotHeight = 350
With oChartDirector
Set oChart = .XYChart(chartWidth, chartHeight, .metalColor(&Hccccff, 0), .Transparent, 1)
End With
With oChart
Call .setRoundedFrame( &Hffffff, 20)
Call .setDropShadow()
'Set the plot area
Call .setPlotArea (plotMarginLeft, plotMarginTop, plotWidth, plotHeight, &Hffffff, -1, -1, &Hcccccc, &Hcccccc)
'Add a bar chart layer using the given data.
Set layer = .addBarLayer(data, .gradientColor(100, 0, chartWidth, 0, &Hff0000, &Hffffff))
Call layer.setBarGap(0.20)
Call layer.set3D(5)
Call .swapXY(True)
'Set the labels on the x axis
Set textbox = .xAxis().setLabels(labels)
Call .xAxis().setLabelStep(1)
'Set the x axis label font to 10pt Arial Bold Italic
Call textbox.setFontStyle("arialbi.ttf")
Call textbox.setFontSize(8)
'Use the format passed in
Call layer.setAggregateLabelFormat("{value} ({gpercent|0.}%)")
End With
' Output the chart
Response.ContentType = "image/png"
Response.BinaryWrite oChart.makeChart2(oChartDirector.PNG)
Response.End
%>
Regards
Peter Kwan
|
|