ASP.Net MVC C#画图 页面调用

摘要:
lst=bll.GetTOP5DJJMData(查询);MinimumRelativePieSize=40“;=null&dp1.YValues=newdouble[]{percent*100};dp1.LegendText=string.Concat((nv.Buy1.Length<

/////C# 后台代码

public FileContentResult PieChart()
        {
            TransactionStatisticsBLL bll = new TransactionStatisticsBLL();
            TransactionStatistics_Query query = new TransactionStatistics_Query();
            GetQuery(query);
            query.Stock = Request["SecuCode"];
            query.InfoType = Request["InfoType"];
            List<EM_DataCenter_TransactionStatistics> lst = bll.GetTOP5DJJMData(query);
            List<EM_DataCenter_TransactionStatistics> lst1 = GetYYBTOP(lst).Take(4).ToList();
            Chart chart1 = new Chart();
            Color backColor = ColorTranslator.FromHtml("#171717");

            chart1.BackColor = backColor;
            chart1.Width = 390;
            chart1.Height = 130;
            chart1.ChartAreas.Add("area1");
            chart1.Series.Add("金额占比");
            chart1.Series["金额占比"].CustomProperties = "DoughnutRadius=45, PieDrawingStyle=Concave, CollectedLabel=Other, MinimumRelativePieSize=40";
            chart1.Series["金额占比"].ChartType = SeriesChartType.Pie;
            chart1.Series["金额占比"]["DoughnutRadius"] = "30";
            chart1.Series["金额占比"]["PieLabelStyle"] = "Inside";

            if (lst1 != null && lst1.Count > 0)
            {
                double surplus = 1;
                foreach (EM_DataCenter_TransactionStatistics nv in lst1)
                {
                    DataPoint dp1 = new DataPoint();
                    var percent = (double)(nv.NetBuy1Amount / nv.NetBuyTotalAmount);
                    surplus -= percent;
                    dp1 = new DataPoint();
                    dp1.YValues = new double[] { percent * 100 };
                    dp1.LegendText = string.Concat((nv.Buy1.Length <= 6 ? nv.Buy1 : nv.Buy1.Substring(0, 6) + "..."), " (", StringTools.DecimalFormat(decimal.Parse((percent * 100).ToString())), "%)");
                    chart1.Series["金额占比"].Points.Add(dp1);
                }
                DataPoint dp2 = new DataPoint();
                dp2 = new DataPoint();
                dp2.YValues = new double[] { surplus * 100 };
                dp2.LegendText = string.Concat("其他", " (", StringTools.DecimalFormat(decimal.Parse((surplus * 100).ToString())), "%)");
                chart1.Series["金额占比"].Points.Add(dp2);
            }

            chart1.ChartAreas[0].BackColor = backColor;

            chart1.ChartAreas[0].Position = new ElementPosition(4, 0, 50, 90);
            chart1.Legends.Add("leg2");

            chart1.Legends[0].BackColor = backColor;
            chart1.Legends[0].ForeColor = ColorTranslator.FromHtml("#D0D0D0");

            chart1.Legends[0].Font = new System.Drawing.Font("宋体", 9, FontStyle.Regular);
            chart1.Legends[0].Position = new ElementPosition(55, 4, 50, 90);

            chart1.DataBind();
            MemoryStream memory = new MemoryStream();
            chart1.SaveImage(memory, ChartImageFormat.Jpeg);
            var bdata = memory.ToArray();
            memory.Dispose();
            return new FileContentResult(bdata, "image/Jpeg");
        }

/////////页面调用

$(obj).attr("src", "path/PieChart?SecuCode=" + secucode + "&InfoType=" + infotype + "&random=" + Math.round(Math.random() * 100));

免责声明:文章转载自《ASP.Net MVC C#画图 页面调用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Klimt 特点 与OpenGL和OpenGL|ES 对比及其关系设计模式之PIMPL模式下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

以前整理的网络上免费API接口

以前整理的一些免费的API接口,具体是否好用还需要时间测试,但是先分享给大家。 天气接口 聚合数据: http://op.juhe.cn/onebox/weather/query 用例 官方文档 来源:weather.com 百度接口: http://api.map.baidu.com/telematics/v3/weather?location=嘉兴...

docker容器以非root用户启动应用

  docker容器启动应用默认的是root用户,可以使用ps命令来查看。很多的目录及文件权限是777,这些都是不安全的。        最近的一项工作就是要以非root用户启动docker,并且修改777权限为755.        在Dockefile中创建指定的用户xxx和用户组,然后用su-exec xxx  java ... 来启动应用,使用ps...

el-checkbox点击无法回显

问题:动态赋予el-checkbox给isChecked属性时候,前端样式不生效 原因:前端添加checked属性, vue并没有添加get set方法,因此,监听不到checked值变化,进而不能更新view。 方案: 用set方法 this.$set(item2, 'isChecked', true) <!-- * @Author:wht...

Windows子系统配置,cmder配置, pycharm配置django开发环境

背景   以往,新手配置python的linux开发环境会遇到许多大坑。最近偶然接触到windows10子系统(Ubuntu),内存占用少,丝滑流畅,感觉十分便利,本地配置好pycharm及代码同步,也省去了安装虚拟机,双系统的麻烦,码代码和娱乐两不误,开发学习十分便利。但是windows的原生的cmd用起来感觉不便,不过搭配cmder替换cmd使用,如虎...

解决ASP.NET MVC5"无法对 null 引用执行运行时绑定"

无法对 null 引用执行运行时绑定 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 无法对 null 引用执行运行时绑定源错误:  视图,Demo....

微信 ios端config配置失败 android端正常

<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> 如果你页面启用了https,务必引入 https://res.wx.qq.com/open/js/jweixin-1.0.0.js ,否则将无法在iOS9.0以上系统中成功使用JSSDK...