public static ChartData Map(Survey Survey, long QuestionId)
        {
            //  Instantiate the analysis service
            var analyser = SurveyAnalysisServiceFactory.Create(Survey);
            //  instantiate the chartdata;
            ChartData data = new ChartData();

            //  Get the question object from the survey
            var question = Survey.Questions.FirstOrDefault(x => x.QuestionId == QuestionId);

            //  Map the data
            data.Title = question.Text;                             //  Load question text
            data.Width = 400;
            //  Set the height of the chart
            data.Height = (question.AvailableResponses.Count() * 30) + 150;

            data.Results = new List<ChartInformation>();

            long totalRespondents = analyser.TotalRespondents();    //  Load total
            foreach (var answer in question.AvailableResponses)
            {
                var result = new ChartInformation();
                result.responses = (analyser.TotalForQuestionResponse(question.QuestionId, answer.LikertScaleNumber) / totalRespondents);
                result.Text = answer.Text;
                data.Results.Add(result);
            }

            return data;
        }
 public SurveyQuestionChart(ChartData chartData)
     : base(chartData)
 {
 }
Beispiel #3
0
 //private List<Series> ChartSeriesData { get; set; }
 //private string ChartTitle { get; set; }
 public MVCChart(ChartData ChartData)
 {
     if (ChartData == null)
         throw new ArgumentNullException("ChartData", "No data supplied to build a chart with");
     _chartData = ChartData;
 }
 public override MVCChart Create(ChartData chartData)
 {
     return new SurveyQuestionChart(chartData);
 }
 public abstract MVCChart Create(ChartData chartdata);