|
We want not to show label/score when score is 0%. How? |
Posted by Franky on Apr-23-2020 19:52 |
|
Hello Peter,
We have a question about a donut-diagram: when a score is zero, we do not want the label/score-combination to be shown in the graph. Can you help us out how to archive that? We still use ASP Classic.
[code start]
Set cd = CreateObject("ChartDirector.API")
data = Array(score_1,score_2,score_3,score_4,score_5,score_6,score_7)
labels = wordarray
colors = colorarray
Set c = cd.PieChart(1200, 550, cd.Transparent)
Call c.setPieSize(600, 250, 220)
'Draw the pie in 3D
angle = 35
Call c.set3D(-1, angle)
Call c.setTransparentColor(&Hffffff)
Call c.setNumberFormat(Chr(1), ",")
' Use the side label layout method
Call c.setLabelLayout(cd.SideLayout)
' Set the label box background color the same as the sector color, with glass effect, and with 5 pixels rounded corners
Set t = c.setLabelStyle()
Call t.setBackground(cd.SameAsMainColor, cd.Transparent)
Call t.setRoundedCorners(5)
' Set the border color of the sector the same color as the fill color. Set the line color of the join line to black (0x0)
Call c.setLineColor(cd.SameAsMainColor, &H808080)
' Distance to circle
Call c.setLabelPos(5, cd.LineColor)
Call c.setLabelFormat("{label} - {percent|0}%")
Call c.setLabelStyle("", 24, &H403232)
'Set the border color of the sector the same color as the fill color. Set the line color of the join line to black (0x0)
Call c.setLineColor(cd.SameAsMainColor, &H0)
Call c.setColors(cd.transparentPalette)
Call c.setStartAngle(-65)
'Set the pie data and the pie labels
Call c.setData(data, labels)
' Set the sector colors
Call c.setColors2(cd.DataColor, colors)
'output the chart
Response.ContentType = "image/png"
Response.BinaryWrite c.makeChart2(cd.PNG)
Response.End
[code end]
Thank you for your help.
Frank. |
Re: We want not to show label/score when score is 0%. How? |
Posted by Peter Kwan on Apr-23-2020 23:51 |
|
Hi Franky,
You can replace 0 with cd.NoValue. It is like:
For i = 0 to Ubound(data)
If data(i) = 0 Then data(i) = cd.NoValue
Next
If the data value is 0, ChartDIrector will display it as 0. If it is cd.NoValue, ChartDirector will not display anything.
Hope this can help.
Regards
Peter Kwan |
Re: We want not to show label/score when score is 0%. How? |
Posted by Franky on Apr-24-2020 02:59 |
|
Thank you, Peter! It works splendidly. |
|