0
        protected void Page_Load(object sender, EventArgs e)
        {
            int count = 0;
            string[] categories = new string[100];
            double[] yValues = new double[100];

            SqlConnection conBudget = new SqlConnection(ConfigurationManager.ConnectionStrings["connMSJ"].ConnectionString);
            SqlCommand cmdCount = new SqlCommand("SELECT COUNT(*) AS COUNT FROM DailyBudget WHERE (Username=@username)", conBudget);
            SqlCommand cmdBudget = new SqlCommand("SELECT Foods, Clothes, Drinks, Entertaiment FROM DailyBudget WHERE (Username=@username)", conBudget);
            SqlCommand cmdColumnName = new SqlCommand("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='DailyBudget' ORDER BY ORDINAL_POSITION", conBudget);
            conBudget.Open();
            cmdCount.Parameters.AddWithValue("@username", Master.getUsername);
            cmdBudget.Parameters.AddWithValue("@username", Master.getUsername);

            SqlDataReader dtrCount = cmdCount.ExecuteReader();
            if (dtrCount.Read())
                count = Convert.ToInt32(dtrCount["COUNT"].ToString());
            dtrCount.Close();

            SqlDataReader dtrColumnName = cmdColumnName.ExecuteReader();
            if (dtrColumnName.Read())                
                //for (int i = 0, x = 1; i < count; i++,x++)
                //    categories[i] = dtrColumnName[x].ToString();            
            dtrColumnName.Close();

            SqlDataReader dtrBudget = cmdBudget.ExecuteReader();
            if (dtrBudget.Read())
                for(int i = 0; i < count; i++)
                    yValues[i] = Convert.ToDouble(dtrBudget[i].ToString());                
            dtrBudget.Close();
            conBudget.Close();

            double[]    yValuess = {0, 75.54, 60.45, 34.73, 85.42};
            string[]    xValues = {"France", "Canada", "Germany", "USA", "Italy"};
            insertChart(xValues, yValuess);
        }

        protected void insertChart(string[] xValues, double[] yValues)
        {
            pcBudget.Series["Series1"]["PieLabelStyle"] = "Outside";
            pcBudget.Series["Series1"].Points.DataBindXY(xValues, yValues);
            pcBudget.Series["Series1"].EmptyPointStyle.IsValueShownAsLabel = false;
            pcBudget.Series["Series1"].EmptyPointStyle.IsVisibleInLegend = false;
            pcBudget.Series["Series1"].LegendText = "#VALX #PERCENT{P2}";
            pcBudget.DataManipulator.Sort(PointSortOrder.Descending, pcBudget.Series["Series1"]);
        }

i hope my statement not wrong, but when i execute the label is still visible same as the legend.
which mean it doesn't work for me. P/S: dummy values used for testing.

1
Contributor
1
Reply
11
Views
3 Years
Discussion Span
Last Post by gahhon
0
        protected void insertChart(string[] xValues, double[] yValues)
        {
            pcBudget.Series["Series1"]["PieLabelStyle"] = "Outside";
            if (totalUsage == 0)
            {
                pcBudget.Titles["Title1"].Visible = false;
                pcBudget.Series["Series1"].EmptyPointStyle.IsValueShownAsLabel = false;
                pcBudget.Series["Series1"].EmptyPointStyle.IsVisibleInLegend = false;
            }
            else
            {
                pcBudget.Series["Series1"].Points.DataBindXY(xValues, yValues);
                pcBudget.Series["Series1"].EmptyPointStyle.IsValueShownAsLabel = false;
                pcBudget.Series["Series1"].EmptyPointStyle.IsVisibleInLegend = false;
                foreach (DataPoint dp in pcBudget.Series["Series1"].Points)
                    dp.IsEmpty = (dp.YValues[0] == 0) ? true : false;
                pcBudget.Series["Series1"].LegendText = "#VALX #PERCENT{P2}";
                pcBudget.DataManipulator.Sort(PointSortOrder.Descending, pcBudget.Series["Series1"]);
            }
        }

Problem Solved

  • foreach (DataPoint dp in chart1.Series[0].Points)
  • `dp.IsEmpty = (dp.YValues[0] == 0) ? true : false;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.