Jump to content
Software FX Community

Pie Charts Display labels


User (Legacy)

Recommended Posts

Hi,

I am using the chartfx web pie charts. I am trying to round off the

display of the value of each section to an integer By using CInt, however,

in order to make a complete 100% , chartfx puts the decimal there.

Code I am using is:

pieOverall.OpenData(COD.Values, 1, 4)

Dim d As DictionaryEntry

Dim i As Integer = 0

For Each d In col1

pieOverall.Value(0, i) = CInt(d.Value) -------LINE #5

pieOverall.AxisX.Label(i) = d.Key

i = i + 1

temp = d.Key

Dim pos1, pos2, num As Integer

pos1 = temp.IndexOf("(")

pos2 = temp.IndexOf(" ", pos1)

num = CInt(temp.Substring(pos1 + 1, pos2 - pos1 - 1))

total = total + num

Next

Session("TotalTests") = total

pieOverall.CloseData(COD.Values)

pieOverall.PointLabels = True

pieOverall.Export(FileFormat.Jpeg,

Server.MapPath("../Images/OverallTarget.jpg"))

NOW, on line # 5, as you can see, I am making the value an integer, however,

when it displays it on the chart, it is made a decimal i.e. if it is

59%, 16% and 24%( which is a total of 99%), it will make it 59.60,16.16 and

24.24% and display it, How can I remove the decimals and display this as

integers on the piechart.

Thanks

Link to comment
Share on other sites

What is displayed by default is the percentage that value represents out of

the total, not the value itself. So it doesn't matter that your values are

integer, the percentages may still contain decimals.

For example a chart containing 3 points of values 5,5 and 5 will display

33.33% for all the slices.

You can control the number of decimals displayed on the labels by doing:

chart.AxisY.LabelsFormat.Decimals = 0;

This will NOT round the percentage values, it will just round the LABELS

that are displayed. You can use the PointLabelMask property to change the

default behavior and display the actual values instead of the percentage.

Check the docs for details.

--

FP

Software FX

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...