Exemple #1
0
    private void loadLineChart()
    {
        LineChart1.ChartTitle = "Number of Umaapaw na Flush sa Isang Taon";

        LineChartSeries sample = new LineChartSeries();

        decimal[] set1 = {
                             new decimal(5),
                             new decimal(10),
                             new decimal(15),
                             new decimal(20),
                             new decimal(25),
                             new decimal(30),
                         };

        sample.Data = set1;
        sample.Name = "Amiel";
        sample.LineColor = "#000000";

        LineChart1.Series.Add(sample);

        LineChart1.DataBind();
    }
        private void BindChart()
        {
            // line chart is very slow to render when there are lots of data points
            // bar chart is much faster
            zgSales.Visible = false;
            lcSales.Visible = true;
            if (salesByMonthData == null) { salesByMonthData = CommerceReport.GetSalesByYearMonthByModule(moduleGuid); }

            StringBuilder categories = new StringBuilder();

            string comma = string.Empty;
            List<decimal> revenue = new List<decimal>();

            // original data is sorted descending on Y, M resorting here
            DataRow[] result = salesByMonthData.Select(string.Empty, "Y ASC, M ASC");

            int spaceInterval = 0;
            int totalItems = result.Length;
            int itemsAdded = 0;
            if (totalItems > 12)
            {
                spaceInterval = 4;
            }
            int nextItemToShow = 0;

            foreach (DataRow row in result)
            {
                categories.Append(comma);

                if (itemsAdded == nextItemToShow)
                {
                    categories.Append(row["Y"].ToString());
                    categories.Append("-");
                    categories.Append(row["M"].ToString());
                    nextItemToShow = itemsAdded + spaceInterval;
                }

                comma = ",";

                revenue.Add(Convert.ToDecimal(row["Sales"]));
                itemsAdded += 1;

            }

            lcSales.ChartTitle = Resource.SalesByMonthChartLabel;

            lcSales.CategoriesAxis = categories.ToString();
            LineChartSeries series = new LineChartSeries();
            series.Name = Resource.SalesByMonthChartSalesLabel;
            series.Data = revenue.ToArray();

            lcSales.Series.Add(series);

            //bcSales.CategoriesAxis
            //bcSales.Series.
        }