public ActionResult CreateChart(string nameLv)
        {
            const string Blue  = "<Chart BackColor=\"#D3DFF0\" BackGradientStyle=\"TopBottom\" BackSecondaryColor=\"White\" BorderColor=\"26, 59, 105\" BorderlineDashStyle=\"Solid\" BorderWidth=\"15\" Palette=\"BrightPastel\">\r\n    <ChartAreas>\r\n        <ChartArea Name=\"Default\" _Template_=\"All\" BackColor=\"64, 165, 191, 228\" BackGradientStyle=\"TopBottom\" BackSecondaryColor=\"White\" BorderColor=\"64, 64, 64, 64\" BorderDashStyle=\"Solid\" ShadowColor=\"Transparent\" /> \r\n    </ChartAreas>\r\n    <Legends>\r\n        <Legend _Template_=\"All\" BackColor=\"Transparent\" Font=\"Trebuchet MS, 8.25pt, style=Bold\" IsTextAutoFit=\"False\" /> \r\n    </Legends>\r\n    <BorderSkin SkinStyle=\"Emboss\" /> \r\n  </Chart>";
            var          chart = new SimpleChart.Chart(width: 800, height: 300, theme: Blue).AddTitle(("Membership function: " + nameLv)).AddLegend();

            for (int i = 0; i < FKB.ListVar.Count; i++)
            {
                if (FKB.ListVar[i].Name == nameLv)
                {
                    chart.AddSeries(
                        name: FKB.ListVar[i].terms[0].Name,
                        chartType: "Line",
                        xValue: new[] { FKB.ListVar[i].terms[0].a, FKB.ListVar[i].terms[0].b, FKB.ListVar[i].terms[0].c },
                        yValues: new[] { 1, 1, 0 });


                    for (int j = 1; j < FKB.ListVar[i].terms.Count - 1; j++)
                    {
                        chart.AddSeries(
                            name: FKB.ListVar[i].terms[j].Name,
                            chartType: "Line",
                            xValue: new[] { FKB.ListVar[i].terms[j].a, FKB.ListVar[i].terms[j].b, FKB.ListVar[i].terms[j].c },
                            yValues: new[] { 0, 1, 0 });
                    }
                    chart.AddSeries(
                        name: FKB.ListVar[i].terms[FKB.ListVar[i].terms.Count - 1].Name,
                        chartType: "Line",
                        xValue: new[] { FKB.ListVar[i].terms[FKB.ListVar[i].terms.Count - 1].a, FKB.ListVar[i].terms[FKB.ListVar[i].terms.Count - 1].b, FKB.ListVar[i].terms[FKB.ListVar[i].terms.Count - 1].c },
                        yValues: new[] { 0, 1, 1 })
                    .Write();
                    break;
                }
            }
            return(null);
        }
        public ActionResult DadosColuna()
        {
            var chart = new System.Web.Helpers.Chart(width: 300, height: 220).AddTitle("Test");

            var xValues = new List <String>();
            var yValues = new List <String>();

            var lista = (from n in db.Naufragos
                         select new
            {
                n.Nome,
                n.Estado
            });

            foreach (var item in lista)
            {
                xValues.Add(item.Nome);
                yValues.Add(item.Estado);
            }

            chart.AddSeries(chartType: "Doughnut",
                            xValue: xValues,
                            yValues: yValues).Write("png");

            return(null);
        }
Exemple #3
0
        public string SavePersonCompanyTicketChart(string userName, int reportId, DateTime startDate, DateTime endDate)
        {
            AccountController ac       = new AccountController();
            string            realName = ac.GetRealName(userName);
            //读取两周的数据,自己客户的票量,按照日期展示曲线图
            OtaCrmModel db           = new OtaCrmModel();
            var         companyNames = from c in db.OtaCompany
                                       where c.SalesUserName == realName
                                       select c.CompanyName;

            var q = from p in db.AgentGradeOperation
                    where p.statDate.Value >= startDate && p.statDate.Value <= endDate && companyNames.Contains(p.agentName)
                    group p by p.statDate
                    into g
                    orderby g.Key
                    select new { ticketSum = g.Sum(b => b.CurDateTicketCount.Value), ticketDay = g.Key };

            List <string> dateList      = new List <string>();
            List <int>    ticketSumList = new List <int>();

            foreach (var item in q)
            {
                dateList.Add(item.ticketDay.Value.ToString("yyyyMMdd"));
                ticketSumList.Add(item.ticketSum);
            }

            System.Web.Helpers.Chart chart = new System.Web.Helpers.Chart(width: 500, height: 300, theme: ChartTheme.Blue, themePath: null);
            chart.AddTitle(text: userName + "客户票量统计", name: userName + "_CompanyTicketSum");
            chart.AddSeries(name: "票量"
                            , chartType: "Column"
                            , chartArea: ""
                            , axisLabel: "张"
                            , legend: "票量合计"
                            , markerStep: 1
                            , xValue: dateList
                            , xField: "日期"
                            , yValues: ticketSumList
                            , yFields: "票量");

            string filePath = Server.MapPath("~/CompanyImages/Reports/" + reportId.ToString());
            CompanyBusinessDailyPhotoesController cbd = new CompanyBusinessDailyPhotoesController();

            cbd.CreateFolderIfNeeded(filePath);
            string fileName = userName + "_CompanyTicketSum_" + startDate.ToString("yyyyMMdd") + "_" + endDate.ToString("yyyyMMdd") + ".jpg";

            chart.Save(path: Path.Combine(filePath, fileName), format: "jpeg");

            return(fileName);
        }
Exemple #4
0
        public ActionResult Chart()
        {
            //essayons de retourner tous les etudiants
            EtudiantContext db   = new EtudiantContext();
            List <Etudiant> list = db.etudiants.ToList();
            //initialisation des compteurs des filieres
            int info = 0, indus = 0, gtr = 0, gpmc = 0;

            //variable pour les nombre totale et le reste qui n'a pas choisi les filieres
            int nbrTotal = list.Count, nbrReste = 0;

            for (int i = 0; i < nbrTotal; i++)
            {
                if (list[i].Choix == null)
                {
                    //un etudiant avec null dans choix alors on va l'es ajouter dans le reste
                    nbrReste++;
                }
                //sinon on va traiter les choix comme ca
                else
                {
                    if (list[i].Validated)
                    {
                        char[] chiffr = (list[i].Choix).ToCharArray();

                        if (chiffr[0] == 'F')
                        {
                            info++;
                        }
                        if (chiffr[0] == 'P')
                        {
                            gpmc++;
                        }
                        if (chiffr[0] == 'T')
                        {
                            gtr++;
                        }
                        if (chiffr[0] == 'D')
                        {
                            indus++;
                        }
                    }
                }
            }

            //les pourcentages
            //double nbrTotalP = Convert.ToDouble(nbrTotal) / Convert.ToDouble(nbrTotal) * 100;
            //double nbrResteP = Convert.ToDouble(nbrReste) / Convert.ToDouble(nbrTotal) * 100;
            double infoP  = Convert.ToDouble(info) / Convert.ToDouble(nbrTotal) * 100;
            double gtrP   = Convert.ToDouble(gtr) / Convert.ToDouble(nbrTotal) * 100;
            double gpmcP  = Convert.ToDouble(gpmc) / Convert.ToDouble(nbrTotal) * 100;
            double indusP = Convert.ToDouble(indus) / Convert.ToDouble(nbrTotal) * 100;


            string[] vx = { "info", "indus", "gtr", "gpmc" };
            double[] vy = { infoP, indusP, gtrP, gpmcP };

            System.Web.Helpers.Chart chart = new System.Web.Helpers.Chart(width: 900, height: 400, theme: ChartTheme.Blue);


            chart.AddSeries(chartType: "Column", xValue: vx, yValues: vy);
            chart.Write("png");
            return(null);
        }
 private string generateSchoolChart(string[] sources, int[] sourceCounts)
 {
     string uuid = Guid.NewGuid().ToString();
     var filePath = getChartPath(uuid);
     //Theme to hide slice labels
     string chartTheme = @"<Chart>
                             <Series>
                                 <Series Name=""Programs"" ChartType=""Pie"" LegendText=""#VALX (#PERCENT{P2})"" CustomProperties=""PieLabelStyle=Disabled"">
                                 </Series>
                             </Series>
                             <Legends>
                                 <Legend _Template_=""All"" Docking=""Bottom"">
                                 </Legend>
                             </Legends>
                         </Chart>";
     var myChart = new System.Web.Helpers.Chart(width: 250, height: 400, theme: chartTheme);
     myChart.AddTitle("Candidates Selected");
     myChart.AddSeries(
         "Programs", chartType: SeriesChartType.Pie.ToString(),
         xValue: sources,
         yValues: sourceCounts
         );
     myChart.AddLegend("Programs");
     myChart.Save(filePath, "jpg");
     return uuid;
 }
 private string generateFYChart(int[,] sourceCounts, string[] sources, bool byFY)
 {
     string uuid = Guid.NewGuid().ToString(); // Generate unique ID for file name
     var filePath = getChartPath(uuid);
     string chartTheme = @"<Chart>
                             <ChartAreas>
                                 <ChartArea Name=""Default"" _Template_=""All"">
                                     <AxisX>
                                         <LabelStyle Interval=""1""/>
                                     </AxisX>
                                 </ChartArea>
                             </ChartAreas>
                             <Legends>
                                 <Legend _Template_=""All"" Docking=""Top"" LegendStyle=""Column"" DockedToChartArea=""Default"" IsDockedInsideChartArea=""true"" BackColor=""Transparent"" Font=""Times New Roman, 6pt"">
                                 </Legend>
                             </Legends>";
     chartTheme += "<Series>";
     for (var i = 0; i < sources.Length; i++)
     {
         chartTheme += "" +
                         "<Series Name='" + sources[i] + "' ChartType='StackedColumn' Label='#VALY{#}' CustomProperties='SmartLabelStyle=Enabled'>" +
                         "</Series>";
     }
     chartTheme += "</Series></Chart>";
     var myChart = new System.Web.Helpers.Chart(width: 900, height: 130, theme: chartTheme);
     string[] months;
     if (byFY)
     {
         months = new[] { "Prior", "Oct", "Nov", "Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept" };
     }
     else
     {
         months = new[] { "Prior", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
     }
     for (var i = 0; i < sources.Length; i++)
     {
         int[] temp = new int[13];
         for (var j = 0; j < 13; j++)
         {
             temp[j] = sourceCounts[i, j];
         }
         myChart.AddSeries(sources[i],
                 chartType: SeriesChartType.StackedColumn.ToString(),
                 xValue: months,
                 yValues: temp);
     }
     myChart.AddLegend();
     myChart.Save(filePath, "jpg");
     return uuid;
 }