示例#1
0
        public IActionResult GetImageFree()
        {
            var cp    = new ChartProviderFree();
            var chart = cp.GetChart();

            chart.Title = "Hours per day";

            var xData = new List <string>
            {
                "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
            };

            var yData = new List <int>
            {
                12, 7, 4, 10, 3, 11, 5
            };

            chart.XData = xData;
            chart.YData = yData;

            var bmp    = chart.GenerateChart();
            var stream = new MemoryStream();

            bmp.Save(stream, ImageFormat.Png);
            var data = stream.ToArray();

            stream.Close();

            return(File(data, "image/png"));
        }
        public IActionResult GetImageFree()
        {
            ChartProviderFree cp    = new ChartProviderFree();
            IChart            chart = cp.GetChart();

            chart.Title = "Hours per day";

            List <string> xdata = new List <string>();

            xdata.Add("Mon");
            xdata.Add("Tue");
            xdata.Add("Wed");
            xdata.Add("Thu");
            xdata.Add("Fri");
            xdata.Add("Sat");
            xdata.Add("Sun");

            List <int> ydata = new List <int>();

            ydata.Add(12);
            ydata.Add(7);
            ydata.Add(4);
            ydata.Add(10);
            ydata.Add(3);
            ydata.Add(11);
            ydata.Add(5);

            chart.XData = xdata;
            chart.YData = ydata;
            Bitmap       bmp    = chart.GenerateChart();
            MemoryStream stream = new MemoryStream();

            bmp.Save(stream, ImageFormat.Png);
            byte[] data = stream.ToArray();
            stream.Close();
            return(File(data, "image/png"));
        }