DunDas对应不同坐标系显示双y轴

其实很简单(但对于CirCular Chart无效),就一句话: webchart.Series["bb"].YAxisType = AxisType.Secondary;

 /// <summary>
    /// 双y轴实现
    /// </summary>
    /// <returns></returns>
    public string GetImgFile()
    {
        ArrayList arrdate = new ArrayList();
        ArrayList arrvalue = new ArrayList();
        ArrayList arrvalues = new ArrayList();
        SetChartStyle("aaa", true);
        webchart.Series.Add("aa");
        webchart.Series.Add("bb");
        webchart.ChartAreas.Add("aa");
        webchart.ImageType = ChartImageType.Png;
        webchart.Width = 650;
        webchart.Height = 450;
        Random r = new Random(10);
        DateTime dt = System.DateTime.Now;
        for (int i = 0; i < 10; i++)
        {
            dt = dt.AddDays(1);
            arrdate.Add(dt.ToShortDateString());
            arrvalue.Add(i);
            arrvalues.Add(i + r.Next());
        }
        webchart.Series["aa"].Type = SeriesChartType.Column;
        webchart.ChartAreas["aa"].AxisX.MajorGrid.LineColor = Color.Silver;
        webchart.ChartAreas["aa"].AxisX.LineColor = Color.Silver;
        webchart.ChartAreas["aa"].AxisX.MajorTickMark.Size = 1;
        webchart.ChartAreas["aa"].AxisX.MajorGrid.Enabled = true;
        webchart.ChartAreas["aa"].AxisY.Enabled = AxisEnabled.True;
        webchart.ChartAreas["aa"].AxisY.MajorGrid.LineColor = Color.Silver;
        webchart.ChartAreas["aa"].AxisY.MajorGrid.Enabled = true;
        webchart.ChartAreas["aa"].AxisY.LineColor = Color.Silver;
        webchart.ChartAreas["aa"].AxisY.Title = "aa";
        webchart.ChartAreas["aa"].AxisY.MajorTickMark.Size = 0;
        webchart.ChartAreas["aa"].AxisY2.Enabled = AxisEnabled.True;
        webchart.ChartAreas["aa"].AxisY2.MajorGrid.LineColor = Color.Silver;
        webchart.ChartAreas["aa"].AxisY2.MajorGrid.Enabled = true;
        webchart.ChartAreas["aa"].AxisY2.LineColor = Color.Silver;
        webchart.ChartAreas["aa"].AxisY2.Title = "bb";
        webchart.ChartAreas["aa"].AxisY2.MajorTickMark.Size = 0;
        webchart.Series["aa"].Points.DataBindXY(arrdate, arrvalue);
        webchart.Series["bb"].Points.DataBindXY(arrdate, arrvalues);
        //主要是这句来显示第二个坐标轴
        webchart.Series["bb"].YAxisType = AxisType.Secondary;
        webchart.Series["aa"].Type = SeriesChartType.Column;
        webchart.Series["bb"].Type = SeriesChartType.Line;
        string ImageName = DateTime.Now.ToString("yyMMddHHmmssfffff") + ".png";

        webchart.Save(HttpContext.Current.Request.PhysicalApplicationPath + ImageName, ChartImageFormat.Png);
        return ImageName;
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值