Пример #1
0
        private void iniChart(AriClinicContext ctx1)
        {
            ctx1 = new AriClinicContext("AriClinicContext");
            IList<Professional> prof = CntAriCli.GetProfessionalTickets(fromDate, toDate, ctx1);
            chart1.PlotArea.XAxis.AutoScale = true;
            chart1.PlotArea.XAxis.Items.Clear();
            chart1.AutoLayout = true;
            chart1.ChartTitle.TextBlock.Visible=false;//.Text = "Servicios por profesional.";
            chart1.PlotArea.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
            chart1.PlotArea.Appearance.FillStyle.MainColor = Color.Transparent;
            ChartSeries chartSeries1 = new ChartSeries();
            chartSeries1.Type = ChartSeriesType.Pie;
            chartSeries1.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            foreach (Professional item in prof)
            {
                ChartSeriesItem serieItem = new ChartSeriesItem();
                serieItem.YValue = (from tic in item.Tickets
                                    where tic.TicketDate >= fromDate && tic.TicketDate <= toDate
                                    select tic).ToList<Ticket>().Count();
                serieItem.Name = item.FullName;
                serieItem.Label.TextBlock.Text = item.Tickets.Count.ToString();
                serieItem.Appearance.Exploded = true;
                chartSeries1.Items.Add(serieItem);
            }

            chart1.Series.Clear();
            chart1.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] { chartSeries1 });  
        }
Пример #2
0
        private void AddNewSeries(UniversalEntity ue)
        {
            ChartSeries cs = new ChartSeries(radWP.SelectedText, ChartSeriesType.Spline);

            RadChart1.Series.Add(cs);
            int i = 0;
            List <ChartSeriesItem> csc = new List <ChartSeriesItem>();

            foreach (ArrayList al in ue)
            {
                ChartSeriesItem csi = new ChartSeriesItem();

                csi.YValue = (Convert.ToDouble(al[0]));
                csi.XValue = (i);
                //csi.XValue=(Convert.ToDateTime(al[1]).Ticks);

                //cs.AddItem((Convert.ToDouble(al[0]));
                i++;

                csc.Add(csi);
            }

            cs.AddItem(csc);

            RadChart1.DataBind();
            RadChart1.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Normal;
        }
        private void UpdateBasedOnTournamentsSeries(Dictionary <TournamentChartSeries, List <ChartSeriesItem> > chartSeriesItems, IList <Tournaments> tournaments)
        {
            var chartItemDataBuilder = CreateTournamentChartItemDataBuilder(ChartDisplayRange);

            var tournamentRecords = chartItemDataBuilder.Create(tournaments, TournamentChartFilterType);

            foreach (var tournament in tournamentRecords)
            {
                foreach (var chartSerie in ChartCollection.Where(x => !x.IsBasedOnStatistic))
                {
                    ChartSeriesItem previousChartSeriesItem = null;
                    ChartSeriesItem chartSeriesItem         = null;

                    if (!chartSeriesItems.ContainsKey(chartSerie))
                    {
                        chartSeriesItems.Add(chartSerie, new List <ChartSeriesItem>());
                    }

                    chartSeriesItem = new ChartSeriesItem
                    {
                        Format                 = chartSerie.Format,
                        Category               = tournament.Started,
                        PointColor             = chartSerie.ColorsPalette.PointColor,
                        TrackBallColor         = chartSerie.ColorsPalette.TrackBallColor,
                        TooltipColor           = chartSerie.ColorsPalette.TooltipColor,
                        TooltipForegroundColor = chartSerie.ColorsPalette.TooltipForeground
                    };

                    previousChartSeriesItem = chartSeriesItems[chartSerie].LastOrDefault();
                    chartSeriesItems[chartSerie].Add(chartSeriesItem);

                    chartSerie.UpdateChartSeriesItemByTournament?.Invoke(chartSeriesItem, previousChartSeriesItem, tournament);
                }
            }
        }
Пример #4
0
        private void iniChart(AriClinicContext ctx1)
        {
            ctx1 = new AriClinicContext("AriClinicContext");
            IList <Invoice> invoices = CntAriCli.GetInvoices(fromDate, toDate, ctx1);

            chart1.PlotArea.XAxis.AutoScale = true;
            chart1.PlotArea.XAxis.Items.Clear();
            chart1.AutoLayout = true;
            chart1.ChartTitle.TextBlock.Visible           = false;
            chart1.PlotArea.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
            //chart1.PlotArea.Appearance.FillStyle.MainColor = Color.Transparent;
            ChartSeries chartSeries1 = new ChartSeries();

            chartSeries1.Type = ChartSeriesType.Bar;
            chartSeries1.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            ChartSeriesItem serieItem = new ChartSeriesItem();

            var rs = from inv in (List <Invoice>)invoices
                     where inv.InvoiceDate >= fromDate && inv.InvoiceDate <= toDate
                     group inv by new { inv.InvoiceDate.Year, inv.InvoiceDate.Month } into g
                select new { Datos = g.Key, Total = g.Sum(inv => inv.Total) };

            foreach (var item in rs)
            {
                serieItem.YValue = (double)item.Total;
                serieItem.Name   = item.Datos.Month + "/" + item.Datos.Year;
                serieItem.Label.TextBlock.Text = item.Total.ToString();
                serieItem.Appearance.Exploded  = true;
                chartSeries1.Items.Add(serieItem);
            }

            chart1.Series.Clear();
            chart1.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] { chartSeries1 });
        }
        private void iniChart(AriClinicContext ctx1)
        {
            ctx1 = new AriClinicContext("AriClinicContext");
            IList <Professional> prof = ctx1.Professionals.ToList <Professional>();

            chart1.PlotArea.XAxis.AutoScale = true;
            chart1.PlotArea.XAxis.Items.Clear();
            chart1.AutoLayout = true;
            chart1.ChartTitle.TextBlock.Visible            = false;//.Text = "Servicios por profesional.";
            chart1.PlotArea.Appearance.FillStyle.FillType  = Telerik.Reporting.Charting.Styles.FillType.Solid;
            chart1.PlotArea.Appearance.FillStyle.MainColor = Color.Transparent;
            ChartSeries chartSeries1 = new ChartSeries();

            chartSeries1.Type = ChartSeriesType.Pie;
            chartSeries1.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            foreach (Professional item in prof)
            {
                ChartSeriesItem serieItem = new ChartSeriesItem();
                int             num       = (from inv in item.ProfessionalInvoices
                                             where inv.InvoiceDate >= fromDate && inv.InvoiceDate <= toDate
                                             select inv).ToList <ProfessionalInvoice>().Count();
                if (num > 0)
                {
                    serieItem.YValue = num;
                    serieItem.Name   = item.FullName;
                    serieItem.Label.TextBlock.Text = num.ToString();
                    serieItem.Appearance.Exploded  = true;
                    chartSeries1.Items.Add(serieItem);
                }
            }

            chart1.Series.Clear();
            chart1.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] { chartSeries1 });
        }
Пример #6
0
        protected void UsageChartDataBinding()
        {
            Telerik.Charting.ChartSeries s = new Telerik.Charting.ChartSeries();

            RChartCDProUsage.Series.Add(s);

            List <UsageItem> us = new List <UsageItem>();

            DataView dv = (DataView)SqlDataSource1.Select(System.Web.UI.DataSourceSelectArguments.Empty);

            if (dv != null)
            {
                foreach (DataRowView dr in dv)
                {
                    ChartSeriesItem item = new ChartSeriesItem();

                    item.Name   = dr["BillDt"].ToString();
                    item.YValue = (double)dr["UsageSummary"];
                    item.Label.TextBlock.Text = (item.YValue / 1000).ToString() + "K";

                    s.Items.Add(item);
                }

                RChartCDProUsage.Series[0].Appearance.LegendDisplayMode =
                    Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;//生成Item模式
                RChartCDProUsage.Series[0].Type = Telerik.Charting.ChartSeriesType.Pie;
                RChartCDProUsage.Series[0].Appearance.ShowLabelConnectors = true;
                RChartCDProUsage.Series[0].Appearance.FillStyle.FillType  = Telerik.Charting.Styles.FillType.ComplexGradient;
            }
        }
Пример #7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            const double hourStep = 1 / 24.0;
            //const double minuteStep = hourStep / 60;
            const double fiveMinuteStep = hourStep / 12;

            double startTime = new DateTime(2008, 1, 1, 8, 0, 0, 0).ToOADate();
            double endTime   = new DateTime(2008, 1, 1, 17, 0, 0, 0).ToOADate();

            radChart1.PlotArea.XAxis.AddRange(startTime, endTime, hourStep);

            Random r = new Random();

            ChartSeries series = radChart1.Series[0];

            series.Items.Clear();


            for (double currentTime = startTime; currentTime < endTime; currentTime += fiveMinuteStep)
            {
                ChartSeriesItem item = new ChartSeriesItem();
                item.XValue = currentTime + (r.NextDouble() - 0.5) * fiveMinuteStep;
                item.YValue = 7065 + (r.NextDouble() - 0.5) * 90;
                series.Items.Add(item);
            }

            radChart1.Series.Add(series);
        }
Пример #8
0
        public Form1()
        {
            InitializeComponent();

            radChart1.PlotArea.YAxis.AxisMode = Telerik.Charting.ChartYAxisMode.Extended;

            //construct a new series and add items with random data to it
            ChartSeries series = radChart1.CreateSeries("point", Color.Blue, Color.LightBlue, ChartSeriesType.Point);

            series.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.White;
            for (int i = 0; i < 6; ++i)
            {
                ChartSeriesItem item = new ChartSeriesItem();
                item.YValue = rand.Next(1, 10);
                item.XValue = i;

                series.Items.Add(item);
            }

            radChart1.Series.Clear();
            //add series to the chart
            radChart1.Series.Add(series);

            radChart1.SkinsOverrideStyles = true;
            radChart1.Skin = "Apple";
            radChart1.ChartTitle.TextBlock.Text = "Point";

            this.EnabledQSFButtons = QSFButtons.None;
        }
Пример #9
0
        private void iniChart(AriClinicContext ctx1)
        {
            ctx1 = new AriClinicContext("AriClinicContext");
            IList <Professional> prof = CntAriCli.GetSurgeonTickets(fromDate, toDate, ctx1);

            chart1.PlotArea.XAxis.AutoScale = true;
            chart1.PlotArea.XAxis.Items.Clear();
            chart1.AutoLayout = true;
            chart1.ChartTitle.TextBlock.Visible            = false;//.Text = "Servicios por profesional.";
            chart1.PlotArea.Appearance.FillStyle.FillType  = Telerik.Reporting.Charting.Styles.FillType.Solid;
            chart1.PlotArea.Appearance.FillStyle.MainColor = Color.Transparent;
            ChartSeries chartSeries1 = new ChartSeries();

            chartSeries1.Type = ChartSeriesType.Pie;
            chartSeries1.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            foreach (Professional item in prof)
            {
                ChartSeriesItem serieItem = new ChartSeriesItem();
                int             num       = CntAriCli.GetTicketsByCirujano(fromDate, toDate, item.PersonId.ToString(), ctx1).Count;
                if (num > 0)
                {
                    serieItem.YValue = num;
                    serieItem.Name   = item.FullName;
                    serieItem.Label.TextBlock.Text = num.ToString();
                    serieItem.Appearance.Exploded  = true;
                    chartSeries1.Items.Add(serieItem);
                }
            }

            chart1.Series.Clear();
            chart1.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] { chartSeries1 });
        }
Пример #10
0
        private void iniChart(AriClinicContext ctx1)
        {
            ctx1 = new AriClinicContext("AriClinicContext");
            IList<Professional> prof = CntAriCli.GetSurgeonTickets(fromDate, toDate, ctx1);
            chart1.PlotArea.XAxis.AutoScale = true;
            chart1.PlotArea.XAxis.Items.Clear();
            chart1.AutoLayout = true;
            chart1.ChartTitle.TextBlock.Visible=false;//.Text = "Servicios por profesional.";
            chart1.PlotArea.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
            chart1.PlotArea.Appearance.FillStyle.MainColor = Color.Transparent;
            ChartSeries chartSeries1 = new ChartSeries();
            chartSeries1.Type = ChartSeriesType.Pie;
            chartSeries1.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            foreach (Professional item in prof)
            {
                ChartSeriesItem serieItem = new ChartSeriesItem();
                int num = CntAriCli.GetTicketsByCirujano(fromDate, toDate, item.PersonId.ToString(), ctx1).Count;
                if (num > 0)
                {
                    serieItem.YValue = num;
                    serieItem.Name = item.FullName;
                    serieItem.Label.TextBlock.Text = num.ToString();
                    serieItem.Appearance.Exploded = true;
                    chartSeries1.Items.Add(serieItem);
                }
            }

            chart1.Series.Clear();
            chart1.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] { chartSeries1 });  
        }
        void SetSeriesItemColor(ChartSeriesItem seriesItem, Brush color)
        {
            string colorToSet = GetStringToSetAsColor(color);

            if (colorToSet != null)
            {
                seriesItem.color = colorToSet;
            }
        }
Пример #12
0
        protected override void CreateChildControls()
        {
            string[] colors = { "#FFDA43", "#2F89C2", "#F267CD", "#79E364", "#EB5D2D", "#42AE18", "#FF9C40", "#B99A72", "#9BC0FF", "#98CC88", "#C3B600" };
            chart                  = new RadChart();
            chart.UseSession       = false;
            chart.TempImagesFolder = "~/_layouts/temp";
            chart.RadControlsDir   = "~/_layouts/radcontrols/RadControls/";

            ChartSeries chartSeries = new ChartSeries();

            chart.AddChartSeries(chartSeries);
            ChartTitle title = new ChartTitle();


            ChartSeries series = chart.GetChartSeries(0);

            series.Name = surveyQuestion;

            chart.Legend.HAlignment  = ChartHAlignment.Center;
            chart.Legend.VAlignment  = ChartVAlignment.Bottom;
            chart.Legend.LegendStyle = LegendItemsPositionType.Row;


            response               = GetSurveyResponse("http://server/sites/techresources/", "http://server/sites/techresources/Lists/Survey2");
            title.Text             = surveyQuestion;
            title.TextFont         = new Font("Verdana", 7);
            chart.Chart.ChartTitle = title;

            series.Clear();
            series.DiameterScale            = 0.40;
            series.ShowLabelConnectors      = false;
            series.ShowLabels               = true;
            series.LabelAppearance.Distance = 7;
            series.LabelAppearance.TextFont = new Font("Verdana", 7);
            series.NotOverlapLabels         = true;
            series.Type = ChartSeriesType.Pie;
            ColorConverter cc = new ColorConverter();
            int            i  = 0;

            foreach (Response res in response)
            {
                ChartSeriesItem seriesItem = new ChartSeriesItem();
                seriesItem.YValue                 = res.totalResponse;
                seriesItem.ItemMap.ToolTip        = res.choiceName;
                seriesItem.Label                  = res.totalResponse.ToString();
                seriesItem.Appearance.MainColor   = (Color)cc.ConvertFromString(colors[i++]);
                seriesItem.Appearance.BorderColor = Color.DimGray;
                seriesItem.Appearance.FillStyle   = FillStyle.Solid;
                seriesItem.Name = res.choiceName;
                series.Items.Add(seriesItem);
            }
            chart.Skin = "LightGreen";
            this.Controls.Add(chart);
        }
Пример #13
0
        /// <summary>
        /// Creates a <see cref="ChartSeriesItem"/> for a pie chart.
        /// </summary>
        /// <param name="value">The value of the pie slice.</param>
        /// <param name="resourceKey">The resource key for the label text.</param>
        /// <param name="fillColor">Color with which to fill the region.</param>
        /// <returns>
        /// A <see cref="ChartSeriesItem"/> for a pie chart with the given value and text
        /// </returns>
        private ChartSeriesItem GetPieChartSeriesItem(double value, string resourceKey, Color fillColor)
        {
            ChartSeriesItem chartSeriesItem = new ChartSeriesItem(value);

            chartSeriesItem.Name = chartSeriesItem.ActiveRegion.Tooltip = Localization.GetString(resourceKey, this.LocalResourceFile);
            if (fillColor != Color.Empty)
            {
                chartSeriesItem.Appearance.FillStyle.MainColor   = Color.FromArgb(0xa0, fillColor);
                chartSeriesItem.Appearance.FillStyle.SecondColor = fillColor;
            }

            return(chartSeriesItem);
        }
Пример #14
0
        /// <summary>
        /// Proceeds the type of the pie.
        /// </summary>
        /// <param name="dataTable">The data table.</param>
        private void ProceedPieType(DataTable dataTable)
        {
            foreach (DataRow row in dataTable.Rows)
            {
                for (int i = 0; i < AnalyticSeriesList.Count; i++)
                {
                    if (row[AnalyticSeriesList[i].Dictionary] != DBNull.Value &&
                        !string.IsNullOrEmpty(AnalyticSeriesList[i].Dictionary) &&
                        (string)row[AnalyticSeriesList[i].Dictionary] != AnalyticSeriesList[i].Title)
                    {
                        continue;
                    }

                    var yAxis = AnalyticYAxisList[i];
                    if (AnalyticSeriesSum[i] == -1)
                    {
                        AnalyticSeriesSum[i] = 0;
                    }
                    AnalyticSeriesSum[i] += double.Parse(row[yAxis.SystemName].ToString());
                }
            }

            var chartSeries = new ChartSeries
            {
                Name = "",
                Type = CurrentChartSeriesType,
                DefaultLabelValue = string.Empty
            };

            rcChart.Series.Add(chartSeries);

            chartSeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            for (int i = 0; i < AnalyticSeriesSum.Count; i++)
            {
                if (AnalyticSeriesSum[i] == -1)
                {
                    continue;
                }

                var chartSeriesItem = new ChartSeriesItem
                {
                    YValue = AnalyticSeriesSum[i], Name = AnalyticSeriesList[i].Title
                };
                chartSeriesItem.Label.TextBlock.Text = AnalyticSeriesSum[i].ToString();
                chartSeries.Items.Add(chartSeriesItem);
            }
        }
Пример #15
0
        /// <summary>
        /// Fills the event log chart.
        /// </summary>
        private void FillEventLogChart()
        {
            this.EventLogChart.ChartTitle.TextBlock.Text = Localization.GetString("Event Log Entries by Type.Text", this.LocalResourceFile);
            this.EventLogChart.PlotArea.EmptySeriesMessage.TextBlock.Text = Localization.GetString("EmptyEventLogMessage.Text", this.LocalResourceFile);

            int?portalId = this.UserInfo.IsSuperUser ? (int?)null : this.PortalId;

            using (IDataReader eventLogReader = DataProvider.Instance().GetEventLogSummaryByType(portalId))
            {
                while (eventLogReader.Read())
                {
                    string          eventLogTypeCssClass = (string)eventLogReader["LogTypeCssClass"];
                    ChartSeriesItem eventLogItem         = this.GetPieChartSeriesItem((int)eventLogReader["Count"], eventLogTypeCssClass, GetEventLogTypeColor(eventLogTypeCssClass));
                    this.EventLogChart.Series[0].Items.Add(eventLogItem);
                }
            }
        }
Пример #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dt = from k in _entities.GetBienDongNhanSu() orderby k.namsinh select k;
            List <GetBienDongNhanSu_Result> newLstBienDong = new List <GetBienDongNhanSu_Result>();
            List <GetBienDongNhanSu_Result> lstBienDong    = dt.ToList();
            int?SumNV = lstBienDong[0].soNV;

            for (int i = 1; i < lstBienDong.Count; i++)
            {
                SumNV += lstBienDong[i].soNV;
                lstBienDong[i].soNV = SumNV;
                newLstBienDong.Add(lstBienDong[i]);
            }
            RadChart1.Series[0].DataYColumn           = "soNV";
            RadChart1.PlotArea.XAxis.DataLabelsColumn = "namsinh";
            RadChart1.DataSource = newLstBienDong;
            RadChart1.DataBind();

            RadChart2.IntelligentLabelsEnabled = false;
            List <GetTyLeNamNu_Result> lstTyLe = _entities.GetTyLeNamNu().ToList();
            ChartSeries serie = new ChartSeries();

            serie.Name = "Giới tính";
            serie.Type = ChartSeriesType.Pie;
            serie.Clear();
            serie.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
            ChartSeriesItem item1 = new ChartSeriesItem();

            item1.YValue = (double)lstTyLe[0].Nam;
            //item1.Name = "Nam";
            item1.Appearance.Exploded  = true;
            item1.Label.TextBlock.Text = "Nam" + " - #%";
            serie.Items.Add(item1);

            ChartSeriesItem item2 = new ChartSeriesItem();

            item2.YValue = (double)lstTyLe[0].Nu;
            //item2.Name = "Nữ";
            item2.Appearance.Exploded  = true;
            item2.Label.TextBlock.Text = "Nữ" + " - #%";

            serie.Items.Add(item2);
            RadChart2.Series.Add(serie);
        }
Пример #17
0
        private void iniChartWeekProfessional(AriClinicContext ctx1)
        {
            ctx1 = new AriClinicContext("AriClinicContext");
            IList <Ticket> tickets = CntAriCli.GetTickets(fromDate, toDate, ctx1);

            chart1.PlotArea.XAxis.Items.Clear();
            //chart1.PlotArea.XAxis.Appearance.TextAppearance.
            chart1.Legend.Visible = true;
            //chart1.PlotArea.XAxis.AddRange(0, 1, 1);
            chart1.PlotArea.XAxis.AutoScale   = false;
            chart1.PlotArea.XAxis.LayoutMode  = Telerik.Reporting.Charting.Styles.ChartAxisLayoutMode.Inside;
            chart1.Appearance.BarWidthPercent = (decimal)5.00;
            chart1.AutoLayout = true;
            chart1.ChartTitle.TextBlock.Visible           = false;
            chart1.PlotArea.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
            //chart1.PlotArea.Appearance.FillStyle.MainColor = Color.Transparent;
            ChartSeries chartSeries1 = new ChartSeries();

            chartSeries1.Type = ChartSeriesType.StackedBar;
            chartSeries1.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            var rs = from tick in (List <Ticket>)tickets
                     where tick.TicketDate >= fromDate && tick.TicketDate <= toDate && tick.GetType().ToString().Equals("AriCliModel.AnestheticTicket")
                     group tick by new { tick.TicketDate.Year, WeekNumber = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(tick.TicketDate, CalendarWeekRule.FirstDay, DayOfWeek.Monday), tick.Professional.FullName } into g
                select new { Datos = g.Key, Total = g.Sum(tick => tick.Amount) };

            ChartSeriesItem serieItem;

            foreach (var item in rs)
            {
                serieItem        = new ChartSeriesItem();
                serieItem.YValue = (double)item.Total;
                chart1.PlotArea.XAxis.AddItem(new ChartAxisItem(item.Datos.WeekNumber + "/" + item.Datos.Year));
                chart1.PlotArea.YAxis.AddItem(new ChartAxisItem(String.Format("{0:#.##}", item.Total)));
                serieItem.Label.TextBlock.Text = String.Format("{0:#.##}", item.Total);
                serieItem.Appearance.Exploded  = true;
                //serieItem.Name = item.Datos.FullName;
                chartSeries1.AddItem(serieItem);
            }

            chart1.Series.Clear();
            chart1.Series.Add(chartSeries1);
        }
Пример #18
0
        private void iniChartMonth(AriClinicContext ctx1)
        {
            ctx1 = new AriClinicContext("AriClinicContext");
            IList <Ticket> tickets = CntAriCli.GetTickets(fromDate, toDate, ctx1);

            chart1.PlotArea.XAxis.Items.Clear();
            chart1.PlotArea.XAxis.AutoScale = false;

            chart1.PlotArea.XAxis.AutoScale   = false;
            chart1.PlotArea.XAxis.LayoutMode  = Telerik.Reporting.Charting.Styles.ChartAxisLayoutMode.Inside;
            chart1.Appearance.BarWidthPercent = (decimal)5.00;

            chart1.AutoLayout = true;
            chart1.ChartTitle.TextBlock.Visible           = false;
            chart1.PlotArea.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
            //chart1.PlotArea.Appearance.FillStyle.MainColor = Color.Transparent;
            ChartSeries chartSeries1 = new ChartSeries();

            chartSeries1.Type = ChartSeriesType.StackedArea;
            chartSeries1.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            var rs = from tick in (List <Ticket>)tickets
                     where tick.TicketDate >= fromDate && tick.TicketDate <= toDate && tick.GetType().ToString().Equals("AriCliModel.AnestheticTicket")
                     group tick by new { tick.TicketDate.Year, tick.TicketDate.Month } into g
                select new { Datos = g.Key, Total = g.Sum(tick => tick.Amount) };

            ChartSeriesItem serieItem;

            foreach (var item in rs)
            {
                serieItem        = new ChartSeriesItem();
                serieItem.YValue = (double)item.Total;
                serieItem.Name   = item.Datos.Month + "/" + item.Datos.Year;
                serieItem.Label.TextBlock.Text = item.Total.ToString();
                serieItem.Appearance.Exploded  = true;
                chartSeries1.AddItem(serieItem);
            }

            chart1.Series.Clear();
            chart1.Series.Add(chartSeries1);
        }
Пример #19
0
        public Form1()
        {
            InitializeComponent();

            radChart1.Series.Clear();
            radChart1.Skin = "LightBlue";
            ChartSeries cs = new ChartSeries();

            cs.Items.Add(new ChartSeriesItem(0, 3));

            ChartSeriesItem csi = new ChartSeriesItem(1, 6);

            cs.Items.Add(csi);

            ChartSeriesItem csi1 = new ChartSeriesItem(2, 4);

            csi1.Empty = true;
            cs.Items.Add(csi1);

            cs.Items.Add(new ChartSeriesItem(3, 3));
            cs.Items.Add(new ChartSeriesItem(4, 8));
            cs.Type = ChartSeriesType.SplineArea;


            radChart1.Series.Add(cs);

            radChart1.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Normal;
            radChart1.PlotArea.XAxis.AutoScale  = false;
            radChart1.PlotArea.XAxis.MaxValue   = 4;
            radChart1.PlotArea.XAxis.MinValue   = 0;
            radChart1.PlotArea.XAxis.Step       = 1;

            cs.Appearance.Border.Width = 5;
            radChart1.Update();

            this.EnabledQSFButtons = QSFButtons.None;
        }
Пример #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            const double hourStep       = 1 / 24.0;
            const double minuteStep     = hourStep / 60;
            const double fiveMinuteStep = minuteStep * 5;

            double startTime = new DateTime(2008, 1, 1, 8, 0, 0, 0).ToOADate();
            double endTime   = new DateTime(2008, 1, 1, 17, 0, 0, 0).ToOADate();

            RadChart1.PlotArea.XAxis.AddRange(startTime, endTime, hourStep);

            Random      r = new Random();
            ChartSeries s = RadChart1.Series[0];

            for (double currentTime = startTime; currentTime < endTime; currentTime += fiveMinuteStep)
            {
                ChartSeriesItem item = new ChartSeriesItem();
                item.XValue = currentTime + (r.NextDouble() - 0.5) * fiveMinuteStep;
                item.YValue = 7065 + (r.NextDouble() - 0.5) * 90;
                s.Items.Add(item);
            }

            double today     = DateTime.Now.Date.ToOADate();
            double lastMonth = DateTime.Now.Date.AddMonths(-1).ToOADate();
            RadChart2.PlotArea.XAxis.AddRange(lastMonth, today, 1);
            s = RadChart2.Series[0];
            for (double currentDate = lastMonth; currentDate <= today; currentDate++)
            {
                ChartSeriesItem item = new ChartSeriesItem();
                item.YValue = 7065 + (r.NextDouble() - 0.5) * 90;
                s.Items.Add(item);
            }
        }
    }
        protected void LoadPieChart()
        {
            teacherCountChart.DataSource = _countData;
            teacherCountChart.DataBind();

            // Handle Legend Labels
            teacherCountChart.Series.Clear();
            var nSeries = new ChartSeries();

            teacherCountChart.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
            teacherCountChart.PlotArea.Appearance.FillStyle.FillType = FillType.Solid;
            teacherCountChart.PlotArea.Appearance.Border.Color = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");

            teacherCountChart.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 8);
            teacherCountChart.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 8);

            nSeries.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.Black;
            nSeries.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 8);     

           

            nSeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
            var count = 0;

            foreach (DataRow dr in _countData.Rows)
            {
                var value = DataIntegrity.ConvertToDouble(dr["TeacherCount"]);
                var myItem = new ChartSeriesItem(value) { Name = dr["Label"].ToString() };
                myItem.Appearance.FillStyle.MainColor = System.Drawing.ColorTranslator.FromHtml(StyleController.GetPieChartColor(dr["Label"].ToString(), count++));
                myItem.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;

                if (value <= 0) myItem.Label.Visible = false;
                nSeries.Type = ChartSeriesType.Pie;
                nSeries.AddItem(myItem);
            }

            teacherCountChart.Series.Add(nSeries);
        }
Пример #22
0
    protected void PopulatePie()
    {
        rc_pie.Legend.Clear();

        // Define and customise chart series
        ChartSeries cs = new ChartSeries("cs_offices", ChartSeriesType.Pie);

        cs.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
        cs.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
        cs.Appearance.TextAppearance.TextProperties.Font  = new Font("Verdana", 7, FontStyle.Regular);
        rc_pie.PlotArea.XAxis.AddRange(1, 4, 1);
        rc_pie.PlotArea.XAxis.IsZeroBased = false;
        rc_pie.PlotArea.YAxis.AxisMode    = ChartYAxisMode.Extended;
        rc_pie.Series.Add(cs);
        rc_pie.Legend.Appearance.Position.Auto            = true;
        rc_pie.Legend.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.TopRight;

        for (int i = 0; i < offices.Rows.Count; i++)
        {
            // Office vars
            String office         = (String)offices.Rows[i]["Office"];
            Color  colour         = Util.ColourTryParse((String)offices.Rows[i]["Colour"]);
            String StartDate      = "";
            String EndDate        = "";
            double target         = 0;
            String UniqueFeatures = "0";
            double avg_yield      = 0;
            String PageRate       = "0";
            String TopSalesman    = "";
            String BiggestFeature = "";
            String TopGenerator   = "";
            String BookName       = "";
            double daily_target   = 0;
            int    DaysLeft       = 0;

            int    latest_book_id     = 0;
            int    office_time_offset = Util.GetOfficeTimeOffset(office);
            String daysLeft           = "(DATEDIFF(EndDate, DATE_ADD(DATE_ADD(NOW(), INTERVAL -1 DAY),INTERVAL @offset HOUR)) - " +
                                        "((DATEDIFF(EndDate, DATE_ADD(DATE_ADD(NOW(), INTERVAL -1 DAY),INTERVAL @offset HOUR))/7) * 2)) as calculatedDaysLeft "; ///7) * 2))+1

            String qry = "SELECT SalesBookID, IssueName, StartDate, EndDate, Target, DaysLeft, " + daysLeft +
                         "FROM db_salesbookhead " +
                         "WHERE Office=@office " +
                         "ORDER BY StartDate DESC LIMIT 1";
            DataTable book_head_info = SQL.SelectDataTable(qry,
                                                           new String[] { "@office", "@offset" },
                                                           new Object[] { office, office_time_offset });

            if (book_head_info.Rows.Count > 0)
            {
                latest_book_id = Convert.ToInt32(book_head_info.Rows[0]["SalesBookID"]);
                qry            = "SELECT ROUND(IFNULL(CONVERT(SUM(Price*Conversion), SIGNED),0)- " +
                                 "IFNULL((SELECT CONVERT(SUM(rl_price*Conversion), SIGNED) FROM db_salesbook WHERE rl_sb_id=@sb_id AND red_lined=1),0)) as total_price " +
                                 "FROM db_salesbook sb, db_salesbookhead sbh " +
                                 "WHERE sb.sb_id=@sb_id " +
                                 "AND sbh.SalesBookID=@sb_id " +
                                 "AND deleted=0 AND IsDeleted=0";
                DataTable dt_total_price = SQL.SelectDataTable(qry, "@sb_id", latest_book_id);

                if (dt_total_price.Rows.Count > 0 && dt_total_price.Rows[0]["total_price"] != DBNull.Value)
                {
                    double price = Convert.ToDouble(dt_total_price.Rows[0]["total_price"]);

                    String[] top = new String[3] {
                        "rep", "list_gen", "feature"
                    };
                    for (int j = 0; j < top.Length; j++)
                    {
                        qry = "SELECT " + top[j] + " as val, CONVERT(SUM(price*conversion), SIGNED) as s FROM db_salesbook WHERE sb_id=@sb_id AND deleted=0 AND IsDeleted=0 GROUP BY " + top[j] + " ORDER BY CONVERT(SUM(price*conversion), SIGNED) DESC LIMIT 1";
                        DataTable tmp = SQL.SelectDataTable(qry, "@sb_id", latest_book_id);
                        if (tmp.Rows.Count > 0)
                        {
                            if (j == 0)
                            {
                                TopSalesman = tmp.Rows[0]["val"] + " (" + Util.TextToCurrency((Convert.ToDouble(tmp.Rows[0]["s"])).ToString(), "usd") + ")";
                            }
                            else if (j == 1)
                            {
                                TopGenerator = tmp.Rows[0]["val"] + " (" + Util.TextToCurrency((Convert.ToDouble(tmp.Rows[0]["s"])).ToString(), "usd") + ")";
                            }
                            else if (j == 2)
                            {
                                BiggestFeature = tmp.Rows[0]["val"] + " (" + Util.TextToCurrency((Convert.ToDouble(tmp.Rows[0]["s"])).ToString(), "usd") + ")";
                            }
                        }
                    }

                    // Book head details
                    BookName  = book_head_info.Rows[0]["IssueName"].ToString();
                    StartDate = book_head_info.Rows[0]["StartDate"].ToString().Substring(0, 10);
                    EndDate   = book_head_info.Rows[0]["EndDate"].ToString().Substring(0, 10);
                    target    = Convert.ToDouble(book_head_info.Rows[0]["Target"]);

                    if (book_head_info.Rows[0]["DaysLeft"].ToString() != "0")
                    {
                        DaysLeft = Convert.ToInt32(book_head_info.Rows[0]["DaysLeft"]);
                    }
                    else
                    {
                        DaysLeft = Convert.ToInt32(book_head_info.Rows[0]["calculatedDaysLeft"]);
                    }

                    if (DaysLeft == 0)
                    {
                        daily_target = (target - price);
                    }
                    else
                    {
                        daily_target = (target - price) / DaysLeft;
                    }

                    // Book data details
                    qry = "SELECT " +
                          "COUNT(DISTINCT feature) AS UniqueFeatures, " +
                          "(CONVERT(SUM(price*conversion), SIGNED)/COUNT(DISTINCT feature)) AS AvgYield, " +
                          "(SELECT page_rate FROM db_salesbook WHERE page_rate != 1 AND deleted = 0 AND sb_id=@sb_id ORDER BY ent_date DESC LIMIT 1) AS PageRate " +
                          "FROM db_salesbook  " +
                          "WHERE deleted=0 AND IsDeleted=0 AND sb_id=@sb_id";
                    DataTable book_info = SQL.SelectDataTable(qry, "@sb_id", latest_book_id);

                    if (book_info.Rows.Count > 0)
                    {
                        UniqueFeatures = book_info.Rows[0]["UniqueFeatures"].ToString();
                        if (book_info.Rows[0]["AvgYield"] != DBNull.Value)
                        {
                            avg_yield = Convert.ToDouble(book_info.Rows[0]["AvgYield"]);
                        }

                        PageRate = book_info.Rows[0]["PageRate"].ToString();
                    }

                    ChartSeriesItem csi_item = new ChartSeriesItem(
                        price,
                        Util.TextToCurrency(price.ToString(), "usd"),
                        colour);

                    csi_item.ActiveRegion.Attributes = "onmouseover=\"this.parentNode.parentNode.style.cursor='pointer'; this.parentNode.parentNode.style.cursor='hand';\" " +
                                                       "onmouseout=\"this.parentNode.parentNode.style.cursor='default'\"; " +
                                                       "onclick=\"alert('Hover over this segment to see detailed book stats.');\" return true;\"";
                    csi_item.Appearance.FillStyle.SecondColor = Color.Transparent;
                    csi_item.Name = office;
                    csi_item.ActiveRegion.Tooltip = "<b><font color=\"#00008B\">" + office + "</font><font color=\"Black\"><br/>Latest Book</b><br/><br/></font>"
                                                    + " <font color=\"Green\">Latest</font> book <font color=\"Black\"><b>(" + StartDate + " - " + EndDate + ")</b></font><br/>"
                                                    + " <font color=\"#1E90FF\">Target :  </font><font color=\"Black\">" + Util.TextToCurrency(target.ToString(), "usd") + "<br/><br/></font>"
                                                    + " <font color=\"#CD5C5C\">Total Revenue :  </font><font color=\"Black\">" + Util.TextToCurrency(price.ToString(), "usd") + " </font><br/>"
                                                    + " <font color=\"#008B8B\">Days Left :  </font><font color=\"Black\">" + DaysLeft + "</font><br/>"
                                                    + " <font color=\"#32CD32\">Daily Target :  </font><font color=\"Black\">" + Util.TextToCurrency(daily_target.ToString(), "usd") + "</font><br/>"
                                                    + " ----------------------------------<br/>"
                                                    + " <font color=\"#FF7F50\">Unique Features :  </font><font color=\"Black\">" + UniqueFeatures + "</font><br/>"
                                                    + " <font color=\"#FF0000\">Avg. Yield :  </font><font color=\"Black\">" + Util.TextToCurrency(avg_yield.ToString(), "usd") + "</font><br/>"
                                                    + " <font color=\"#00BFFF\">Page Rate :  </font><font color=\"Black\">" + PageRate + "</font><br/>"
                                                    + " ----------------------------------<br/>"
                                                    + " <font color=\"#B22222\">Top Salesman :  </font><font color=\"Black\">" + TopSalesman + "</font><br/>"
                                                    + " <font color=\"#4B0082\">Top Generator :  </font><font color=\"Black\">" + TopGenerator + "</font><br/>"
                                                    + " <font color=\"#008080\">Biggest Feature :  </font><font color=\"Black\">" + BiggestFeature + "</font><br/>"
                                                    + "</font><br/></font>Navigate to this book using the Budget Hub.<br/>For more information use the Sales Book Output page.";
                    cs.AddItem(csi_item);
                }
            }
        }
    }
Пример #23
0
        protected void UsageChartDataBinding()
        {
            Telerik.Charting.ChartSeries s = new Telerik.Charting.ChartSeries();

            RChartCDProUsage.Series.Add(s);

            List<UsageItem> us = new List<UsageItem>();

            DataView dv = (DataView)SqlDataSource1.Select(System.Web.UI.DataSourceSelectArguments.Empty);

            if (dv != null)
            {
                foreach (DataRowView dr in dv)
                {
                    ChartSeriesItem item = new ChartSeriesItem();

                    item.Name=dr["BillDt"].ToString();
                    item.YValue=(double)dr["UsageSummary"];
                    item.Label.TextBlock.Text = (item.YValue/1000).ToString() + "K";

                    s.Items.Add(item);
                }

                RChartCDProUsage.Series[0].Appearance.LegendDisplayMode =
                    Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;//生成Item模式
                RChartCDProUsage.Series[0].Type = Telerik.Charting.ChartSeriesType.Pie;
                RChartCDProUsage.Series[0].Appearance.ShowLabelConnectors = true;
                RChartCDProUsage.Series[0].Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.ComplexGradient;
            }
        }
Пример #24
0
        /// <summary>
        /// Creates a <see cref="ChartSeriesItem"/> for a pie chart.
        /// </summary>
        /// <param name="value">The value of the pie slice.</param>
        /// <param name="resourceKey">The resource key for the label text.</param>
        /// <param name="fillColor">Color with which to fill the region.</param>
        /// <returns>
        /// A <see cref="ChartSeriesItem"/> for a pie chart with the given value and text
        /// </returns>
        private ChartSeriesItem GetPieChartSeriesItem(double value, string resourceKey, Color fillColor)
        {
            ChartSeriesItem chartSeriesItem = new ChartSeriesItem(value);
            chartSeriesItem.Name = chartSeriesItem.ActiveRegion.Tooltip = Localization.GetString(resourceKey, this.LocalResourceFile);
            if (fillColor != Color.Empty)
            {
                chartSeriesItem.Appearance.FillStyle.MainColor = Color.FromArgb(0xa0, fillColor);
                chartSeriesItem.Appearance.FillStyle.SecondColor = fillColor;
            }

            return chartSeriesItem;
        }
Пример #25
0
        /// <summary>
        /// Proceeds the type of the non pie.
        /// </summary>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="dataTable">The data table.</param>
        private void ProceedNonPieType(DateTime startDate, DateTime endDate, DataTable dataTable)
        {
            if (dataTable.Rows.Count == 0 || AnalyticSeriesList.Count == 0)
            {
                return;
            }

            foreach (DataRow row in dataTable.Select("1=1", AnalyticXAxisList[0].SystemName + " ASC"))
            {
                for (int i = 0; i < AnalyticSeriesList.Count; i++)
                {
                    if (!string.IsNullOrEmpty(AnalyticSeriesList[i].Dictionary) &&
                        (row[AnalyticSeriesList[i].Dictionary] == DBNull.Value ||
                         (string)row[AnalyticSeriesList[i].Dictionary] != AnalyticSeriesList[i].Title))
                    {
                        continue;
                    }

                    var chartSeriesItem = new ChartSeriesItem();

                    double value = 0;
                    ProceedAxis(row, AnalyticXAxisList[i].SystemName, rcChart.PlotArea.XAxis, startDate, endDate, dataTable.Rows.Count, ref value);
                    if (value != -1)
                    {
                        chartSeriesItem.XValue = value;
                    }

                    value = 0;
                    ProceedAxis(row, AnalyticYAxisList[i].SystemName, rcChart.PlotArea.YAxis, startDate, endDate, dataTable.Rows.Count, ref value);

                    if (!(row[AnalyticXAxisList[i].SystemName] is DateTime))
                    {
                        if (AnalyticXAxisList[i].SystemName != "Period")
                        {
                            var rows =
                                dataTable.Select(string.Format("{0} = '{1}' AND {2} = '{3}'",
                                                               AnalyticXAxisList[i].SystemName,
                                                               row[AnalyticXAxisList[i].SystemName],
                                                               AnalyticSeriesList[i].Dictionary,
                                                               AnalyticSeriesList[i].Title));
                            if (rows.Count() > 1)
                            {
                                value = rows.Sum(dataRow => double.Parse(dataRow[AnalyticSeriesList[i].SystemNameValue].ToString()));
                            }
                        }
                    }

                    if (!(row[AnalyticYAxisList[i].SystemName] is DateTime))
                    {
                        if (AnalyticYAxisList[i].SystemName != "Period" && !string.IsNullOrEmpty(AnalyticSeriesList[i].Dictionary))
                        {
                            var rows = dataTable.Select(string.Format("{0} = '{1}' AND {2} = '{3}'",
                                                                      AnalyticSeriesList[i].Dictionary,
                                                                      AnalyticSeriesList[i].Title,
                                                                      AnalyticXAxisList[i].SystemName,
                                                                      row[AnalyticXAxisList[i].SystemName]));
                            if (rows.Count() > 1)
                            {
                                value = rows.Sum(dataRow => double.Parse(dataRow[AnalyticSeriesList[i].SystemNameValue].ToString()));
                            }
                        }
                    }

                    if (value != -1)
                    {
                        chartSeriesItem.YValue = value;
                    }
                    rcChart.Series[i].Items.Add(chartSeriesItem);
                }
            }
        }
    private void fillChartData()
    {
        int iCountExercises = 0;
        int iHeight = 0;
        bool bWeightFlg = false;
        string[] saBMIGraph = new string[365];
        int iBMIGraph = 0;
        DateTime dCurrentDate = DateTime.Now;
        DateTime dTwoWeks = (DateTime)dCurrentDate.AddDays(-14);

        DataSet DS = objBackofficeClass.Mem_GET_UserInfo(Membership.GetUser().UserName);
        lblBMIHeight.Text = DS.Tables[0].Rows[0]["HEIGHT"].ToString() + " BMIHeight";
        iHeight = Convert.ToInt32(DS.Tables[0].Rows[0]["HEIGHT"]);

           // DS = objBackofficeClass.Mem_GET_UserAssessments_BY_UserId(gsUserID);
        //lblLevelID.Text = DS.Tables[0].Rows[0]["LEVEL_ID"].ToString() + " LEVEL_ID";
        //lblAssessmentScore.Text = DS.Tables[0].Rows[0]["ASSESSMENT_SCORE"].ToString() + "";

        DS = objPALClass.PAL_GET_PalStarts(gsUserID, "1", "0");

        string sNumSteps = DS.Tables[0].Rows[0]["NUM_STEPS"].ToString();
        string sProgramCurrentStep = DS.Tables[0].Rows[0]["PROGRAM_CURRENT_STEP"].ToString();

        DS = objPALClass.PAL_GET_PalEntries_BY_UserId(gsUserID, dCurrentDate.AddDays(-giChartDaySpan).ToString(), dCurrentDate.ToString());

         ChartSeries chChartSeries = RadChart1.Series[0];
        ChartSeriesItem CSI;
        TimeSpan TS =  new TimeSpan();
        foreach (DataRow DR in DS.Tables[0].Rows)
        {
            CSI = new ChartSeriesItem();

            int iCurrentDateAverage = 0;
            while ((DateTime)DR["PAL_ENTRY_DATE"] > Convert.ToDateTime(gaDates[iCurrentDateAverage, 0]) && iCurrentDateAverage < giArraySize - 1)//Gert to correct average group
            {
                iCurrentDateAverage++;
            }

            if (DR["PAL_ENTRY_WEIGHT"].ToString() != "" && iHeight.ToString() != "0")
            {
                int iBMI = (Convert.ToInt32(DR["PAL_ENTRY_WEIGHT"]) * 703 / (iHeight * iHeight));
                if (bWeightFlg == false)
                {
                    lblBMIWeight.Text = DR["PAL_ENTRY_WEIGHT"].ToString() + " BMIWeight";
                    bWeightFlg = true;
                }
                try
                {
                    gaDates[iCurrentDateAverage, 1] = (Convert.ToDouble(gaDates[iCurrentDateAverage, 1]) + (Convert.ToDouble(iBMI) / 10)).ToString();
                    gaDates[iCurrentDateAverage, 2] = (Convert.ToInt32(gaDates[iCurrentDateAverage, 2]) + 1).ToString();
                }
                catch (Exception e)
                { }

                saBMIGraph[iBMIGraph] = DR["PAL_ENTRY_WEIGHT"].ToString();
                iBMIGraph++;
            }

        }
        if (cbBMI.Checked)
        {
            /*
            Response.Write("</br>RadChart1.PlotAreaX " + RadChart1.PlotArea.XAxis.Items.Count.ToString() + " x " + RadChart1.PlotArea.XAxis.Items[0].Value.ToString() + " x " + RadChart1.PlotArea.XAxis.Items[RadChart1.PlotArea.XAxis.Items.Count - 1].Value.ToString() + "</br>");
            Response.Write("RadChart1.PlotAreaX " + RadChart1.PlotArea.YAxis.Items.Count.ToString() + " x " + RadChart1.PlotArea.YAxis.Items[0].Value.ToString() + " x " + RadChart1.PlotArea.YAxis.Items[RadChart1.PlotArea.YAxis.Items.Count - 1].Value.ToString() + "</br>");
            Response.Write("RadChart1.PlotAreaX " + RadChart1.PlotArea.YAxis2.Items.Count.ToString() + " x " + RadChart1.PlotArea.YAxis2.Items[0].Value.ToString() + " x " + RadChart1.PlotArea.YAxis2.Items[RadChart1.PlotArea.YAxis2.Items.Count - 1].Value.ToString() + "</br>");

            Response.Write("XAvis values: " + RadChart1.PlotArea.XAxis.Items[0].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[1].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[2].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[3].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[4].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[5].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[6].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[7].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[8].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[9].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[10].Value.ToString() + ", ");
            Response.Write(RadChart1.PlotArea.XAxis.Items[11].Value.ToString());
            */
                for (int i = 0; i < giArraySize; i++)
                {
                    if (gaDates[i, 2] != "0" && gaDates[i, 2] != "" && gaDates[i, 2] != null)
                    {
                        CSI = new ChartSeriesItem();
                        CSI.YValue = Convert.ToDouble(gaDates[i, 1]) / Convert.ToInt32(gaDates[i, 2]);
                        TS = DateTime.Now - Convert.ToDateTime(gaDates[i, 0]);

                        CSI.XValue = Convert.ToDouble(gaDates[i, 3]);//(giChartDaySpan - TS.Days);

                        chChartSeries.AddItem(CSI);//, Convert.ToDateTime(DR["PAL_ENTRY_DATE"].ToString(),"dd,MM,yyyy").ToString());

                    }
                }
        }

        //clear out the array data for the next field.
        for (int i = 0; i < giArraySize; i++)
        {
            gaDates[i, 1] = "0";
            gaDates[i, 2] ="0";
        }

        DS = objDDClass.DD_GET_DdEntries_BY_UserId(gsUserID, dCurrentDate.AddDays(-giChartDaySpan).ToString(), dCurrentDate.ToString());

        chChartSeries = RadChart1.Series[1];
        TS = new TimeSpan();
        foreach (DataRow DR in DS.Tables[0].Rows)
        {
            CSI = new ChartSeriesItem();

            int iCurrentDateAverage = 0;
            while ((DateTime)DR["DD_ENTRY_DATE"] > Convert.ToDateTime(gaDates[iCurrentDateAverage, 0]))//Gert to correct average group
            {
                iCurrentDateAverage++;
            }

            if (DR["LV_FIELD_01"].ToString() != "" && DR["LV_FIELD_01"].ToString() != "0")
            {
                int iSleep = Convert.ToInt32(DR["LV_FIELD_01"]);

                gaDates[iCurrentDateAverage, 1] = (Convert.ToDouble(gaDates[iCurrentDateAverage, 1]) + (Convert.ToDouble(iSleep))).ToString();
                gaDates[iCurrentDateAverage, 2] = (Convert.ToInt32(gaDates[iCurrentDateAverage, 2]) + 1).ToString();

                saBMIGraph[iBMIGraph] = DR["LV_FIELD_01"].ToString();
                iBMIGraph++;
            }
        }

        if (cbSleep.Checked)
        {

            for (int i = 0; i < giArraySize; i++)
            {
                if (gaDates[i, 2] != "0" && gaDates[i, 2] != "" && gaDates[i, 2] != null)
                {
                    CSI = new ChartSeriesItem();
                    CSI.YValue = Convert.ToDouble(gaDates[i, 1]) / Convert.ToInt32(gaDates[i, 2]);
                    TS = DateTime.Now - Convert.ToDateTime(gaDates[i, 0]);

                    CSI.XValue = Convert.ToDouble(gaDates[i, 3]);//(giChartDaySpan - TS.Days);

                    chChartSeries.AddItem(CSI);//, Convert.ToDateTime(DR["PAL_ENTRY_DATE"].ToString(),"dd,MM,yyyy").ToString());
                }
            }
        }

        //clear out the array data for the next field.
        for (int i = 0; i < giArraySize; i++)
        {
            gaDates[i, 1] = "0";
            gaDates[i, 2] = "0";
        }

        DS = objDDClass.DD_GET_DdEntries_BY_UserId(gsUserID, dCurrentDate.AddDays(-giChartDaySpan).ToString(), dCurrentDate.ToString());

        chChartSeries = RadChart1.Series[2];
        TS = new TimeSpan();
        foreach (DataRow DR in DS.Tables[0].Rows)
        {
            CSI = new ChartSeriesItem();

            int iCurrentDateAverage = 0;
            while ((DateTime)DR["DD_ENTRY_DATE"] > Convert.ToDateTime(gaDates[iCurrentDateAverage, 0]))//Gert to correct average group
            {
                iCurrentDateAverage++;
            }

            if (DR["LV_FIELD_02"].ToString() != "" && DR["LV_FIELD_02"].ToString() != "0")
            {
                int iSleep = Convert.ToInt32(DR["LV_FIELD_02"]);
               // Response.Write(gaDates[iCurrentDateAverage, 1].ToString() + ",  ");

                gaDates[iCurrentDateAverage, 1] = (Convert.ToDouble(gaDates[iCurrentDateAverage, 1]) + (Convert.ToDouble(iSleep))).ToString();
                gaDates[iCurrentDateAverage, 2] = (Convert.ToInt32(gaDates[iCurrentDateAverage, 2]) + 1).ToString();

                saBMIGraph[iBMIGraph] = DR["LV_FIELD_02"].ToString();
                iBMIGraph++;
            }
        }

        if (cbStress.Checked)
        {

            for (int i = 0; i < giArraySize; i++)
            {
                if (gaDates[i, 2] != "0" && gaDates[i, 2] != "" && gaDates[i, 2] != null)
                {
                    CSI = new ChartSeriesItem();
                    CSI.YValue = Convert.ToDouble(gaDates[i, 1]) / Convert.ToInt32(gaDates[i, 2]);
                    TS = DateTime.Now - Convert.ToDateTime(gaDates[i, 0]);
                  //  Response.Write(CSI.YValue.ToString()+"  ");
                    CSI.XValue = Convert.ToDouble(gaDates[i, 3]);//(giChartDaySpan - TS.Days);

                    chChartSeries.AddItem(CSI);//, Convert.ToDateTime(DR["PAL_ENTRY_DATE"].ToString(),"dd,MM,yyyy").ToString());
                }
            }
        }

        //clear out the array data for the next field.
        for (int i = 0; i < giArraySize; i++)
        {
            gaDates[i, 1] = "0";
            gaDates[i, 2] = "0";
        }

        DS = objPALClass.PAL_GET_PalEntries_BY_UserId(gsUserID, dCurrentDate.AddDays(-giChartDaySpan).ToString(), dCurrentDate.ToString());

        chChartSeries = RadChart1.Series[3];
        TS = new TimeSpan();
        foreach (DataRow DR in DS.Tables[0].Rows)
        {
            CSI = new ChartSeriesItem();

            //Response.Write(((DateTime)DR["PAL_ENTRY_DATE"]).ToString() + " </br> " );

            int iCurrentDateAverage = 0;
            while ((DateTime)DR["PAL_ENTRY_DATE"] > Convert.ToDateTime(gaDates[iCurrentDateAverage, 0]) && iCurrentDateAverage < giArraySize - 1)//Gert to correct average group
            {

                iCurrentDateAverage++;
            }

            if (DR["MET_EQUIVALENT"].ToString() != "")
            {
                int iMET = Convert.ToInt32(DR["MET_EQUIVALENT"]) / 10;

                gaDates[iCurrentDateAverage, 1] = (Convert.ToDouble(gaDates[iCurrentDateAverage, 1]) + (Convert.ToDouble(iMET))).ToString();
                gaDates[iCurrentDateAverage, 2] = (Convert.ToInt32(gaDates[iCurrentDateAverage, 2]) + 1).ToString();

                saBMIGraph[iBMIGraph] = DR["MET_EQUIVALENT"].ToString();
                iBMIGraph++;
            }
        }

        for (int i = 0; i < iBMIGraph; i++)
        {
            lblBMIGraph.Text = lblBMIGraph.Text + " (" + saBMIGraph[i] + "," + lblBMIHeight.Text + " ) ";

        }

        if (cbMET.Checked)
        {

            for (int i = 0; i < giArraySize; i++)
            {
                if (gaDates[i, 2] != "0" && gaDates[i, 2] != "" && gaDates[i, 2] != null)
                {
                    CSI = new ChartSeriesItem();
                    CSI.YValue = Convert.ToDouble(gaDates[i, 1]) / Convert.ToInt32(gaDates[i, 2]);
                    TS = DateTime.Now - Convert.ToDateTime(gaDates[i, 0]);

                    CSI.XValue = Convert.ToDouble(gaDates[i, 3]);//(giChartDaySpan - TS.Days);

                    chChartSeries.AddItem(CSI);//, Convert.ToDateTime(DR["PAL_ENTRY_DATE"].ToString(),"dd,MM,yyyy").ToString());
                }
            }
        }
    }
    private void fillRadChart_PAL_Duration(string sFromDate, string sFilter_AccountFrom)
    {
        RadChart_PAL_Duration.Chart.Series[0].Items.Clear();

        DateTime dtMonthStart = Convert.ToDateTime(sFromDate);
        string sMonthStart = dtMonthStart.ToString("MM/01/yyyy");
        string sMonthEnd = dtMonthStart.AddMonths(1).AddSeconds(-1).ToString();

        DataSet DS = objReportClass.Rpt_REPORT_ListPal_Duration(UC_Visitlog_Visitlog1.ACCOUNT_ID, sFilter_AccountFrom, sMonthStart, sMonthEnd);

        //12 possible colors
        Color[] MainColor = new Color[] {   Color.LightGoldenrodYellow, Color.LightGray, Color.LightCyan, Color.YellowGreen, Color.LightSkyBlue,  Color.Violet,      Color.Orange,    Color.Khaki,         Color.DeepPink, Color.LightGreen, Color.LightBlue, Color.LightPink};
        Color[] SecondColor = new Color[] { Color.Goldenrod,            Color.DarkGray,  Color.Cyan,      Color.Honeydew,    Color.SlateBlue,     Color.Purple,      Color.OrangeRed, Color.Tan,           Color.Red,      Color.Green,      Color.Blue,      Color.Pink};
        Color[] TextColor = new Color[] {   Color.DarkGoldenrod,        Color.Gray,      Color.DarkCyan,  Color.Olive,       Color.DarkSlateBlue, Color.DarkViolet,  Color.Red,       Color.DarkSlateGray, Color.Maroon,   Color.DarkGreen,  Color.DarkBlue,  Color.DeepPink};

        if (DS.Tables[0].Rows.Count > 0)
        {
            for (int i = 0; i < DS.Tables[0].Rows.Count; i++)
            {
                if (Convert.ToInt32(DS.Tables[0].Rows[i]["COUNT"]) != 0)
                {
                    ChartSeriesItem CSI = new ChartSeriesItem();
                    CSI.YValue = Convert.ToDouble(DS.Tables[0].Rows[i]["COUNT"]);
                    CSI.Label.TextBlock.Text = DS.Tables[0].Rows[i]["ITEM_TEXT"].ToString() + " (" + DS.Tables[0].Rows[i]["COUNT"].ToString() + ")";
                    CSI.Label.TextBlock.Appearance.TextProperties.Font = new Font("Arial", 7);
                    CSI.XValue = 1;

                    //layout
                    CSI.Appearance.FillStyle.MainColor = MainColor[i];
                    CSI.Appearance.FillStyle.SecondColor = SecondColor[i];
                    CSI.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Gradient;
                    CSI.Label.TextBlock.Appearance.TextProperties.Color = TextColor[i];

                    RadChart_PAL_Duration.Series[0].AddItem(CSI);
                }

            }
        }
    }
        protected void LoadPieCharts()
        {
            if (_levelID <= 0) return;


            var taskList = new List<AsyncPageTask>
            {
                new AsyncPageTask(GetStudentCounts),
                new AsyncPageTask(LoadDistrictParms)
            };

            foreach (AsyncPageTask page in taskList)
            {
                PageAsyncTask newTask = new PageAsyncTask(page.OnBegin, page.OnEnd, page.OnTimeout, "StudentSearch", true);
                Page.RegisterAsyncTask(newTask);
            }
            taskList = null;
            Page.ExecuteRegisteredAsyncTasks();

            studentCountChart.DataSource = countData;
            studentCountChart.ChartTitle.Visible = false;
            studentCountChart.DataBind();

            //studentPieChartXmlHttpPanel.Value = "";   Don't need this particularly at the moment

            //Handle Legend Labels
            studentCountChart.Series.Clear();
            var nSeries = new ChartSeries();

            studentCountChart.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
            studentCountChart.PlotArea.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;
            studentCountChart.PlotArea.Appearance.Border.Color = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");

            studentCountChart.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 6);
            studentCountChart.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 6);
            studentCountChart.PlotArea.XAxis.Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.TopRight;
            nSeries.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.Black;
            nSeries.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 6);
            nSeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            var count = 0;

            //change to foreach for easier reading
            var gradeList = new List<string>();
            foreach (DataRow dr in countData.Rows)
            {
                var value = DataIntegrity.ConvertToDouble(dr["StudentCount"]);
                var xValue = 0;
                switch (_level)
                {
                    case EntityTypes.Teacher:
                        xValue = dr.Table.Columns.Contains("ClassID") ? DataIntegrity.ConvertToInt(dr["ClassID"]) : 0;
                        break;
                    case EntityTypes.School:
                        gradeList.Add(dr.Table.Columns.Contains("GradeNumber") ? dr["GradeNumber"].ToString() : string.Empty);
                        xValue = gradeList.Count - 1;
                        break;
                }

                var myItem = new ChartSeriesItem(value) { Name = dr["Grade"].ToString(), XValue = xValue };
                myItem.Appearance.FillStyle.MainColor = System.Drawing.ColorTranslator.FromHtml(StyleController.GetPieChartColor(dr["Grade"].ToString(), count++)); ;
                myItem.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;

                if (value <= 0) myItem.Label.Visible = false;

                nSeries.Type = ChartSeriesType.Pie;
                nSeries.AddItem(myItem);
                studentCountChart.Series.Add(nSeries);

            }
        }
    protected void rc_pie_annual_Click(object sender, ChartClickEventArgs args)
    {
        if (args.SeriesItem != null)
        {
            if (args.SeriesItem.Parent.Name == "parent_series")
            {
                lbl_drill_down.Text = "Click a pie section to load the book";
                String territory = args.SeriesItem.Name;
                btn_back.Enabled = true;

                // Format chart for drill
                rc_pie_annual.Clear();
                rc_pie_annual.PlotArea.XAxis.Items.Clear();
                rc_pie_annual.ChartTitle.Visible        = true;
                rc_pie_annual.ChartTitle.TextBlock.Text = territory + "'s " + dd_annual_year.Text + " Books";
                rc_pie_annual.PlotArea.YAxis.AxisMode   = ChartYAxisMode.Extended;


                // Define and add territory chart series
                ChartSeries territory_series = new ChartSeries(territory, ChartSeriesType.Pie);
                territory_series.Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
                territory_series.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
                rc_pie_annual.Series.Add(territory_series);

                // Get top two books
                String qry = "SELECT x.IssueName, ROUND(x.originalprice-IFNULL(CONVERT(SUM(db_salesbook.rl_price*Conversion),SIGNED),0)) as total_price, x.StartDate " +
                             "FROM " +
                             "( " +
                             "    SELECT sbh.SalesBookID, IssueName, CONVERT(SUM(Price*Conversion),SIGNED) as originalprice, StartDate " +
                             "    FROM db_salesbook sb, db_salesbookhead sbh " +
                             "    WHERE sb.sb_id = sbh.SalesBookID " +
                             "    AND YEAR(StartDate)=@year " +
                             "    AND deleted=0 AND IsDeleted=0 " +
                             "    AND Office=@office " +
                             "    GROUP BY sbh.SalesBookID " +
                             "    ORDER BY StartDate " +
                             ") as x " +
                             "LEFT JOIN db_salesbook ON " +
                             "x.SalesBookID = db_salesbook.rl_sb_id " +
                             "GROUP BY x.IssueName " +
                             "ORDER BY x.StartDate";
                String[]  pn           = { "@office", "@year" };
                Object[]  pv           = { territory, dd_annual_year.Text };
                DataTable dt_book_data = SQL.SelectDataTable(qry, pn, pv);

                if (dt_book_data.Rows.Count > 0)
                {
                    for (int i = 0; i < dt_book_data.Rows.Count; i++)
                    {
                        if (dt_book_data.Rows[i]["total_price"] != DBNull.Value)
                        {
                            String          bookName = dt_book_data.Rows[i]["IssueName"].ToString();
                            double          price    = Convert.ToDouble(dt_book_data.Rows[i]["total_price"]);
                            Color           colour   = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256));
                            ChartSeriesItem csi_item = new ChartSeriesItem(
                                price,
                                Util.TextToCurrency(price.ToString(), "usd"),
                                colour,
                                false);

                            csi_item.Appearance.FillStyle.SecondColor = colour;
                            csi_item.Name   = bookName;
                            csi_item.Parent = territory_series;
                            territory_series.AddItem(csi_item);

                            if (i == dt_book_data.Rows.Count - 1)
                            {
                                csi_item.Appearance.Exploded = true;
                            }
                        }
                    }
                }

                if (dt_book_data.Rows.Count > 11)
                {
                    rc_pie_annual.Height = 400;
                }
                else
                {
                    rc_pie_annual.Height = 300;
                }
            }
            else
            {
                // Just re-use bar chart transfer
                rc_bar_latest_Click(sender, args);
            }
        }
    }
    // Graphs
    protected void BindChart(RadChart chart, ChartSeriesType chartType, String chartTimeScale)
    {
        // Clear chart and reset total_usd
        double total_usd = 0;

        chart.Clear();
        chart.PlotArea.XAxis.Items.Clear();

        // Define parent chart series and format
        ChartSeries parent_series = new ChartSeries("parent_series", chartType);

        parent_series.Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
        parent_series.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
        chart.Series.Add(parent_series);

        // Iterate offices
        double highest_price = 0;
        double lowest_price  = 999999;

        for (int i = 0; i < offices.Rows.Count; i++)
        {
            String territory = (String)offices.Rows[i]["Office"];
            String shortname = (String)offices.Rows[i]["ShortName"];
            Color  colour    = Util.ColourTryParse((String)offices.Rows[i]["Colour"]);

            // Toggle latest/annual data
            String timeScaleExpr = String.Empty;
            if (chartTimeScale == "latest")
            {
                timeScaleExpr = "=(SELECT SalesBookID FROM db_salesbookhead WHERE Office=@office ORDER BY StartDate DESC LIMIT 1) ";
            }
            else if (chartTimeScale == "annual")
            {
                timeScaleExpr = "IN (SELECT SalesBookID FROM db_salesbookhead WHERE Office=@office AND YEAR(StartDate)=@year) ";
            }

            // For each office..
            String qry = "SELECT ROUND(IFNULL(CONVERT(SUM(Price*Conversion), SIGNED),0)- " +
                         "IFNULL((SELECT CONVERT(SUM(rl_price*Conversion), SIGNED) " +
                         "FROM db_salesbook sb, db_salesbookhead sbh " +
                         "WHERE sb.rl_sb_id = sbh.SalesBookID " +
                         "AND sbh.SalesBookID " + timeScaleExpr +
                         "AND red_lined=1 AND IsDeleted=0 AND Office=@office),0)) as total_price " +
                         "FROM db_salesbook sb, db_salesbookhead sbh " +
                         "WHERE sb.sb_id = sbh.SalesBookID " +
                         "AND sbh.SalesBookID " + timeScaleExpr +
                         "AND deleted=0 AND IsDeleted=0";
            String[]  pn         = { "@office", "@year" };
            Object[]  pv         = { territory, dd_annual_year.Text };
            DataTable totalprice = SQL.SelectDataTable(qry, pn, pv);

            if (totalprice.Rows.Count > 0 && totalprice.Rows[0]["total_price"] != DBNull.Value)
            {
                double price             = Convert.ToDouble(totalprice.Rows[0]["total_price"]);
                String currency_terrtory = territory;

                total_usd += price;

                // Get max and min for chart padding
                highest_price = Math.Max(highest_price, price);
                lowest_price  = Math.Min(lowest_price, price);

                ChartSeriesItem csi_item = new ChartSeriesItem(
                    price,
                    Util.TextToCurrency(price.ToString(), "usd"),
                    colour,
                    false);

                csi_item.Name   = territory;
                csi_item.Parent = parent_series;
                parent_series.AddItem(csi_item);

                if (chart.ID.Contains("bar"))
                {
                    chart.PlotArea.XAxis.Items.Add(new ChartAxisItem(shortname));
                }
                else
                {
                    csi_item.Appearance.FillStyle.MainColor   = colour;
                    csi_item.Appearance.FillStyle.SecondColor = colour;
                }
            }
        }

        // Individual chart formatting
        if (chart.ID.Contains("rc_pie"))
        {
            parent_series.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
            lbl_drill_down.Text      = "Click a pie section to drill down";
            chart.ChartTitle.Visible = false;
            chart.Height             = 300;
        }
        else if (chart.ID.Contains("rc_bar"))
        {
            if (chart.ID.Contains("latest"))
            {
                parent_series.ActiveRegionToolTip = "Click to view the latest book for this territory.";
            }
            parent_series.Appearance.TextAppearance.TextProperties.Font = new Font("Verdana", 8, FontStyle.Regular);

            if (lowest_price != 0)
            {
                lowest_price = (lowest_price + (lowest_price / 100) * 40);
            }
            double step = highest_price / 10;
            if (step == 0)
            {
                step = 1;
            }
            rc_bar_latest.PlotArea.YAxis.AddRange(0, (highest_price + (highest_price / 100) * 20), step);
        }

        // Set total USD label
        lbl_total_usd.Text = "Total USD: " + Util.TextToCurrency(total_usd.ToString(), "us");
    }
        private void BuildChart(RadChart chart, DataTable seriesData)
        {
            // Handle Legend Labels
            chart.Series.Clear();
            var nSeries = new ChartSeries();
            var nSeries2 = new ChartSeries();
            
            nSeries.Name = "School %";
            nSeries2.Name = "District %";
            chart.Legend.Appearance.ItemTextAppearance.AutoTextWrap = AutoTextWrap.False;

            //double minval = 100;
            //double maxval = 0;

            ChartAxisItemsCollection caic = new ChartAxisItemsCollection();

            var year_list = new List<String>();
            // Begin Experience tab
            foreach (DataRow dr in seriesData.Rows)
            {
                var myItem = new ChartSeriesItem(DataIntegrity.ConvertToDouble(dr["SuspensionRate"]), dr["LevelLabel"].ToString()) { Name = dr["SchoolYear"].ToString() };
                if (String.IsNullOrEmpty(dr["SuspensionRate"].ToString())) myItem.Appearance.Visible = false;   // hide bar and text if the value is null (no data)
                //myItem.Label.Appearance.LabelLocation = StyleSeriesItemLabel.ItemLabelLocation.Auto;
                if (dr["Level"].Equals("District"))
                {
                    nSeries2.AddItem(myItem);
                }
                else
                {
                    nSeries.AddItem(myItem);
                }
                
                year_list.Add(dr["SchoolYear"].ToString());
                
                //if (minval > DataIntegrity.ConvertToDouble(dr["SuspensionRate"])) minval = DataIntegrity.ConvertToDouble(dr["SuspensionRate"]);
                //if (maxval < DataIntegrity.ConvertToDouble(dr["SuspensionRate"])) maxval = DataIntegrity.ConvertToDouble(dr["SuspensionRate"]);
            }
            foreach (var yl in year_list.Distinct())
            {
                ChartAxisItem ai = new ChartAxisItem();
                ai.TextBlock.Text = yl;
                caic.Add(ai);    
            }
            
            chart.PlotArea.XAxis.AddItem(caic);

            chart.PlotArea.YAxis.MinValue = 0;
            //chart.PlotArea.YAxis.Step = (maxval - (minval - 5)) / 2;
            chart.PlotArea.YAxis.Step = 5;
            chart.PlotArea.YAxis.AutoScale = true;
            //chart.PlotArea.YAxis.MaxValue = maxval == 100 ? maxval : maxval + 5;
            //chart.PlotArea.YAxis.a = maxval == 100 ? maxval : maxval + 5;

            chart.Series.Add(nSeries);
            chart.Series.Add(nSeries2);

            chart.ChartTitle.Visible = false;

            chart.SetSkin("SuspensionRate");
        }
Пример #32
0
 protected void BuildSeriesItem(ChartSeries series, double count, string label)
 {
     ChartSeriesItem item = new ChartSeriesItem(count, label);
     item.Label.TextBlock.Appearance.TextProperties.Color = Color.HotPink;
     item.Label.TextBlock.Appearance.TextProperties.Font = new Font("Arial", 12, FontStyle.Bold);
     series.Items.Add(item);
 }
        void SetKendoChartSeries()
        {
            //todo: refactor this method into smaller methods. Also, we should probably put the similar code for the two axes in the same places (instead of dealing with one axis, then the other).

            ChartOptions chartO = new ChartOptions();
            var          series = new JSArray <ChartSeriesItem>();

            #region Preparing the data points (series)
            foreach (CartesianSeries cartesianSeries in _series)
            {
                if (cartesianSeries.ItemsSource != null)
                {
                    ChartSeriesItem seriesItem = new ChartSeriesItem();
                    seriesItem.type = cartesianSeries.GetChartType();

                    #region attempt at dealing with tooltips in series.
                    //if(cartesianSeries is LineSeries)
                    //{
                    //    //Note: the following does nothing if chartO.tooltip.shared is true.
                    //    //note: The LineSeries is the only one that has the LineSeries.TrackBallInfoTemplate set in the xaml
                    //    seriesItem.tooltip = new ChartSeriesItemTooltip();
                    //    Interop.ExecuteJavaScript("$0.visible = true", seriesItem.tooltip.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.crosshair.visible = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                    //    seriesItem.tooltip.format = "Close: {0}";
                    //}
                    //if(cartesianSeries.TrackBallInfoTemplate != null)
                    //{
                    //    //find a way to generate a kendo-style template in html here, from the cartesianSeries.TrackBallInfoTemplate.
                    //    //that includes creating the html structure and translating the bindings into something in kendo style.
                    //    // for example, the Text="{Binding DataPoint.Category, StringFormat=Date: \{0:d\} }"
                    //}
                    #endregion

                    if (cartesianSeries is CategoricalStrokedSeries)
                    {
                        var    cartesianSeriesAsCategoricalSeries = cartesianSeries as CategoricalStrokedSeries;
                        string categoryField = cartesianSeriesAsCategoricalSeries.CategoryBinding.PropertyPath; //I'll just assume this has to have a value because I can't find a default value or anything like that in the telerik things I found on the internet.
                        string valueField    = cartesianSeriesAsCategoricalSeries.ValueBinding.PropertyPath;    // same as above.

                        SetSeriesItemColor(seriesItem, cartesianSeriesAsCategoricalSeries.Stroke);
                        if (cartesianSeries is AreaSeries)
                        {
                            SetSeriesItemColor(seriesItem, ((AreaSeries)cartesianSeriesAsCategoricalSeries).Fill);
                        }

                        var propNames = new List <string>()
                        {
                            categoryField, valueField
                        };

                        var res = PrepareSeriesData(cartesianSeries.ItemsSource, propNames);

                        seriesItem.categoryField = categoryField;
                        seriesItem.field         = valueField;
                        seriesItem.data          = res;
                        seriesItem.missingValues = "gap";
                    }
                    else
                    {
                        //get the data as points as is.
                    }

                    //var v = new JSObject();
                    //Interop.ExecuteJavaScript(@"$0.UnderlyingJSInstance = [1, 2, 3]", v);
                    //seriesItem.data = v;
                    series.Add(seriesItem);
                }
            }
            #endregion

            var categoryAxis     = new JSArray <ChartCategoryAxisItem>();
            var categoryAxisItem = new ChartCategoryAxisItem();

            if (HorizontalAxis != null)
            {
                var labels = new ChartCategoryAxisItemLabels();
                labels.rotation = HorizontalAxis.LabelFitMode == Charting.AxisLabelFitMode.Rotate ? -60 : 0;
                labels.format   = HorizontalAxis.LabelFormat; //Note: this seems to apply to DateFormats as well so I don't think we need to set labels.dateFormats
                labels.font     = HorizontalAxis.FontFamily != null ? HorizontalAxis.FontFamily.Source : null;

                //labels.color = "LightGray"; //todo: find out what defines the label's color (it is not HorizontalAxis.Foreground apparently)
                categoryAxisItem.labels = labels;

                string XAxisColor = GetStringToSetAsColor(HorizontalAxis.LineStroke);
                if (XAxisColor != null)
                {
                    categoryAxisItem.color = XAxisColor;
                }
            }

            bool hideCategoryAxisGridLines = false;
            bool hideValueAxisGridLines    = false;
            if (Grid != null)
            {
                #region Determining Whether to hide the Grid lines or not.
                switch (Grid.MajorLinesVisibility)
                {
                case GridLineVisibility.None:
                    hideCategoryAxisGridLines = true;
                    hideValueAxisGridLines    = true;
                    break;

                case GridLineVisibility.X:
                    hideValueAxisGridLines = true;
                    break;

                case GridLineVisibility.Y:
                    hideCategoryAxisGridLines = true;
                    break;

                case GridLineVisibility.XY:
                    break;

                default:
                    break;
                }
                #endregion

                //hiding the vertical lines:
                if (hideCategoryAxisGridLines)
                {
                    categoryAxisItem.majorGridLines = new ChartCategoryAxisItemMajorGridLines();
                    Interop.ExecuteJavaScript("$0.visible = false", categoryAxisItem.majorGridLines.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.majorGridLines.visible = false; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                    categoryAxisItem.minorGridLines = new ChartCategoryAxisItemMinorGridLines();
                    Interop.ExecuteJavaScript("$0.visible = false", categoryAxisItem.minorGridLines.UnderlyingJSInstance); //todo: same as above.
                }
            }

            categoryAxis.Add(categoryAxisItem);
            chartO.categoryAxis = categoryAxis;

            var valueAxis     = new JSArray <ChartValueAxisItem>();
            var valueAxisItem = new ChartValueAxisItem();

            if (Grid != null)
            {
                if (Grid.MajorYLineDashArray != null)
                {
                    valueAxisItem.majorGridLines          = new ChartValueAxisItemMajorGridLines();
                    valueAxisItem.majorGridLines.dashType = "dash"; //Note: it's MajorYLineDashArray="5, 2" but I think the kendo charts only support a set of values: "dash","dashDot","dot","longDash","longDashDot","longDashDotDot" and "solid"
                }
            }

            //hiding the horizontal lines:
            if (hideValueAxisGridLines)
            {
                valueAxisItem.majorGridLines = new ChartValueAxisItemMajorGridLines();
                Interop.ExecuteJavaScript("$0.visible = false", valueAxisItem.majorGridLines.UnderlyingJSInstance); //todo: find out how to do valueAxisItem.majorGridLines.visible = false; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                valueAxisItem.minorGridLines = new ChartValueAxisItemMinorGridLines();
                Interop.ExecuteJavaScript("$0.visible = false", valueAxisItem.minorGridLines.UnderlyingJSInstance); //todo: same as above.
            }

            string YAxisColor = GetStringToSetAsColor(VerticalAxis.LineStroke);
            if (YAxisColor != null)
            {
                valueAxisItem.color = YAxisColor;
            }

            valueAxis.Add(valueAxisItem);
            chartO.valueAxis = valueAxis;

            if (Behaviors != null)
            {
                foreach (var behavior in Behaviors)
                {
                    if (behavior is ChartTrackBallBehavior)
                    {
                        ChartTrackBallBehavior behaviorAsCTBB = (ChartTrackBallBehavior)behavior;
                        if (behaviorAsCTBB.ShowIntersectionPoints)
                        {
                            categoryAxisItem.crosshair = new ChartCategoryAxisItemCrosshair();
                            Interop.ExecuteJavaScript("$0.visible = true", categoryAxisItem.crosshair.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.crosshair.visible = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                            //categoryAxisItem.crosshair.tooltip = new ChartCategoryAxisItemCrosshairTooltip();
                            //Interop.ExecuteJavaScript("$0.visible = true", categoryAxisItem.crosshair.tooltip.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.crosshair.visible = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                            //categoryAxisItem.crosshair.tooltip.format = "Date: {0:d}";

                            chartO.tooltip = new ChartTooltip();                                                //todo: move this to somewhere more adapted?
                            //Interop.ExecuteJavaScript("$0.visible = true", chartO.tooltip.UnderlyingJSInstance); //todo: find out how to do categoryAxisItem.crosshair.visible = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                            Interop.ExecuteJavaScript("$0.shared = true", chartO.tooltip.UnderlyingJSInstance); //todo: find out how to do chartO.tooltip.shared = true; without having Bridge break everything by boxing the value even though it is boxed in the generated code.
                                                                                                                //                            chartO.tooltip.sharedTemplate = @"<div>#: category #</div>
                                                                                                                //# for (var i = 0; i < points.length; i++) { #
                                                                                                                //    <div>#: points[i].series.name# : #: points[i].value #</div>
                                                                                                                //# } #";
                        }
                    }
                }
            }

            //Setting the chart's background color:
            Brush background = Background;
            if (background != null && background is SolidColorBrush)
            {
                chartO.chartArea            = new ChartChartArea();
                chartO.chartArea.background = (string)((SolidColorBrush)background).ConvertToCSSValue();
            }


            chartO.series = series;
            _kendoChart.setOptions(chartO);
        }
Пример #34
0
    protected RadChart GenerateVersusChart(String office)
    {
        RadChart rc = new RadChart();

        rc.Clear();
        rc.PlotArea.XAxis.Items.Clear();

        rc.Width  = 450;
        rc.Height = 300;
        rc.Skin   = "Black";
        rc.ChartTitle.TextBlock.Text = office + ": Weekly SPA Overview (Target to Actual)";
        rc.ChartTitle.TextBlock.Appearance.TextProperties.Font = new Font("Verdana", 10, FontStyle.Regular);
        rc.PlotArea.EmptySeriesMessage.TextBlock.Text          = "Error, database connection could not be establised.";
        //rc.PlotArea.SeriesOrientation = ChartSeriesOrientation.Horizontal;
        rc.Legend.Appearance.Visible = false;
        rc.PlotArea.YAxis.Appearance.TextAppearance.Visible = false;
        rc.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
        rc.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
        rc.PlotArea.XAxis.AutoScale = false;
        rc.PlotArea.YAxis.AutoScale = false;
        rc.AutoLayout = true;

        // Define chart target series
        ChartSeries SPATargetSeries = new ChartSeries("revTarget", ChartSeriesType.Bar);

        SPATargetSeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
        SPATargetSeries.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;;
        SPATargetSeries.Appearance.TextAppearance.TextProperties.Font  = new Font("Verdana", 7, FontStyle.Regular);
        rc.Series.Add(SPATargetSeries);

        // Define chart values series
        ChartSeries SPASeries = new ChartSeries("rev", ChartSeriesType.Bar);

        SPASeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
        SPASeries.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;;
        SPASeries.Appearance.TextAppearance.TextProperties.Font  = new Font("Verdana", 7, FontStyle.Regular);
        rc.Series.Add(SPASeries);

        int s       = 0;
        int p       = 0;
        int a       = 0;
        int tr      = 0;
        int pr      = 0;
        int no_ccas = 0;

        // Grab SPA
        String qry = "SELECT prh.ProgressReportID," +
                     "SUM((mS+tS+wS+thS+fS+xS)) as Suspects, " +
                     "SUM((mP+tP+wP+thP+fP+xP)) as Prospects, " +
                     "SUM((mA+tA+wA+thA+fA+xA)) as Approvals, " +
                     "SUM((mTotalRev+tTotalRev+wTotalRev+thTotalRev+fTotalRev+xTotalRev)) as TR, " +
                     "SUM(PersonalRevenue) as PR, " +
                     "COUNT(*) as CCAs, " +
                     "0 as RD, " +
                     "0 as PD " +
                     "FROM db_progressreport pr, db_progressreporthead prh " +
                     "WHERE prh.ProgressReportID = pr.ProgressReportID " +
                     "AND Office=@office " +
                     "GROUP BY prh.ProgressReportID " +
                     "ORDER BY StartDate DESC LIMIT 1";
        DataTable dt_report_info = SQL.SelectDataTable(qry, "@office", office);

        if (dt_report_info.Rows.Count > 0)
        {
            // Grab Target SPA
            int no_631 = 0;
            int no_321 = 0;
            qry = "SELECT CCAType, COUNT(*) as no FROM db_progressreport WHERE ProgressReportID=@ProgressReportID GROUP BY CCAType";
            DataTable ccas_types = SQL.SelectDataTable(qry, "@ProgressReportID", dt_report_info.Rows[0]["ProgressReportID"]);
            if (ccas_types.Rows.Count > 0)
            {
                for (int j = 0; j < ccas_types.Rows.Count; j++)
                {
                    switch (ccas_types.Rows[j]["CCAType"].ToString())
                    {
                    case "-1":
                        no_631 += Convert.ToInt32(ccas_types.Rows[j]["no"]);
                        break;

                    case "1":
                        no_631 += Convert.ToInt32(ccas_types.Rows[j]["no"]);
                        break;

                    case "2":
                        no_321 = Convert.ToInt32(ccas_types.Rows[j]["no"]);
                        break;
                    }
                }
            }
            int target_s = (no_631 * 3) + (no_321 * 6);
            int target_p = (no_631 * 2) + (no_321 * 3);
            int target_a = no_631 + no_321;

            s       = Convert.ToInt32(dt_report_info.Rows[0]["Suspects"]);
            p       = Convert.ToInt32(dt_report_info.Rows[0]["Prospects"]);
            a       = Convert.ToInt32(dt_report_info.Rows[0]["Approvals"]);
            tr      = Convert.ToInt32(dt_report_info.Rows[0]["TR"]);
            pr      = Convert.ToInt32(dt_report_info.Rows[0]["PR"]);
            no_ccas = Convert.ToInt32(dt_report_info.Rows[0]["CCAs"]);

            int greatest = s;
            greatest = Math.Max(p, greatest);
            greatest = Math.Max(a, greatest);
            greatest = Math.Max(a, greatest);
            greatest = Math.Max(target_s, greatest);
            greatest = Math.Max(target_p, greatest);
            greatest = Math.Max(target_a, greatest);
            greatest = Convert.ToInt32((((float)greatest / 100) * 108));

            double max_value = Convert.ToDouble(greatest) + 0.5;
            double step      = 1;
            rc.PlotArea.YAxis.AddRange(0, max_value, step);

            // Actual SPA
            ChartSeriesItem csi_a = new ChartSeriesItem(a, a.ToString(), Color.DodgerBlue, false);
            ChartSeriesItem csi_p = new ChartSeriesItem(p, p.ToString(), Color.Magenta, false);
            ChartSeriesItem csi_s = new ChartSeriesItem(s, s.ToString(), Color.Lime, false);
            // Target SPA
            ChartSeriesItem csi_ta = new ChartSeriesItem(target_a, target_a.ToString(), Color.DarkOrange, false);
            ChartSeriesItem csi_tp = new ChartSeriesItem(target_p, target_p.ToString(), Color.DarkOrange, false);
            ChartSeriesItem csi_ts = new ChartSeriesItem(target_s, target_s.ToString(), Color.DarkOrange, false);

            SPASeries.AddItem(csi_a);
            SPASeries.AddItem(csi_p);
            SPASeries.AddItem(csi_s);
            SPATargetSeries.AddItem(csi_ta);
            SPATargetSeries.AddItem(csi_tp);
            SPATargetSeries.AddItem(csi_ts);

            rc.PlotArea.XAxis.Items.Add(new ChartAxisItem("Ap"));
            rc.PlotArea.XAxis.Items.Add(new ChartAxisItem("Pr"));
            rc.PlotArea.XAxis.Items.Add(new ChartAxisItem("Su"));
            //rc.PlotArea.XAxis.Items.Add(new ChartAxisItem("T" + Environment.NewLine + Environment.NewLine + "A"));
            SPASeries.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            SPASeries.Appearance.Border.Visible  = true;
        }
        else
        {
            rc = null;
        }

        return(rc);
    }
Пример #35
0
        protected void Page_Load(object sender, EventArgs e)
        {
            /****************************************************************
             * if user does not have Tab_Search_Staff permissions, then hide
             * the search tab and the radPageView associated with it.
             * *************************************************************/
            if (!UserHasPermission(Permission.Tab_Search_Staff))
            {
                radPageViewStaffSearch.Visible = false;
                foreach (Telerik.Web.UI.RadTab tab in RadTabStrip2.Tabs)
                {
                    if (tab.Text == "Search")
                    {
                        tab.Visible = false;
                        break;
                    }
                }
            }

            /*******************************************************************
             * If user does not have Icon_Expanded_Staff permissions, then hide
             * the "Advanced Search" link via its surrounding div tag.
             * ****************************************************************/
            StaffSearch_DivAdvancedSearch.Visible = (UserHasPermission(Permission.Icon_ExpandedSearch_Staff));

            _level = SessionObject.LCOrole;
            _levelID = DataIntegrity.ConvertToInt(Tile.TileParms.GetParm("levelID"));

            staffSearch_HiddenLevel.Value = _level.ToString();
            staffSearch_HiddenLevelID.Value = Standpoint.Core.Classes.Encryption.EncryptInt(_levelID);
            staffPieChartXmlHttpPanel.Value = string.Empty;

            DataTable countData;
            string chartSeriesItemName = string.Empty;
            switch (_level)
            {
                case Base.Enums.EntityTypes.LCOAdministrator:
                    countData = Base.Classes.LCO.GetStaffCounts();
                    chartSeriesItemName = "PortalName";
                    break;
                case Base.Enums.EntityTypes.District:
                    countData = Base.Classes.Staff.GetStateStaffCounts();
                    chartSeriesItemName = "loweredrolename";
                    break;
                default:
                    return;
            }

            staffCountChart.DataSource = countData;
            staffCountChart.ChartTitle.Visible = false;
            staffCountChart.DataBind();

            // Handle Legend Labels
            staffCountChart.Series.Clear();
            var nSeries = new ChartSeries();
            nSeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;

            foreach (DataRow dr in countData.Rows)
            {
                var value = DataIntegrity.ConvertToDouble(dr["StaffCount"]);
                var myItem = new ChartSeriesItem(value) { Name = dr[chartSeriesItemName].ToString() };
                if (value <= 0) myItem.Label.Visible = false;
                nSeries.Type = ChartSeriesType.Pie;
                nSeries.AddItem(myItem);
            }

            staffCountChart.Series.Add(nSeries);

            if (IsPostBack)
            {
                // Reloads previous search results if session object search text has a value
                if (staffSearchText_smallTile.Value == "Search by last name..." && SessionObject.TeacherSearchTxtPostBack_smallTile != null
                        && SessionObject.TeacherSearchTxtPostBack_smallTile.Length > 0)
                {
                    SearchStaffByLastName_Click(null, null);
                }

                return;
            }

            staffSearchMoreLink.Visible = false;
            staffSearchTileGrid.Visible = false;
            addNewStaff.Visible = UserHasPermission(Base.Enums.Permission.Create_Staff);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            /*******************************************************************
             * If user does not have Icon_Expanded_Staff permissions, then hide
             * the "Advanced Search" link via its surrounding div tag.
             * ****************************************************************/
            _level = (Thinkgate.Base.Enums.EntityTypes)Tile.TileParms.GetParm("level");
            _levelID = DataIntegrity.ConvertToInt(Tile.TileParms.GetParm("levelID"));

            List<AsyncPageTask> taskList = new List<AsyncPageTask>();
            taskList.Add(new AsyncPageTask(GetAttendRateForSchool));

            foreach (AsyncPageTask page in taskList)
            {
                PageAsyncTask newTask = new PageAsyncTask(page.OnBegin, page.OnEnd, page.OnTimeout, "SchoolAttendance", true);
                Page.RegisterAsyncTask(newTask);
            }
            taskList = null;
            Page.ExecuteRegisteredAsyncTasks();

            // Handle Legend Labels
            teacherCountChart.Series.Clear();
            var nSeries = new ChartSeries();
            var nSeries2 = new ChartSeries();

            nSeries.Name = "School %";
            nSeries2.Name = "District %";
            
            //double minval = 100;
            //double maxval = 0;

            ChartAxisItemsCollection caic = new ChartAxisItemsCollection();

            var year_list = new List<String>();

            foreach (DataRow dr in countData.Rows)
            {
                var myItem = new ChartSeriesItem(DataIntegrity.ConvertToDouble(dr["AttendanceRate"]), dr["LevelLabel"].ToString()) { Name = dr["SchoolYear"].ToString() };
                if (String.IsNullOrEmpty(dr["AttendanceRate"].ToString())) myItem.Appearance.Visible = false;   // hide bar and text if the value is null (no data)
                if (dr["Level"].Equals("District"))
                {
                    nSeries2.AddItem(myItem);
                }
                else
                {
                    nSeries.AddItem(myItem);
                }
                year_list.Add(dr["SchoolYear"].ToString());

                //if (minval > DataIntegrity.ConvertToDouble(dr["AttendanceRate"])) minval = DataIntegrity.ConvertToDouble(dr["AttendanceRate"]);
                //if (maxval < DataIntegrity.ConvertToDouble(dr["AttendanceRate"])) maxval = DataIntegrity.ConvertToDouble(dr["AttendanceRate"]);
            }
            foreach (var yl in year_list.Distinct())
            {
                ChartAxisItem ai = new ChartAxisItem();
                ai.TextBlock.Text = yl;
                caic.Add(ai);
            }
            teacherCountChart.PlotArea.XAxis.AddItem(caic);

            teacherCountChart.PlotArea.YAxis.MinValue = 0;
            teacherCountChart.PlotArea.YAxis.Step = 5;
            teacherCountChart.PlotArea.YAxis.MaxValue = 1;

            teacherCountChart.Series.Add(nSeries);
            teacherCountChart.Series.Add(nSeries2);

            teacherCountChart.ChartTitle.Visible = false;

            teacherCountChart.SetSkin("SchoolAttendanceRates");
        }
Пример #37
0
        private void UpdateBasedOnStatisticSeries(Dictionary <TournamentChartSeries, List <ChartSeriesItem> > chartSeriesItems, IList <Tournaments> tournaments)
        {
            if (tournaments == null || tournaments.Count == 0)
            {
                return;
            }

            var chartItemDataBuilder           = CreateChartItemDataBuilder(ChartDisplayRange);
            var tournamentChartItemDataBuilder = CreateTournamentChartItemDataBuilder(ChartDisplayRange);

            var firstDate = tournamentChartItemDataBuilder.GetFirstDate(tournaments.Max(x => x.Firsthandtimestamp));

            var groupedTournaments = tournaments
                                     .Where(x => x.Firsthandtimestamp >= firstDate && (tournamentChartFilterType == TournamentChartFilterType.All ||
                                                                                       tournamentChartFilterType == TournamentChartFilterType.MTT && x.Tourneytagscsv == TournamentsTags.MTT.ToString() ||
                                                                                       tournamentChartFilterType == TournamentChartFilterType.STT && x.Tourneytagscsv == TournamentsTags.STT.ToString()))
                                     .GroupBy(x => x.BuildKey()).ToDictionary(x => x.Key, x => x.FirstOrDefault());

            var filteredTournamentPlayerStatistic = StorageModel
                                                    .GetFilteredTournamentPlayerStatistic()
                                                    .Where(x => groupedTournaments.ContainsKey(new TournamentKey(x.PokersiteId, x.TournamentId)))
                                                    .ToArray();

            // filter and orders
            var stats = chartItemDataBuilder.PrepareStatistic(filteredTournamentPlayerStatistic);

            object previousGroupKey = null;

            var itemsCounter = 0;

            for (var statIndex = 0; statIndex < stats.Length; statIndex++)
            {
                var stat = stats[statIndex];

                var currentGroupKey = chartItemDataBuilder.BuildGroupKey(stat, statIndex);

                var isNew = !currentGroupKey.Equals(previousGroupKey);

                if (isNew)
                {
                    itemsCounter++;
                }

                previousGroupKey = currentGroupKey;

                foreach (var chartSerie in ChartCollection.Where(x => x.IsBasedOnStatistic))
                {
                    ChartSeriesItem previousChartSeriesItem = null;
                    ChartSeriesItem chartSeriesItem         = null;

                    if (!chartSeriesItems.ContainsKey(chartSerie))
                    {
                        chartSeriesItems.Add(chartSerie, new List <ChartSeriesItem>());
                    }

                    if (isNew)
                    {
                        chartSeriesItem = new ChartSeriesItem
                        {
                            Format                 = chartSerie.Format,
                            Category               = chartItemDataBuilder.GetValueFromGroupKey(currentGroupKey),
                            PointColor             = chartSerie.ColorsPalette.PointColor,
                            TrackBallColor         = chartSerie.ColorsPalette.TrackBallColor,
                            TooltipColor           = chartSerie.ColorsPalette.TooltipColor,
                            TooltipForegroundColor = chartSerie.ColorsPalette.TooltipForeground
                        };

                        previousChartSeriesItem = chartSeriesItems[chartSerie].LastOrDefault();
                        chartSeriesItems[chartSerie].Add(chartSeriesItem);
                    }
                    else
                    {
                        previousChartSeriesItem = chartSeriesItem = chartSeriesItems[chartSerie].LastOrDefault();
                    }

                    chartSerie.UpdateChartSeriesItemByStatistic?.Invoke(chartSeriesItem, previousChartSeriesItem, stat);
                }
            }
        }
    private void fillRadChart_PAL_Enrties(string sXAxisValue, string sFromDate, string sFilter_AccountFrom)
    {
        DateTime dtMonthStart = Convert.ToDateTime(sFromDate);
        string sMonthStart = dtMonthStart.ToString("MM/01/yyyy");
        string sMonthEnd = dtMonthStart.AddMonths(1).AddSeconds(-1).ToString();
        DataSet DS = objReportClass.Rpt_REPORT_PalEntries_BY_Date(sMonthStart, sMonthEnd, UC_Visitlog_Visitlog1.ACCOUNT_ID, sFilter_AccountFrom);

        string sXAxisText = dtMonthStart.ToString("MMM yy");
        double dNumPal = Convert.ToDouble(DS.Tables[0].Rows[0]["NUM_PAL"]);
        double dSumMet = Convert.ToDouble(DS.Tables[0].Rows[0]["SUM_MET"]);

        //insert the new xaxis coordinate
        ChartAxisItem CAI = new ChartAxisItem();
        CAI.Value = Convert.ToDecimal(sXAxisValue);
        CAI.TextBlock.Text = sXAxisText;// dtCurrent.AddDays(-giChartDaySpan).ToString("MMM d");
        CAI.Appearance.RotationAngle = 0;
        CAI.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Top;
        RadChart_PAL_Enrties.PlotArea.XAxis.Items.Add(CAI);

        ChartSeriesItem CSI1 = new ChartSeriesItem();
        CSI1.YValue = dNumPal;
        CSI1.XValue = Convert.ToDouble(sXAxisValue);
        //if (Convert.ToDateTime(sMonthStart) < DateTime.Now)
        {
            RadChart_PAL_Enrties.Series[0].AddItem(CSI1);

        }
        sFromDate = Convert.ToDateTime(sFromDate).AddMonths(1).ToString();
    }
        private ChartSeriesItem GetChartSeriesItem(string label, double value)
        {
            var chartItem = new ChartSeriesItem(value);
            chartItem.Name = label;
            chartItem.Label.TextBlock.Text = label;

            return chartItem;
        }
 private ChartSeriesItem GetChartSeriesItem(double value, System.Drawing.Color color, System.Drawing.Color textColor)
 {
     var item = new ChartSeriesItem(value, value.ToString("0.00"));
     item.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;
     item.Appearance.FillStyle.MainColor = color;
     item.Label.TextBlock.Appearance.TextProperties.Color = textColor;
     return item;
 }
    protected void GetChart()
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        ConsumerRadChart.Series.Clear();
        ConsumerRadChart.Clear();
        ConsumerRadChart.PlotArea.Chart.Series.Clear();
        ConsumerRadChart.PlotArea.XAxis.Clear();
        ConsumerRadChart.PlotArea.YAxis.Clear();

        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        string adID = AdDropDown.SelectedItem.Value;
        DataView dvAd = dat.GetDataDV("SELECT * FROM Ads WHERE Ad_ID=" + adID);
        DataView dvAdCategories = dat.GetDataDV("SELECT DISTINCT  AC.Name, ACM.CategoryID FROM "+
            "Ad_Category_Mapping ACM, AdCategories AC WHERE AC.ID=ACM.CategoryID AND ACM.AdID=" + adID);
        TitleLabel.Text = "<span style=\"font-size: 30px;color: white;\">Statistics For Ad: <span style=\"color: #1fb6e7;\">" +
            dvAd[0]["Header"].ToString() + "</span></span><hr>";

        TitleLabel.Text += "<table cellspacing=\"20px\"><tr valign=\"top\"><td>";

        if (bool.Parse(dvAd[0]["BigAd"].ToString()))
            TitleLabel.Text += "<br/><b>Ad Type: </b><span style=\"color: #1fb6e7; font-weight: bold;\">Big Ad</span>";
        else
            TitleLabel.Text += "<br/><b>Ad Type: </b><span style=\"color: #1fb6e7; font-weight: bold;\">Normal Ad</span>";

        int totalViews = int.Parse(dvAd[0]["NumViews"].ToString());
        int currentViews = int.Parse(dvAd[0]["NumCurrentViews"].ToString());

        DataView dvAdStatistics = dat.GetDataDV("SELECT CASE WHEN LocationOnly = 'True' THEN 'Location Only' " +
            "WHEN WasEmail = 'True' THEN 'Email View' WHEN Reason = 'NonAssigned' THEN 'Non-Assigned User' " +
            "ELSE dbo.GetCategories(Reason) END AS 'Reason', CASE WHEN LocationOnly = 'True' THEN 'Location Only' " +
            "WHEN WasEmail = 'True' THEN 'Email View' WHEN Reason = 'NonAssigned' THEN 'Non-Assigned User' " +
            "ELSE dbo.GetCategories(Reason) END AS 'Reason For View [Location Only, " +
            "Non-Assigned User or list of Categories]', Date " +
            "FROM AdStatistics WHERE AdID=" + adID + " GROUP BY [Date], UserID, IP, LocationOnly, WasEmail, Reason ORDER BY [Date] DESC");
        DataView dvAdStatistics2 = dat.GetDataDV("SELECT  LocationOnly, WasEmail, Reason  " +
            ", Date " +
            "FROM AdStatistics WHERE AdID=" + adID + " GROUP BY [Date], UserID, IP, LocationOnly, WasEmail, " +
            "Reason ORDER BY [Date] DESC");

        string lastDayDay = "";
        if (dvAdStatistics2.Count > 0)
            lastDayDay = DateTime.Parse(dvAdStatistics2[0]["Date"].ToString()).Date.ToShortDateString();

        dvAdStatistics2.RowFilter = "WasEmail = 1";
        int wasEmailCount = dvAdStatistics2.Count;
        int notEmailCount = currentViews - wasEmailCount;

        if (currentViews < totalViews)
        {
            TitleLabel.Text += "<br/><b>Status: </b><span style=\"color: #1fb6e7; font-weight: bold;\">Ad is still running</span>";
            TitleLabel.Text += "<br/><b>Number of Views Needed: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + totalViews.ToString() + "</span>";
            TitleLabel.Text += "</td><td>";
            TitleLabel.Text += "<br/><b>Number of Current Views: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + currentViews.ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Views by Email: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + wasEmailCount.ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Views on Site: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + notEmailCount.ToString() + "</span>";
            TitleLabel.Text += "</td><td>";
            TitleLabel.Text += "<br/><b>Display To All: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + dvAd[0]["DisplayToAll"].ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Display To Non-Users: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + dvAd[0]["NonUsersAllowed"].ToString() + "</span>";
            TitleLabel.Text += "</td></tr></table>";
        }
        else
        {
            TitleLabel.Text += "<br/><b>Ad has finished running on:</b> <span style=\"color: #1fb6e7; font-weight: bold;\">" + lastDayDay + "</span>";
            TitleLabel.Text += "</td><td>";
            TitleLabel.Text += "<br/><b>Views by Email: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + wasEmailCount.ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Views on Site: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + notEmailCount.ToString() + "</span>";
            TitleLabel.Text += "</td><td>";
            TitleLabel.Text += "<br/><b>Display To All: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + dvAd[0]["DisplayToAll"].ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Display To Non-Users: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + dvAd[0]["NonUsersAllowed"].ToString() + "</span>";
            TitleLabel.Text += "</td></tr></table>";
        }

        //Construct the chart
        //for each entry in AdStatistics table for this particular ad
            //get the number of different categories it was in
                //One of the categories will be the location
            //increment each category if exists in AdStatistics entry
            //each category will have it's own series

        ArrayList listOfCategories = new ArrayList(dvAdCategories.Count);
        Hashtable hashOfCategories = new Hashtable();

        char[] delim = { ';' };
        string[] tokens;

        //Get the hash of the count of all the categories of the reason why the ad was seen.
        ListofUsersLiteral.Text = "<table cellpadding=\"10px\" style=\"font-size: 12px;border: solid 1px #1fb6e7; background-color: #1b1b1b;\"><tr><td>" +
            "<span style=\"font-size: 14px; font-weight: bold;\"></span>" +
            "</td><td><span style=\"font-size: 14px; font-weight: bold;\">Reason For View [Location Only, Non-Assigned User or list of Categories]</span>" +
            "</td><td><span style=\"font-size: 14px; font-weight: bold;\">Date</span></td></tr>";

        //gv.DataSource = dvAdStatistics;
        //gv.DataBind();

        for (int i = 0; i < dvAdStatistics.Count; i++)
        {
            ListofUsersLiteral.Text += "<tr><td>" + (i + 1).ToString() + "</td><td>";
            ListofUsersLiteral.Text += dvAdStatistics[i]["Reason"].ToString();
            //if (bool.Parse(dvAdStatistics[i]["LocationOnly"].ToString()))
            //{
            //    ListofUsersLiteral.Text += "Location Only";
            //    if (hashOfCategories.ContainsKey("-1"))
            //    {
            //        hashOfCategories["-1"] = int.Parse(hashOfCategories["-1"].ToString()) + 1;
            //    }
            //    else
            //    {
            //        hashOfCategories["-1"] = 1;
            //    }
            //}
            //else
            //{
            //    if (dvAdStatistics[i]["Reason"].ToString().Trim() != "NonAssigned")
            //    {
            //        tokens = dvAdStatistics[i]["Reason"].ToString().Split(delim);

            //        for (int j = 0; j < tokens.Length; j++)
            //        {
            //            if (tokens[j].Trim() != "")
            //            {
            //                dvAdCategories.RowFilter = "CategoryID = " + tokens[j];
            //                if (dvAdCategories.Count > 0)
            //                    ListofUsersLiteral.Text += dvAdCategories[0]["Name"].ToString() + ", ";
            //                if (hashOfCategories.ContainsKey(tokens[j].Trim()))
            //                {
            //                    hashOfCategories[tokens[j].Trim()] =
            //                        int.Parse(hashOfCategories[tokens[j].Trim()].ToString()) + 1;
            //                }
            //                else
            //                {
            //                    hashOfCategories.Add(tokens[j].Trim(), 1);
            //                }
            //            }
            //        }
            //        if (ListofUsersLiteral.Text.Substring(ListofUsersLiteral.Text.Length - 2, 2) == ", ")
            //            ListofUsersLiteral.Text = ListofUsersLiteral.Text.Substring(0, ListofUsersLiteral.Text.Length - 2);
            //    }
            //    else
            //    {
            //        ListofUsersLiteral.Text += "Non-Assigned User";
            //        if (hashOfCategories.ContainsKey("-2"))
            //        {
            //            hashOfCategories["-2"] = int.Parse(hashOfCategories["-2"].ToString()) + 1;
            //        }
            //        else
            //        {
            //            hashOfCategories["-2"] = 1;
            //        }
            //    }
            //}
            ListofUsersLiteral.Text += "</td><td>" +
                DateTime.Parse(dvAdStatistics[i]["Date"].ToString()).ToShortDateString() + "</td></tr>";
        }

        dvAdCategories.RowFilter = "";
        ListofUsersLiteral.Text += "</table>";

        System.Drawing.Color level4Colora = System.Drawing.Color.FromArgb(51, 51, 51);
        System.Drawing.Color level4Colorb = System.Drawing.Color.FromArgb(134, 175, 200);
        System.Drawing.Color level3Colora = System.Drawing.Color.FromArgb(33, 65, 11);
        System.Drawing.Color level3Colorb = System.Drawing.Color.FromArgb(115, 148, 77);
        System.Drawing.Color level2Colora = System.Drawing.Color.FromArgb(213, 79, 2);
        System.Drawing.Color level2Colorb = System.Drawing.Color.FromArgb(244, 189, 67);
        System.Drawing.Color level1Colora = System.Drawing.Color.FromArgb(192, 140, 8);
        System.Drawing.Color level1Colorb = System.Drawing.Color.FromArgb(227, 201, 70);

        ConsumerRadChart.Chart.Series.Clear();

        ConsumerRadChart.Chart.ChartTitle.TextBlock.Text = "Ad Statistics for '" + dvAd[0]["Header"].ToString() + "'. Date: " + lastDayDay.Trim();
        ConsumerRadChart.Chart.ChartTitle.TextBlock.Appearance.AutoTextWrap = Telerik.Charting.Styles.AutoTextWrap.True;

        //Put the UserCount into the DV so that we can easily bind it to the chart
        DataTable dt = dvAdCategories.ToTable();
        DataColumn dc = new DataColumn("UserCount");
        DataColumn dc2 = new DataColumn("XCount");
        dt.Columns.Add(dc);
        dt.Columns.Add(dc2);
        DataRow row;
        int colcount = 0;
        for (int i = 0; i < dvAdCategories.Count; i++)
        {
            if (hashOfCategories.ContainsKey(dvAdCategories[i]["CategoryID"].ToString()))
            {
                dt.Rows[i]["UserCount"] = int.Parse(hashOfCategories[dvAdCategories[i]["CategoryID"].ToString()].ToString());
                dt.Rows[i]["XCount"] = colcount;
                colcount++;
            }
        }

        if (hashOfCategories.ContainsKey("-1"))
        {
            row = dt.NewRow();
            row["UserCount"] = hashOfCategories["-1"].ToString();
            row["Name"] = "Location Only";
            row["CategoryID"] = "-1";
            row["XCount"] = colcount;
            dt.Rows.Add(row);
        }

        if (hashOfCategories.ContainsKey("-2"))
        {
            row = dt.NewRow();
            row["UserCount"] = hashOfCategories["-2"].ToString();
            row["Name"] = "Non-Assigned User";
            row["CategoryID"] = "-2";
            row["XCount"] = colcount + 1;
            dt.Rows.Add(row);
        }

        dvAdCategories = new DataView(dt, "", "", DataViewRowState.CurrentRows);

        dvAdCategories.RowFilter = "Isnull(UserCount,'Null Column') <> 'Null Column'";

        ChartSeries salesSeries1;
        int itemsCount = 0;
        ConsumerRadChart.DataGroupColumn = "Name";
        ConsumerRadChart.DataSource = dvAdCategories;

        int maxYCount = 0;
        ConsumerRadChart.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Between;
        ConsumerRadChart.PlotArea.XAxis.AutoShrink = true;
        ConsumerRadChart.SeriesOrientation = Telerik.Charting.ChartSeriesOrientation.Vertical;
        ConsumerRadChart.PlotArea.XAxis.AxisLabel.Appearance.RotationAngle = 45;
        for (int i = 0; i < dvAdCategories.Count; i++)
        {
            if (hashOfCategories.ContainsKey(dvAdCategories[i]["CategoryID"].ToString()))
            {

                //TitleLabel.Text += "<br/><br/>"+i.ToString()+": "+dvAdCategories[i]["Name"].ToString()+", userCount" +
                //dvAdCategories[i]["UserCount"].ToString() + ", XCount: "+dvAdCategories[i]["XCount"].ToString() +
                //", catID: " + dvAdCategories[i]["CategoryID"].ToString();

                salesSeries1 = new ChartSeries(dvAdCategories[i]["Name"].ToString(), ChartSeriesType.Bar);
                //salesSeries1.Appearance.LabelAppearance.Visible = false;
                for (int j = 0; j < itemsCount; j++)
                {
                    ChartSeriesItem chartSI = new ChartSeriesItem(true);
                    chartSI.Visible = false;
                    salesSeries1.Items.Add(chartSI);
                }
                salesSeries1.DataYColumn = "UserCount";
                salesSeries1.DataXColumn = "XCount";
                salesSeries1.DataLabelsColumn = "UserCount";
                ConsumerRadChart.AddChartSeries(salesSeries1);
                salesSeries1.Items.Add(new ChartSeriesItem(double.Parse(dvAdCategories[i]["UserCount"].ToString()),
                    dvAdCategories[i]["UserCount"].ToString()));
                salesSeries1.PlotArea.XAxis.AxisLabel.Appearance.RotationAngle = 45;
                ConsumerRadChart.PlotArea.XAxis.AddItem(dvAdCategories[i]["Name"].ToString());
                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].TextBlock.Text = dvAdCategories[i]["Name"].ToString();
                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].Appearance.RotationAngle = 45;
                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Bottom;

                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].TextBlock.Appearance.Position.Y = float.Parse("-30.00");
                //ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].TextBlock.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Bottom;
                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].TextBlock.Appearance.Position.Auto = true;

                itemsCount++;

                if (int.Parse(dvAdCategories[i]["UserCount"].ToString()) > maxYCount)
                    maxYCount = int.Parse(dvAdCategories[i]["UserCount"].ToString());
            }
        }

        //if (hashOfCategories.ContainsKey("Location Only"))
        //{
        //    ConsumerRadChart.PlotArea.XAxis.AddItem("Location Only");
        //    ConsumerRadChart.PlotArea.XAxis.Items[ConsumerRadChart.PlotArea.XAxis.Items.Count - 1].TextBlock.Text = "Location Only";
        //    salesSeries1 = new ChartSeries("Location Only", ChartSeriesType.Bar);
        //    salesSeries1.Items.Clear();
        //    ChartSeriesItem item = new ChartSeriesItem(int.Parse(hashOfCategories["Location Only"].ToString()),
        //        "Location Only");
        //    item.YValue = itemsCount;
        //    salesSeries1.AddItem(item);
        //    ConsumerRadChart.AddChartSeries(salesSeries1);
        //    ConsumerRadChart.DataBind();
        //    if (int.Parse(hashOfCategories["Location Only"].ToString()) > maxYCount)
        //        maxYCount = int.Parse(hashOfCategories["Location Only"].ToString());
        //}
        //else
        //{
        //    //ChartSeriesItem item = new ChartSeriesItem(0, "Location Only");
        //    //item.XValue = ConsumerRadChart.PlotArea.XAxis.Items.Count;

        //    //salesSeries1.Items.Add(item);
        //}

        ConsumerRadChart.PlotArea.XAxis.AxisLabel.TextBlock.Text = "Categories";
        ConsumerRadChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Number of Views";
        ConsumerRadChart.Chart.PlotArea.XAxis.AxisLabel.TextBlock.Text = "Categories";
        ConsumerRadChart.Chart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Number of Views";
        ConsumerRadChart.Chart.PlotArea.XAxis.AxisLabel.Appearance.Dimensions.Height = 200;
        ConsumerRadChart.Chart.PlotArea.YAxis.LabelStep = 1;
        ConsumerRadChart.Chart.PlotArea.XAxis.LabelStep = 1;
        ConsumerRadChart.Chart.PlotArea.YAxis.AutoScale = false;
        ConsumerRadChart.Chart.PlotArea.YAxis.AxisMode = ChartYAxisMode.Normal;
        ConsumerRadChart.Chart.PlotArea.YAxis.MaxValue = maxYCount + 2;
        ConsumerRadChart.Chart.PlotArea.YAxis.Step = 1;
        ConsumerRadChart.Chart.PlotArea.Appearance.Dimensions.Margins.Right = 200;
        ConsumerRadChart.Chart.PlotArea.XAxis.AutoScale = false;

        //ConsumerRadChart.Chart.PlotArea.XAxis.MaxValue = dvAdCategories.Count + 2;
        //ConsumerRadChart.Chart.PlotArea.XAxis.Step = 1;
        //ConsumerRadChart.DataBind();

        ChartPanel.Visible = true;
    }
        protected void Page_Load(object sender, EventArgs e)
        {            
            if (_levelID <= 0) return;


            List<AsyncPageTask> taskList = new List<AsyncPageTask>();
            taskList.Add(new AsyncPageTask(GetStudentCounts));
            taskList.Add(new AsyncPageTask(LoadDistrictParms));

            foreach (AsyncPageTask page in taskList)
            {
                PageAsyncTask newTask = new PageAsyncTask(page.OnBegin, page.OnEnd, page.OnTimeout, "StudentSearch", true);
                Page.RegisterAsyncTask(newTask);
            }
            taskList = null;
            Page.ExecuteRegisteredAsyncTasks();

            studentCountChart.DataSource = countData;
            studentCountChart.ChartTitle.Visible = false;
            studentCountChart.DataBind();

            studentPieChartXmlHttpPanel.Value = "";

            //Handle Legend Labels
            studentCountChart.Series.Clear();
            var nSeries = new ChartSeries();

            studentCountChart.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
            studentCountChart.PlotArea.Appearance.FillStyle.FillType = FillType.Solid;
            studentCountChart.PlotArea.Appearance.Border.Color = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
           
            studentCountChart.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 8);
            studentCountChart.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 8);
            studentCountChart.PlotArea.XAxis.Appearance.LabelAppearance.Position.AlignedPosition = AlignedPositions.TopRight;
            nSeries.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.Black;
            nSeries.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 8);
            nSeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
            
            var count = 0;

            //change to foreach for easier reading
            var gradeList = new List<string>();
            foreach (DataRow dr in countData.Rows)
            {
                var value = DataIntegrity.ConvertToDouble(dr["StudentCount"]);
                var xValue = 0;
                switch (_level)
                {
                    case EntityTypes.Teacher:
                        xValue = dr.Table.Columns.Contains("ClassID") ? DataIntegrity.ConvertToInt(dr["ClassID"]) : 0;
                        break;
                    case EntityTypes.School:
                        gradeList.Add(dr.Table.Columns.Contains("GradeNumber") ? dr["GradeNumber"].ToString() : string.Empty);
                        xValue = gradeList.Count - 1;
                        break;
                }

                var myItem = new ChartSeriesItem(value) { Name = dr["Grade"].ToString(), XValue = xValue };
                myItem.Appearance.FillStyle.MainColor = System.Drawing.ColorTranslator.FromHtml(StyleController.GetPieChartColor(dr["Grade"].ToString(), count++)); ;
                myItem.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;
                
                if (value <= 0) myItem.Label.Visible = false;

                nSeries.Type = ChartSeriesType.Pie;
                nSeries.AddItem(myItem);
                /*
                var classIDValue = DataIntegrity.ConvertToDouble(dr["ClassID"]);
                var classItem = new ChartSeriesItem(classIDValue) { XValue = DataIntegrity.ConvertToDouble(dr["ClassID"]) };
                classItem.Label.Visible = false;*/


                /****************************************************************
                 * if user does not have Tab_Search_Staff permissions, then hide
                 * the search tab and the radPageView associated with it.
                 * *************************************************************/
                if (!UserHasPermission(Permission.Tab_Search_Students))
                {
                    RadPageView2.Visible = false;
                    foreach (Telerik.Web.UI.RadTab tab in RadTabStrip2.Tabs)
                    {
                        if (tab.Text == "Search")
                        {
                            tab.Visible = false;
                            break;
                        }
                    }
                }

                /*******************************************************************
                 * If user does not have Icon_ExpandedSearch_Students permissions, 
                 * then hide the "Advanced Search" link via its surrounding div tag.
                 * ****************************************************************/

                StudentSearch_DivAdvancedSearch.Visible = (UserHasPermission(Permission.Icon_ExpandedSearch_Students));

            }

            SessionObject.StudentSearchParms.AddParm("GradeListFilter", gradeList);

            studentCountChart.Series.Add(nSeries);

            if (IsPostBack)
            {
                //Reloads previous search results if session object search text has a value
                if (studentsSearchText_smallTile.Value == "Search by last name..." && SessionObject.StudentSearchTxtPostBack_smallTile != null
                    && SessionObject.StudentSearchTxtPostBack_smallTile.Length > 0)
                    SearchStudentsByLastName_Click(null, null);

                return;
            }

            studentSearchMoreLink.Visible = false;
            studentsSearchTileGrid.Visible = false;
            enrollStudent.Visible = UserHasPermission(Base.Enums.Permission.Enroll_Student);
            addNewStudent.Visible = UserHasPermission(Base.Enums.Permission.Create_Student);
        }
    private void fillRadChart_PAL_Type(string sFromDate,  string sFilter_AccountFrom)
    {
        RadChart_PAL_Type.Chart.Series[0].Items.Clear();

        DateTime dtMonthStart = Convert.ToDateTime(sFromDate);
        string sMonthStart = dtMonthStart.ToString("MM/01/yyyy");
        string sMonthEnd = dtMonthStart.AddMonths(1).AddSeconds(-1).ToString();

        DataSet DS = objReportClass.Rpt_REPORT_ListPal_Type(UC_Visitlog_Visitlog1.ACCOUNT_ID, sFilter_AccountFrom, sMonthStart, sMonthEnd);

        if (DS.Tables[0].Rows.Count > 0)
        {
            foreach (DataRow DR in DS.Tables[0].Rows)
            {
                if (Convert.ToInt32(DR["COUNT"]) != 0)
                {
                    ChartSeriesItem CSI = new ChartSeriesItem();
                    CSI.YValue = Convert.ToDouble(DR["COUNT"]);
                    CSI.Label.TextBlock.Text = DR["ITEM_TEXT"].ToString() + " (" + DR["COUNT"].ToString() + ")";
                    CSI.XValue = 1;
                    RadChart_PAL_Type.Series[0].AddItem(CSI);
                }

            }
        }
    }
    protected void BindBetweenChart(object sender, EventArgs e)
    {
        // Clear
        rc_bar_between.Clear();
        rc_bar_between.PlotArea.XAxis.Items.Clear();

        // Get dates from calander boxes.
        DateTime start_date = Convert.ToDateTime(rdp_between_start.SelectedDate);
        DateTime end_date   = Convert.ToDateTime(rdp_between_end.SelectedDate);

        bool anyTerritoriesChecked = false;

        for (int i = 0; i < rtv_offices.Nodes[0].Nodes.Count; i++)
        {
            if (rtv_offices.Nodes[0].Nodes[i].Checked == true)
            {
                anyTerritoriesChecked = true;
                break;
            }
        }

        if (start_date > end_date)
        {
            Util.PageMessage(this, "Start date cannot be after the end date!");
        }
        else if (rdp_between_start.SelectedDate == null || rdp_between_end.SelectedDate == null)
        {
            Util.PageMessage(this, "Please ensure you specify a start and an end date.");
        }
        else if (!anyTerritoriesChecked)
        {
            Util.PageMessage(this, "Must have at least one territory selected.");
        }
        else
        {
            // Define parent chart series
            ChartSeries parent_series = new ChartSeries("parent_series", ChartSeriesType.Bar);
            parent_series.Appearance.TextAppearance.TextProperties.Font = new Font("Verdana", 8, FontStyle.Regular);
            parent_series.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
            parent_series.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
            rc_bar_between.Series.Add(parent_series);

            for (int i = 0; i < rtv_offices.Nodes[0].Nodes.Count; i++)
            {
                if (rtv_offices.Nodes[0].Nodes[i].Checked)
                {
                    String territory = rtv_offices.Nodes[0].Nodes[i].Text;
                    String qry       = "SELECT IFNULL(CONVERT(SUM(Price*Conversion),SIGNED),0) as total_price " +
                                       "FROM db_salesbook sb, db_salesbookhead sbh " +
                                       "WHERE sb.sb_id = sbh.SalesBookID " +
                                       "AND Office=@office " +
                                       "AND ent_date BETWEEN @start_date AND @end_date " +
                                       "AND deleted=0 AND IsDeleted=0 AND red_lined=0";
                    String[]  pn         = { "@start_date", "@end_date", "@office" };
                    Object[]  pv         = { start_date.ToString("yyyy/MM/dd"), end_date.ToString("yyyy/MM/dd"), territory };
                    DataTable totalprice = SQL.SelectDataTable(qry, pn, pv);

                    if (totalprice.Rows.Count > 0 && totalprice.Rows[0]["total_price"] != DBNull.Value)
                    {
                        double          price    = Convert.ToDouble(totalprice.Rows[0]["total_price"]);
                        ChartSeriesItem csi_item = new ChartSeriesItem(
                            price,
                            Util.TextToCurrency(price.ToString(), "usd"),
                            Util.ColourTryParse(rtv_offices.Nodes[0].Nodes[i].Value),
                            false);

                        csi_item.Name   = territory;
                        csi_item.Parent = parent_series;
                        parent_series.AddItem(csi_item);
                        rc_bar_between.PlotArea.XAxis.Items.Add(new ChartAxisItem(territory));
                    }
                }
            }
        }
    }
Пример #45
0
        public Form1()
        {
            InitializeComponent();

            radChart1.Series.Clear();

            ChartSeries cs = new ChartSeries();

            ChartSeriesItem csi = new ChartSeriesItem();

            csi.XValue  = 0;
            csi.YValue  = 3;
            csi.YValue2 = 4.5;
            csi.YValue3 = 1;
            csi.YValue4 = 6;
            cs.Items.Add(csi);

            ChartSeriesItem csi2 = new ChartSeriesItem();

            csi2.XValue  = 1;
            csi2.YValue  = 5;
            csi2.YValue2 = 4;
            csi2.YValue3 = 2;
            csi2.YValue4 = 8;
            cs.Items.Add(csi2);

            ChartSeriesItem csi3 = new ChartSeriesItem();

            csi3.XValue  = 2;
            csi3.YValue  = 5.5;
            csi3.YValue2 = 5;
            csi3.YValue3 = 3;
            csi3.YValue4 = 6;
            cs.Items.Add(csi3);

            ChartSeriesItem csi4 = new ChartSeriesItem();

            csi4.XValue  = 3;
            csi4.YValue  = 5;
            csi4.YValue2 = 4;
            csi4.YValue3 = 3;
            csi4.YValue4 = 7;
            cs.Items.Add(csi4);

            ChartSeriesItem csi5 = new ChartSeriesItem();

            csi5.XValue  = 4;
            csi5.YValue  = 5;
            csi5.YValue2 = 6;
            csi5.YValue3 = 4;
            csi5.YValue4 = 6.5;
            cs.Items.Add(csi5);

            cs.Type = ChartSeriesType.CandleStick;
            cs.Appearance.LabelAppearance.Visible = false;
            radChart1.Series.Add(cs);

            radChart1.PlotArea.XAxis.AutoScale = false;
            radChart1.PlotArea.XAxis.MaxValue  = 4;
            radChart1.PlotArea.XAxis.MinValue  = 0;
            radChart1.PlotArea.XAxis.Step      = 1;

            radChart1.Update();
            this.EnabledQSFButtons = QSFButtons.None;
        }
Пример #46
0
    protected void PopulateCurrentGraph()
    {
        double total_usd = 0;

        rc_bar_latest.Clear();
        rc_bar_latest.PlotArea.XAxis.Items.Clear();

        // Define parent chart series and format
        ChartSeries parent_series = new ChartSeries("parent_series", ChartSeriesType.Bar);

        parent_series.Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
        parent_series.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
        parent_series.Appearance.TextAppearance.TextProperties.Font  = new Font("Verdana", 7, FontStyle.Regular);
        parent_series.ActiveRegionToolTip = "Click to view this book.";
        rc_bar_latest.Series.Add(parent_series);

        // Iterate offices
        double highest_price = 0;
        double lowest_price  = 999999;

        for (int i = 0; i < offices.Rows.Count; i++)
        {
            String territory = (String)offices.Rows[i]["Office"];
            String shortname = (String)offices.Rows[i]["ShortName"];
            Color  colour    = Util.ColourTryParse((String)offices.Rows[i]["Colour"]);

            // For each office..
            String qry = "SELECT ROUND(IFNULL(CONVERT(SUM(Price*Conversion), SIGNED),0)- " +
                         "IFNULL((SELECT CONVERT(SUM(rl_price*Conversion), SIGNED) " +
                         "FROM db_salesbook WHERE rl_sb_id=(SELECT SalesBookID FROM db_salesbookhead WHERE Office=@office ORDER BY StartDate DESC LIMIT 1) " +
                         "AND red_lined=1),0)) as total_price " +
                         "FROM db_salesbook sb, db_salesbookhead sbh " +
                         "WHERE sb.sb_id = (SELECT SalesBookID FROM db_salesbookhead WHERE Office=@office ORDER BY StartDate DESC LIMIT 1) " +
                         "AND sbh.SalesBookID = (SELECT SalesBookID FROM db_salesbookhead WHERE Office=@office ORDER BY StartDate DESC LIMIT 1) " +
                         "AND deleted=0 AND IsDeleted=0";
            double price = 0;
            if (Double.TryParse(SQL.SelectString(qry, "total_price", "@office", territory), out price))
            {
                total_usd += price;

                // Get max and min for chart padding
                highest_price = Math.Max(highest_price, price);
                lowest_price  = Math.Min(lowest_price, price);

                ChartSeriesItem csi_item = new ChartSeriesItem(
                    price,
                    Util.TextToCurrency(price.ToString(), "usd"),
                    colour,
                    false);

                csi_item.Name   = territory;
                csi_item.Parent = parent_series;
                parent_series.AddItem(csi_item);
                rc_bar_latest.PlotArea.XAxis.Items.Add(new ChartAxisItem(shortname));
            }
        }

        if (lowest_price != 0)
        {
            lowest_price = (lowest_price + (lowest_price / 100) * 40);
        }

        double max_value = (highest_price + (highest_price / 100) * 20);
        double step      = highest_price / 10;

        if (step == 0)
        {
            step = 1;
        }
        rc_bar_latest.PlotArea.YAxis.AddRange(0, max_value, step);

        // Set total USD label
        lbl_total_usd.Text = "Total USD: " + Util.TextToCurrency(total_usd.ToString(), "usd");
    }
Пример #47
0
    protected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        String ter = ((GridView)sender).ToolTip;

        if (e.Row.RowIndex == 3)
        {
            e.Row.BackColor               = Color.LightSteelBlue;
            e.Row.Cells[13].Text          = "Annual";
            e.Row.Cells[0].Font.Underline = true;
        }

        // Total rows
        if (e.Row.RowIndex == 4 || e.Row.RowIndex == 5 || e.Row.RowIndex == 6 || e.Row.RowIndex == 7)
        {
            int total = 0;
            for (int i = 1; i < e.Row.Cells.Count - 1; i++)
            {
                int this_val = 0;
                Int32.TryParse(e.Row.Cells[i].Text, out this_val);
                total += this_val;

                if (!ter.Contains("_break"))
                {
                    // If book value
                    if (e.Row.RowIndex == 4)
                    {
                        group_bookvalue[(i - 1)] = Convert.ToInt32(group_bookvalue[(i - 1)]) + this_val;
                        group_bookvalue[12]     += this_val;
                    }
                    // If outstanding
                    else if (e.Row.RowIndex == 5)
                    {
                        group_outstanding[(i - 1)] = Convert.ToInt32(group_outstanding[(i - 1)]) + this_val;
                        group_outstanding[12]     += this_val;
                    }
                    // If litigation
                    else if (e.Row.RowIndex == 6)
                    {
                        group_litigation[(i - 1)] = Convert.ToInt32(group_litigation[(i - 1)]) + this_val;
                        group_litigation[12]     += this_val;
                    }
                    // If red line
                    else
                    {
                        group_red_line[(i - 1)] = Convert.ToInt32(group_red_line[(i - 1)]) + this_val;
                        group_red_line[12]     += this_val;
                    }
                }
                e.Row.Cells[i].Text = Util.TextToCurrency(this_val.ToString(), "usd");
            }
            e.Row.Cells[13].Text = Util.TextToCurrency(total.ToString(), "usd");
        }
        else if (e.Row.RowIndex == 8 && ter != "Group") // ADP
        {
            ChartSeries cs = new ChartSeries(ter, ChartSeriesType.Line);
            if (!ter.Contains("_break"))
            {
                cs.Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.SeriesName;
                for (int i = 0; i < offices.Rows.Count; i++)
                {
                    if (ter == offices.Rows[i]["Office"].ToString())
                    {
                        cs.Appearance.FillStyle.MainColor = Util.ColourTryParse(offices.Rows[i]["Colour"].ToString());
                        break;
                    }
                }
                rc_line_adp.Series.Add(cs);
            }

            for (int i = 1; i < e.Row.Cells.Count - 1; i++)
            {
                double adp = 0.0;
                if (e.Row.Cells[i].Text == "&nbsp;" || e.Row.Cells[i].Text == "0")
                {
                    e.Row.Cells[i].Text = "-";
                }
                else
                {
                    String qry = "SELECT FORMAT(AVG(DATEDIFF(date_paid, ent_date)),1) as 'ADP' " +
                                 "FROM db_salesbook sb, db_salesbookhead sbh " +
                                 "WHERE sb.sb_id = sbh.SalesBookID " +
                                 "AND date_paid >= ent_date " +
                                 "AND date_paid <= NOW() " +
                                 "AND date_paid IS NOT NULL " +
                                 "AND deleted=0 AND IsDeleted=0 AND red_lined=0 " +
                                 "AND sbh.SalesBookID=@sb_id";
                    DataTable dt_adp = SQL.SelectDataTable(qry, "@sb_id", e.Row.Cells[i].Text);

                    if (dt_adp.Rows.Count > 0 && dt_adp.Rows[0]["ADP"] != DBNull.Value)
                    {
                        e.Row.Cells[i].Text = dt_adp.Rows[0]["ADP"].ToString();
                        adp = Convert.ToDouble(dt_adp.Rows[0]["ADP"]);
                        group_adp[i - 1]  += adp;
                        region_adp[i - 1] += adp;
                    }
                    else
                    {
                        e.Row.Cells[i].Text = "-";
                    }
                }

                if (!ter.Contains("_break"))
                {
                    // cap adp to 100
                    if (adp > 100)
                    {
                        adp = 100;
                    }
                    ChartSeriesItem csi_item = new ChartSeriesItem(adp, " ");
                    cs.AddItem(csi_item);
                }
            }

            if (cb_region.Checked)
            {
                if (!ter.Contains("_break"))
                {
                    region_adp[12]++; // use 12th index as number of offices per region
                }
                else
                {
                    for (int i = 1; i < e.Row.Cells.Count - 1; i++)
                    {
                        e.Row.Cells[i].Text = (region_adp[i - 1] / region_adp[12]).ToString("N1");
                        region_adp[i - 1]   = 0;
                    }
                    region_adp[12] = 0;
                }
            }
        }
        else if (e.Row.RowIndex == 9) // PAID %
        {
            decimal sum     = 0;
            decimal val     = 0;
            int     numnums = 0;
            for (int i = 1; i < e.Row.Cells.Count - 1; i++)
            {
                // Fix _break header names when grouping by region
                if (cb_region.Checked)
                {
                    if (((GridView)sender).Rows[3].Cells[i].Text.Contains("_break"))
                    {
                        ((GridView)sender).Rows[3].Cells[i].Text = Server.HtmlEncode(months[(i - 1)] + " " + dd_year.SelectedItem.Text);
                    }
                }

                Decimal.TryParse(e.Row.Cells[i].Text, out val);
                if (!ter.Contains("_break"))
                {
                    group_paid[(i - 1)] += val;
                }
                if (val != 0)
                {
                    numnums++;
                }
                sum += val;

                if (ter != "Group")
                {
                    // Grab paid% history from previous day
                    String    qry     = "SELECT Paid FROM db_cashreporthistory WHERE Date=@date AND Office=@office AND Year=@year AND CalendarMonth=@cal_month";
                    DataTable history = SQL.SelectDataTable(qry,
                                                            new String[] { "@date", "@office", "@year", "@cal_month" },
                                                            new Object[] {
                        DateTime.Now.Date.Subtract(new TimeSpan(24, 0, 0)).ToString("yyyy/MM/dd").Substring(0, 10),
                        ter,
                        dd_year.SelectedItem.Text,
                        ((GridView)sender).Columns[i].HeaderText
                    });

                    // Add coloured labels for today/yesterday
                    Label lbl_paid_cur = new Label();
                    lbl_paid_cur.Text = Server.HtmlEncode(e.Row.Cells[i].Text + "%");

                    ImageButton arrow = new ImageButton();
                    arrow.Enabled = false;
                    arrow.Height  = arrow.Width = 10;
                    arrow.Attributes.Add("style", "position:relative; top:1px; left:3px;");
                    if (history.Rows.Count > 0)
                    {
                        if (Convert.ToDouble(e.Row.Cells[i].Text) > Convert.ToDouble(history.Rows[0]["Paid"]))
                        {
                            lbl_paid_cur.ForeColor = Color.Green;
                            arrow.ImageUrl         = "~/Images/Icons/qr_Up.png";
                        }
                        else if (Convert.ToDouble(history.Rows[0]["Paid"]) > Convert.ToDouble(e.Row.Cells[i].Text))
                        {
                            lbl_paid_cur.ForeColor = Color.Red;
                            arrow.ImageUrl         = "~/Images/Icons/qr_Down.png";
                        }
                        else if (Convert.ToDouble(history.Rows[0]["Paid"]) == Convert.ToDouble(e.Row.Cells[i].Text))
                        {
                            //lbl_paid_cur.ForeColor = Color.Orange;
                            arrow.Height   = 8;
                            arrow.ImageUrl = "~/Images/Icons/qr_Equal.png";
                        }
                        arrow.ToolTip = "Yesterday's value: " + history.Rows[0]["Paid"].ToString() + "%";
                    }
                    else
                    {
                        arrow.Height   = arrow.Width = 12;
                        arrow.ImageUrl = "~/Images/Icons/qr_Unknown.png";
                        arrow.ToolTip  = "No history found";
                        arrow.Attributes.Add("style", "position:relative; top:2px; left:3px;");
                    }
                    e.Row.Cells[i].Controls.Add(lbl_paid_cur);
                    e.Row.Cells[i].Controls.Add(arrow);
                }
            }

            decimal avg = 0;
            if (sum != 0 && numnums != 0)
            {
                if (!ter.Contains("_break"))
                {
                    group_paid[13] += 1;
                }
                avg = sum / numnums;
            }
            if (!ter.Contains("_break"))
            {
                group_paid[12] += avg;
            }
            e.Row.Cells[13].Text = avg.ToString("N2") + "% (avg.)";

            // LAST ROW, DO GROUP
            if (ter == "Group")
            {
                GridView    gv_group    = (GridView)sender;
                GridViewRow bookval     = gv_group.Rows[4];
                GridViewRow outstanding = gv_group.Rows[5];
                GridViewRow litigation  = gv_group.Rows[6];
                GridViewRow redline     = gv_group.Rows[7];
                GridViewRow adp         = gv_group.Rows[8];

                // Add series to group chart
                rc_line_gadp.Clear();
                ChartSeries cs = new ChartSeries("Group Avg", ChartSeriesType.Line);
                cs.Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.SeriesName;
                rc_line_gadp.Series.Add(cs);

                double total_g_avg_value = 0;
                int    total_g_avg_moths = 0;
                for (int j = 1; j < bookval.Cells.Count; j++)
                {
                    // GROUP BOOKVAL
                    bookval.Cells[j].Text = Util.TextToCurrency(group_bookvalue[(j - 1)].ToString(), "USD");
                    // GROUP OUTSTANDING
                    outstanding.Cells[j].Text = Util.TextToCurrency(group_outstanding[(j - 1)].ToString(), "USD");
                    // GROUP LITIGATION
                    litigation.Cells[j].Text = Util.TextToCurrency(group_litigation[(j - 1)].ToString(), "USD");
                    // GROUP RED LINE
                    redline.Cells[j].Text = Util.TextToCurrency(group_red_line[(j - 1)].ToString(), "USD");
                    // GROUP ADP
                    if (group_adp[(j - 1)] == 0)
                    {
                        e.Row.Cells[j].Text = "0 (avg.)";
                    }
                    else
                    {
                        double avg_adp = (((double)group_adp[(j - 1)]) / offices.Rows.Count);
                        total_g_avg_value += avg_adp;
                        total_g_avg_moths++;
                        adp.Cells[j].Text = avg_adp.ToString("N2") + " (avg.)";

                        // Add to group chart
                        ChartSeriesItem csi_item = new ChartSeriesItem(avg_adp, " ");
                        cs.AddItem(csi_item);
                    }
                    // GROUP PAID
                    if (group_paid[13] == 0)
                    {
                        e.Row.Cells[j].Text = "0.0% (avg.)";
                    }
                    else
                    {
                        e.Row.Cells[j].Text = ((group_paid[(j - 1)]) / group_paid[13]).ToString("N2") + "% (avg.)";
                    }
                }

                // Add month names to line chart
                rc_line_adp.PlotArea.XAxis.Items.Clear();
                rc_line_gadp.PlotArea.XAxis.Items.Clear();
                for (int i = 1; i < e.Row.Cells.Count - 1; i++)
                {
                    String issue_name = ((GridView)sender).HeaderRow.Cells[i].Text;
                    rc_line_adp.PlotArea.XAxis.Items.Add(new ChartAxisItem(issue_name));
                    rc_line_gadp.PlotArea.XAxis.Items.Add(new ChartAxisItem(issue_name));
                }

                // Add group average line
                rc_line_gadp.PlotArea.MarkedZones.Clear();
                ChartMarkedZone g_avg = new ChartMarkedZone();
                g_avg.Appearance.FillStyle.MainColor = Color.Orange;
                double g_avg_value = total_g_avg_value / total_g_avg_moths;
                g_avg.ValueStartY = g_avg_value;
                g_avg.ValueEndY   = g_avg_value + (g_avg_value / 100) * 2;
                rc_line_gadp.PlotArea.MarkedZones.Add(g_avg);
                rc_line_gadp.ChartTitle.TextBlock.Text = "Group Average Days to Pay (" + g_avg_value.ToString("N1") + " avg.)"; // set chart title
            }
        }
    }
    private void fillRadChart_DD_TotalsCount(string sXAxisValue, string sFromDate, string sFilter_AccountFrom)
    {
        DateTime dtMonthStart = Convert.ToDateTime(sFromDate);
        string sMonthStart = dtMonthStart.ToString("MM/01/yyyy");
        string sMonthEnd = dtMonthStart.AddMonths(1).AddSeconds(-1).ToString();

        //insert the new xaxis coordinate
        string sXAxisText = dtMonthStart.ToString("MMM yy");
        ChartAxisItem CAI = new ChartAxisItem();
        CAI.Value = Convert.ToDecimal(sXAxisValue);
        CAI.TextBlock.Text = sXAxisText;// dtCurrent.AddDays(-giChartDaySpan).ToString("MMM d");
        CAI.Appearance.RotationAngle = 0;
        CAI.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Top;
        RadChart_DD_TotalsCount.PlotArea.XAxis.Items.Add(CAI);

        DataSet DS = objBackofficeClass.GET_Items_AnyItemTable("LVType", "LIST_DD");

        //RadChart_DD_LVTotals.Series[0].Name = DS.Tables[0].Rows[0]["ITEM_TEXT"].ToString();

        DS = objReportClass.Rpt_REPORT_ListDd_LVType(sMonthStart, sMonthEnd, UC_Visitlog_Visitlog1.ACCOUNT_ID, sFilter_AccountFrom);

           // if (DS.Tables[0].Rows.Count > 0 && Convert.ToDateTime(sMonthStart) < DateTime.Now)
        {
            DataRow DR = DS.Tables[0].Rows[0];

            ChartSeriesItem CSI = new ChartSeriesItem();
            CSI.YValue = Convert.ToDouble(DR["Count"]);
            CSI.XValue = Convert.ToDouble(sXAxisValue);
            RadChart_DD_TotalsCount.Series[0].AddItem(CSI);
        }
    }
Пример #49
0
        public override void Update()
        {
            var chartItemDataBuilder = CreateChartItemDataBuilder(ChartDisplayRange);

            // filter and orders
            var stats = chartItemDataBuilder.PrepareStatistic(StorageModel.GetFilteredCashPlayerStatistic());

            object previousGroupKey = null;

            chartItemDataBuilder.Prepare(stats.Length);

            var chartSeriesItems = new Dictionary <ChartSeries, List <ChartSeriesItem> >();

            var itemsCounter = 0;

            for (var statIndex = 0; statIndex < stats.Length; statIndex++)
            {
                var stat = stats[statIndex];

                var currentGroupKey = chartItemDataBuilder.BuildGroupKey(stat, statIndex);

                var isNew = !currentGroupKey.Equals(previousGroupKey);

                if (isNew)
                {
                    itemsCounter++;
                }

                previousGroupKey = currentGroupKey;

                foreach (var chartSerie in ChartCollection)
                {
                    ChartSeriesItem previousChartSeriesItem = null;
                    ChartSeriesItem chartSeriesItem         = null;

                    if (!chartSeriesItems.ContainsKey(chartSerie))
                    {
                        chartSeriesItems.Add(chartSerie, new List <ChartSeriesItem>());
                    }

                    if (isNew)
                    {
                        chartSeriesItem = new ChartSeriesItem
                        {
                            Format   = chartSerie.Format,
                            Category = chartItemDataBuilder.GetValueFromGroupKey(currentGroupKey)
                        };

                        previousChartSeriesItem = chartSeriesItems[chartSerie].LastOrDefault();
                        chartSeriesItems[chartSerie].Add(chartSeriesItem);
                    }
                    else
                    {
                        previousChartSeriesItem = chartSeriesItem = chartSeriesItems[chartSerie].LastOrDefault();
                    }

                    chartSerie.UpdateChartSeriesItem(chartSeriesItem, previousChartSeriesItem, stat, statIndex, stats.Length);
                }
            }

            if (ChartDisplayRange == ChartDisplayRange.Hands)
            {
                HandsCount = itemsCounter;
            }

            App.Current?.Dispatcher.Invoke(() => ChartCollection?.ForEach(x => x.ItemsCollection?.Clear()));

            if (chartSeriesItems.Count > 0)
            {
                chartSeriesItems.Keys.ForEach(charSerie =>
                {
                    charSerie.ItemsCollection = new ObservableCollection <ChartSeriesItem>(chartSeriesItems[charSerie]);
                });
            }
        }
Пример #50
0
 protected void BuildSeriesItem(ChartSeries series, double count, string label, int sum = 0)
 {
     if (sum == 0)
     {
         ChartSeriesItem item = new ChartSeriesItem(count);
         item.Label.TextBlock.Appearance.Visible = false;
         series.Items.Add(item);
     }
     else
     {
         ChartSeriesItem item = new ChartSeriesItem(count, sum.ToString());
         item.Label.TextBlock.Appearance.TextProperties.Color = Color.HotPink;
         item.Label.TextBlock.Appearance.TextProperties.Font = new Font("Arial", 12, FontStyle.Bold);
         series.Items.Add(item);
     }
 }