示例#1
0
        public static Highcharts ConstructChart(Dictionary<int, double> dataToDisplay, string chartTitle,string chartDescription)
        {
            var title = new Title() { Text = chartTitle };
            var subtitle = new Subtitle() { Text = chartDescription };
            var XData = dataToDisplay.Keys.ToList().ConvertAll(x => Convert.ToString(x)).ToArray();
            var YData = dataToDisplay.Values;
            var xaxisTitle = new XAxisTitle { Text = "X" };
            var yaxisTitle = new YAxisTitle { Text = "Y" };

            Highcharts chart = new Highcharts("Chart")
                .SetTitle(title)
                .SetSubtitle(subtitle)
                .SetXAxis(new XAxis
                {
                    Categories = XData,
                    Title = xaxisTitle,
                    LineWidth = 0
                })
                .SetYAxis(new YAxis
                {
                    Title = yaxisTitle,
                    LineWidth = 0
                })
                .SetSeries(new Series
                {
                    Data = new Data(YData.OfType<object>().ToArray()),
                });

            return chart;
        }
示例#2
0
        private void loadSummaryPieChart()
        {
            queryString = "select count(*) as count, CASE greatest(Neutral,Happy,Sad,Angry,Surprised,Scared,Disgusted)" +
                          " WHEN Neutral THEN 'Neutral'" +
                          " WHEN Happy THEN 'Happy'" +
                          " WHEN Sad THEN 'Sad'" +
                          " WHEN Angry THEN 'Angry'" +
                          " WHEN Surprised THEN 'Surprised'" +
                          " WHEN Scared THEN 'Scared'" +
                          " WHEN Disgusted THEN 'Disgusted'" +
                          " else 'Unknown'" +
                          " END AS maxColumn from alef.emotions where Student_id=" + studentId +
                          " and Timestamp BETWEEN " + start + " AND " + end + " group by maxColumn;";

            DataTable data              = loadDatafromDB(queryString);
            var       percentages       = new List <object[]>();
            double    totalNumOfRecords = 0;

            foreach (DataRow dr in data.Rows)
            {
                totalNumOfRecords += Convert.ToDouble(dr["count"]);
            }

            foreach (DataRow dr in data.Rows)
            {
                double percentage = Math.Round((((Convert.ToDouble(dr["count"])) / totalNumOfRecords) * 100.0), 2);
                percentages.Add(new object[] { dr["maxColumn"].ToString(), percentage.ToString() });
            }

            Title title = new DotNet.Highcharts.Options.Title();

            title.Text = "";

            DotNet.Highcharts.Highcharts chart2 = new DotNet.Highcharts.Highcharts("chart2").SetTitle(title);
            chart2.SetSeries(new Series
            {
                Type = DotNet.Highcharts.Enums.ChartTypes.Pie,
                Data = new Data(percentages.ToArray())
            });
            ltrChart2.Text = chart2.ToHtmlString();
        }
示例#3
0
        private void generateGraph(ConfigDAO configs, Literal literal)
        {
            DataTable data = loadDatafromDB(queryString);

            Object[] intensities = new Object[data.Rows.Count];
            string[] timestamps  = new string[data.Rows.Count];
            int      index       = 0;

            foreach (DataRow dr in data.Rows)
            {
                intensities[index] = (dr[configs.emotion].ToString() != "") ? dr[configs.emotion] : null;
                timestamps[index]  = dr["Timestamp"].ToString();
                index++;
            }

            Series[] serieses   = new Series[1];
            Series   dataSeries = new Series {
                Data = new Data(intensities)
            };

            dataSeries.Color = configs.color;
            dataSeries.Name  = configs.emotion;
            serieses[0]      = dataSeries;

            Title title = new DotNet.Highcharts.Options.Title();

            title.Text = configs.graphTitle;

            XAxis xAxis = new XAxis();

            xAxis.Categories   = timestamps;
            xAxis.TickInterval = 200;

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(configs.chartName).SetXAxis(xAxis).SetSeries(serieses).SetTitle(title);
            literal.Text = chart.ToHtmlString();
        }
 /// <summary>
 /// The chart's main title.
 /// </summary>
 /// <param name="title"></param>
 /// <returns></returns>
 public Highcharts SetTitle(Title title)
 {
     _Title = title;
     return this;
 }
示例#5
0
        private void loadEmotionGraph()
        {
            queryString = "select Neutral,Happy,Sad,Angry,Surprised,Scared,Disgusted,Timestamp from alef.emotions where Student_id= "
                          + studentId + " and Timestamp BETWEEN " + start + " AND " + end + "; ";

            DataTable data = loadDatafromDB(queryString);

            Object[] neutralIntensities   = new Object[data.Rows.Count];
            Object[] happyIntensities     = new Object[data.Rows.Count];
            Object[] sadIntensities       = new Object[data.Rows.Count];
            Object[] angryIntensities     = new Object[data.Rows.Count];
            Object[] surprisedIntensities = new Object[data.Rows.Count];
            Object[] scaredIntensities    = new Object[data.Rows.Count];
            Object[] disgustedIntensities = new Object[data.Rows.Count];
            string[] timestamps           = new string[data.Rows.Count];

            int index = 0;

            foreach (DataRow dr in data.Rows)
            {
                neutralIntensities[index]   = (dr["Neutral"].ToString() != "") ? dr["Neutral"] : null;
                happyIntensities[index]     = (dr["Happy"].ToString() != "") ? dr["Happy"] : null;
                sadIntensities[index]       = (dr["Sad"].ToString() != "") ? dr["Sad"] : null;
                angryIntensities[index]     = (dr["Angry"].ToString() != "") ? dr["Angry"] : null;
                surprisedIntensities[index] = (dr["Surprised"].ToString() != "") ? dr["Surprised"] : null;
                scaredIntensities[index]    = (dr["Scared"].ToString() != "") ? dr["Scared"] : null;
                disgustedIntensities[index] = (dr["Disgusted"].ToString() != "") ? dr["Disgusted"] : null;
                timestamps[index]           = dr["Timestamp"].ToString();
                index++;
            }

            Series[] serieses = new Series[7];

            Series neutralDataSeries = new Series {
                Data = new Data(neutralIntensities)
            };

            neutralDataSeries.Name = "Neutral";

            Series happyDataSeries = new Series {
                Data = new Data(happyIntensities)
            };

            happyDataSeries.Name = "Happy";

            Series sadDataSeries = new Series {
                Data = new Data(sadIntensities)
            };

            sadDataSeries.Name = "Sad";

            Series angryDataSeries = new Series {
                Data = new Data(angryIntensities)
            };

            angryDataSeries.Name = "Angry";

            Series surprisedDataSeries = new Series {
                Data = new Data(surprisedIntensities)
            };

            surprisedDataSeries.Name = "Surprised";

            Series scaredDataSeries = new Series {
                Data = new Data(scaredIntensities)
            };

            scaredDataSeries.Name = "Scared";

            Series disgustedDataSeries = new Series {
                Data = new Data(disgustedIntensities)
            };

            disgustedDataSeries.Name = "Disgusted";

            serieses[0] = neutralDataSeries;
            serieses[1] = happyDataSeries;
            serieses[2] = sadDataSeries;
            serieses[3] = angryDataSeries;
            serieses[4] = surprisedDataSeries;
            serieses[5] = scaredDataSeries;
            serieses[6] = disgustedDataSeries;

            Title title = new DotNet.Highcharts.Options.Title();

            title.Text = "Emotion Summary";

            XAxis xAxis = new XAxis();

            xAxis.Categories   = timestamps;
            xAxis.TickInterval = 200;

            DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart1").SetXAxis(xAxis).SetSeries(serieses).SetTitle(title);
            ltrChart.Text = chart.ToHtmlString();
        }