Esempio n. 1
0
        public static IHtmlString BarChart(this HtmlHelper html, ChartData chartData, int width, int height, double axisYMax, double axisYMin, double? axisYInterval,
                        string axisYLabelFormat, bool displayLegend,
                        string axisXTitle, string axisYTitle,
                        SeriesChartType chartType,
                        bool eachSeriesInNewChartArea, List<CustomLabels.CustomLabel> axisYCustomLabels = null)
        {
            //get chart
            if (chartData != null)
            {
                BarChart barChart = new BarChart(chartData, width, height, axisYMax, axisYMin, axisYInterval,
                                                 axisYLabelFormat, displayLegend, chartType,
                                                 eachSeriesInNewChartArea, axisYCustomLabels);

                barChart.AxisXTitle = axisXTitle;
                barChart.AxisYTitle = axisYTitle;
                
                Chart chart = barChart.Chart;

                //render
                StringBuilder control = new StringBuilder();
                HtmlTextWriter writer = new HtmlTextWriter(new System.IO.StringWriter(control));
                chart.RenderControl(writer);

                string screenReaderTable = ScreenReaderTable(chartData);

                return new MvcHtmlString("<div aria-hidden=\"true\">" + control.ToString() + "</div>" + screenReaderTable);
            }

            return new MvcHtmlString(string.Empty);
        }
Esempio n. 2
0
        private static string ScreenReaderTable(ChartData chartData)
        {
            List<ChartData.Series> seriesCollection = chartData.SeriesCollection;
            if (seriesCollection != null)
            {
                StringBuilder adaTable = new StringBuilder();

                adaTable.Append("<table summary=\"" + chartData.ChartTitle + "\" class=\"hidden\" >");
                // header row
                adaTable.Append("<thead><tr><th></th>");
                foreach (var point in seriesCollection[0].Points)
                {
                    TagBuilder thHeader = new TagBuilder("th");
                    thHeader.Attributes.Add("scope", "col");
                    thHeader.SetInnerText(point.AxisLabel);

                    adaTable.Append(thHeader.ToString());
                }
                adaTable.Append("</thead></tr>");

                // data rows
                adaTable.Append("<tbody>");
                foreach (var series in seriesCollection)
                {
                    StringBuilder dataRow = new StringBuilder();

                    dataRow.Append("<tr>");

                    TagBuilder tdRowValue = new TagBuilder("th");
                    tdRowValue.Attributes.Add("scope", "row");
                    tdRowValue.SetInnerText(series.Name);

                    dataRow.Append(tdRowValue.ToString());

                    foreach (var point in series.Points)
                    {
                        TagBuilder tdValue = new TagBuilder("td");
                        tdValue.SetInnerText(point.Label ?? point.Value.ToString());

                        dataRow.Append(tdValue.ToString());
                    }
                    dataRow.Append("</tr>");

                    adaTable.Append(dataRow.ToString());
                }
                adaTable.Append("</tbody>");

                adaTable.Append("</table>");

                return adaTable.ToString();
            }
            else
            {
                return string.Empty;
            }
        }
Esempio n. 3
0
 public static IHtmlString BarChart(this HtmlHelper html, ChartData chartData, int width, int height, double axisYMax, double axisYMin, double? axisYInterval,
                 string axisYLabelFormat, bool displayLegend, SeriesChartType chartType, 
                 bool eachSeriesInNewChartArea, List<CustomLabels.CustomLabel> axisYCustomLabels = null)
 {
     return BarChart(html,
                     chartData,
                     width,
                     height,
                     axisYMax,
                     axisYMin,
                     axisYInterval,
                     axisYLabelFormat,
                     displayLegend,
                     null,
                     null,
                     chartType,
                     eachSeriesInNewChartArea,
                     axisYCustomLabels);
 }
 protected override void ExecuteTest()
 {
     var service = new StateAssessmentNormalizedChartService(repository, metricNodeResolver);
     actualModel = service.Get(StateAssessmentNormalizedChartRequest.Create(suppliedStudentUSI, suppliedSchoolId, suppliedMetricVariantId));
 }
Esempio n. 5
0
 public BenchmarkModel()
 {
     ChartData = new ChartData();        
 }
 public AssessmentRateChartModel()
 {
     ChartData = new ChartData();
     MetricFootnotes = new List<MetricFootnote>();
 }
 protected override void ExecuteTest()
 {
     var service = new GradeLevelChartService(repository, metricInstanceSetKeyResolver, metricGoalProvider, metricNodeResolver);
     actualModel = service.Get(new GradeLevelChartRequest()
                                   {
                                       SchoolId = suppliedSchoolId,
                                       MetricVariantId = suppliedMetricVariantId,
                                       Title = suppliedChartTitle
                                   });
 }
Esempio n. 8
0
        private Series CreateSeries(ChartData.Series series)
        {
	        var chartType = ChartType;
            var lineSeries = series as ChartData.LineSeries;
            if (lineSeries != null)
                chartType = SeriesChartType.Line;

            var chartSeries = new Series(series.Name)
            {
                ChartType = chartType,
                Color = ColorTranslator.FromHtml(series.Style.BackgroundColor),
                LabelForeColor = ColorTranslator.FromHtml(ChartColors.White),
				BackHatchStyle = GetHatchStyle(series.Style),
				BackSecondaryColor = ColorTranslator.FromHtml(series.Style.ForegroundColor),
                CustomProperties = seriesCustomProperty,
                Font = (Font)defaultFont.Clone(),
                Legend = series.ShowInLegend ? displayLegendName : hideLegendName,
            };

            if (DisplayLegend && ChartData.SeriesCollection[0].Points.Count > 6)
                chartSeries.CustomProperties = showLegendSeriesCustomProperty;

            if (EachSeriesInNewChartArea && ChartData.SeriesCollection.Count == 3)
                chartSeries.CustomProperties = threeChartAreaSeriesCustomProperty;

            if (EachSeriesInNewChartArea && ChartData.SeriesCollection.Count >= 4)
                chartSeries.CustomProperties = multipleChartAreaSeriesCustomProperty;

            if (lineSeries != null)
            {
                chartSeries.BorderWidth = 2;
                chartSeries["LabelStyle"] = lineSeries.LabelStyle;
                chartSeries.MarkerImage = lineSeries.MarkerImage;
                chartSeries.LabelForeColor = ColorTranslator.FromHtml(series.Style.BackgroundColor);
                chartSeries.IsValueShownAsLabel = true;
            }

            return chartSeries;
        }
Esempio n. 9
0
        public BarChart(ChartData chartData, int width, int height, double axisYMax, double axisYMin, double? axisYInterval, string axisYLabelFormat,
            bool displayLegend, SeriesChartType chartType, bool eachSeriesInNewChartArea, List<CustomLabels.CustomLabel> axisYCustomLabels = null)
        {
            ChartData = chartData;
            Width = width;// 740;
            Height = height;// 200;
            YMax = axisYMax;// 1;
            YMin = axisYMin;// 0;
            AxisYInterval = (axisYInterval ?? .25);
            AxisYLabelFormat = !string.IsNullOrEmpty(axisYLabelFormat) ? axisYLabelFormat : "{P0}";
            DisplayLegend = displayLegend;
            AxisXTitle = chartData.AxisXTitle;
            AxisYTitle = chartData.AxisYTitle;
            ChartType = chartType;
            EachSeriesInNewChartArea = eachSeriesInNewChartArea;
            AxisYCustomLabels = axisYCustomLabels;
            ChartId = chartData.ChartId;

            //setup control
            SetYMax();

            if (DisplayLegend)
                chartAreaWidth = 65;

            if (EachSeriesInNewChartArea)
            {
                horizontalOffset = 10;
                //chartAreaWidth = 85; chartAreaWidth - horizontalOffset;
                if (ChartData.SeriesCollection.Count > 0)
                    chartAreaWidth = chartAreaWidth / ChartData.SeriesCollection.Count;
            }

            Chart chart = SetupChart(String.Format(chartControlIdFormat, 0, ChartId));

            if (ChartData.StripLines != null)
            {
                foreach (var stripLine in ChartData.StripLines)
                {
                    if (stripLine == null)
                        continue;

                    //Adding a strip line.
                    var sl = new StripLine
                                 {
                                     Interval = -1,
                                     BorderColor = ColorTranslator.FromHtml(stripLine.Color),
                                     IntervalOffset = stripLine.Value,
                                     ToolTip = stripLine.Tooltip
                                 };

                    chart.ChartAreas[0].AxisY.StripLines.Add(sl);
                }
            }

            if (ChartData.SeriesCollection == null || ChartData.SeriesCollection.Count == 0 ||
                ChartData.SeriesCollection.First().Points.Count == 0)
            {
                var series =
                    CreateSeries(new ChartData.Series { Name = defaultSeries, Style = ChartSeriesStyle.White, ShowInLegend = false });
                int i = series.Points.AddY(0);
                series.Points[i].ToolTip = String.Empty;
                series.Points[i].Label = String.Empty;
                series.Points[i].AxisLabel = String.Empty;
                series.Points[i].Color = ColorTranslator.FromHtml(ChartColors.White);
                chart.ChartAreas[0].AxisX.MajorTickMark.Size = 0;
                chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = ColorTranslator.FromHtml(ChartColors.White);

                chart.Series.Add(series);
                Chart = chart;
                return;
            }

            if (!EachSeriesInNewChartArea)
                PlotPoints(chart);
            else
                PlotPointsInMultipleChartAreas(chart);

            Chart = chart;
        }
 protected override void ExecuteTest()
 {
     var service = new StateAssessmentNotNormalizedChartService(repository, metricNodeResolver);
     actualModel = service.Get(new StateAssessmentNotNormalizedChartRequest()
                                   {
                                       StudentUSI = suppliedStudentUSI,
                                       SchoolId = suppliedSchoolId,
                                       MetricVariantId = suppliedMetricVariantId,
                                       Title = suppliedChartTitle,
                                   });
 }
Esempio n. 11
0
		public HistoricalChartModel()
		{
			AvailablePeriods = new List<PeriodItem>();
			ChartData = new ChartData();
		}