zoukankan      html  css  js  c++  java
  • Visifire实现统计图

            /// <summary>
            /// 柱形图
            /// </summary>
            public static Chart InitCompareChart(string fundName, string tenThousandRate, string sevenRate)
            {
                Chart CompareChart = new Chart();
                CompareChart.Theme = "Theme3";
                Visifire.Charts.Title t = new Visifire.Charts.Title();
                t.Text = string.Format("{0}与存款收益比较", fundName);
                CompareChart.Titles.Add(t);
    
                DataSeries dataSeries = new DataSeries { RenderAs = RenderAs.Bar };
                dataSeries.LabelEnabled = true;
                dataSeries.LegendText = "每万元单日收益";
                double tenThousandAccrual = 0;
                Double.TryParse(tenThousandRate, out tenThousandAccrual);
                dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = fundName, YValue = tenThousandAccrual });
                dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "定期五年", YValue = 1.3014 });
                dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "定期三年", YValue = 1.1644 });
                dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "定期二年", YValue = 1.0274 });
                dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "定期一年", YValue = 0.8219 });
                dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "定期半年", YValue = 0.7671 });
                dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "定期三月", YValue = 0.7123 });
                dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "活期", YValue = 0.0959 });
    
                DataSeries dataSeries2 = new DataSeries { RenderAs = RenderAs.Bar };
                dataSeries2.LabelEnabled = true;
                dataSeries2.LegendText = "七日年化收益率";
                double qiRiAnnualizedYield = 0;
                Double.TryParse(sevenRate.Replace("%", ""), out qiRiAnnualizedYield);
                dataSeries2.DataPoints.Add(new DataPoint { AxisXLabel = fundName, YValue = qiRiAnnualizedYield });
                dataSeries2.DataPoints.Add(new DataPoint { AxisXLabel = "定期五年", YValue = 4.75 });
                dataSeries2.DataPoints.Add(new DataPoint { AxisXLabel = "定期三年", YValue = 4.25 });
                dataSeries2.DataPoints.Add(new DataPoint { AxisXLabel = "定期二年", YValue = 3.75 });
                dataSeries2.DataPoints.Add(new DataPoint { AxisXLabel = "定期一年", YValue = 3.00 });
                dataSeries2.DataPoints.Add(new DataPoint { AxisXLabel = "定期半年", YValue = 2.80 });
                dataSeries2.DataPoints.Add(new DataPoint { AxisXLabel = "定期三月", YValue = 2.60 });
                dataSeries2.DataPoints.Add(new DataPoint { AxisXLabel = "活期", YValue = 0.35 });
    
                CompareChart.Series.Add(dataSeries);
                CompareChart.Series.Add(dataSeries2);
    
                return CompareChart;
            }
    
            /// <summary>
            ///折线统计图
            /// </summary>
            public static Chart InitTenThousandRateChart(string fundName, List<FundDay> fundDayList)
            {
                Chart TrendChart = new Chart();
                TrendChart.Theme = "Theme3";
                Visifire.Charts.Title t = new Visifire.Charts.Title();
                t.Text = string.Format("{0}单日万元收益走势", fundName);
                TrendChart.Titles.Add(t);
    
                DataSeries AccrualSeries = new DataSeries { RenderAs = RenderAs.Line };
                AccrualSeries.LabelEnabled = true;
                AccrualSeries.LegendText = "每万元单日收益";
    
                int listCount = fundDayList.Count;
                int dayIndex = (listCount >= 7) ? 6 : listCount;//限定最多只能取七天的数据做走势图,并且保证时间轴(X轴)的最右端是最新日期
    
                if (listCount > 0)
                {
                    while (dayIndex >= 0)
                    {
                        FundDay fundDay = fundDayList[dayIndex];
    
                        string date = fundDay.Date.Substring(fundDay.Date.IndexOf("-") + 1);
    
                        double tenThousandAccrual = 0;
                        Double.TryParse(fundDay.TenThousandRate, out tenThousandAccrual);
                        AccrualSeries.DataPoints.Add(new DataPoint { AxisXLabel = date, YValue = tenThousandAccrual });
    
                        dayIndex--;
                    }
                }
    
                Axis a = new Axis();
                a.StartFromZero = false;
                TrendChart.AxesY.Add(a);
    
                TrendChart.Series.Add(AccrualSeries);
    
                return TrendChart;
            }
  • 相关阅读:
    html5 存储方式
    分割字符串得到分数,然后求和取整
    通过javascript的日期对象来得到当前的日期
    基础选择器
    制作3D旋转视频展示区
    自由缩放属性resize
    团队项目第四天
    团队项目第三天
    团队项目第二天
    团队项目第一天
  • 原文地址:https://www.cnblogs.com/AlvinLiang/p/4987566.html
Copyright © 2011-2022 走看看