Esempio n. 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;
        }
 /// <summary>
 /// The chart's subtitle
 /// </summary>
 /// <param name="subtitle"></param>
 /// <returns></returns>
 public Highcharts SetSubtitle(Subtitle subtitle)
 {
     _Subtitle = subtitle;
     return this;
 }