Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I'm been trying to learn Visual C# and I'm trying to do a customized piechart.
My data is about crime reports, and I just need to compute the frequency of each crime per location. I already did the label text to be the location names, but I can't change the legend text to be the crime type.
Here is my code behind:
C#
protected void Chart1_Load(object sender, EventArgs e)
      {
          //Piechat customization----close enough.
          Chart1.Series[0]["PieLabelStyle"] = "Outside";

          //Show crime types as legend----???
          Chart1.Series[0].LegendText = "#CrimeTypeValues";

          //Show locations on the piechart as labels..done!
          Chart1.Series[0].Label = "#VALX";


      }


Here's what I have done:
image link

Is there a way to show the crime type values as the legend text?


Here is my SQL query for my chart:
SQL
SELECT     TOP (100) PERCENT CrimeLocation, CrimeType, COUNT(CrimeType) AS CrimeCount, 100 * CONVERT(DECIMAL(4, 2), COUNT(CrimeLocation)) /
                          (SELECT     SUM(CrimeCount) AS Expr1
                            FROM          dbo.view_nonindex_summary) AS Frequency
FROM         dbo.tblInitialReport
GROUP BY CrimeType, CrimeLocation
ORDER BY Frequency DESC"


Thanks in advanced.
Posted
Updated 20-Mar-14 5:21am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900