菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
82
0

silverlight 双坐标轴

原创
05/13 14:22
阅读数 530748

标签:style   size   c   ext   t   width   string   sp   art   color   get   

  public void CreateLine(Grid oGrid, string sTitle, string sTableName, bool ifGetSig, string sYUint, string sYUint2, string sYTitle1, string sYTitle2, string sYTitle3, string[] sXLabel, double[] dYValue1, double[] dYValue2, double[] dYValue3)
        {

            Chart chart = new MyChart();

            chart.Width = 500;//宽
            chart.Height = 300;//高
            //chart.Margin = new Thickness(0, 20, 40, 0);
            chart.Margin = new Thickness(0, 0, 10, 20); //位置
            chart.ScrollingEnabled = false;
            chart.Name = sTableName;
            chart.DataPointWidth = 2.5;
            if (ifGetSig)
            {
                chart.MouseLeftButtonUp += new MouseButtonEventHandler(chart_MouseLeftButtonUp);
            }

            Title title = new Title();
            title.Text = sTitle; //图表标题
            title.FontSize = 15;//图表标题字体大小
            chart.Titles.Add(title);

            // X 坐标轴
            Axis axisX = new Axis();
            AxisLabels xal = new AxisLabels //X 坐标轴样式
            {
                //Enabled = true, //设置是否显示坐标轴上的文本,默认值为true
                //Angle = 45,//设置文本显示的角度,取值为 –90 至 90
                FontSize = 13//设置文字大小
            };
            axisX.AxisLabels = xal;
            chart.AxesX.Add(axisX);
            // Y 坐标轴
            Axis axisY = new Axis();
            AxisLabels yal = new AxisLabels  // Y 坐标轴样式
            {
                //Enabled = true, //设置是否显示坐标轴上的文本,默认值为true
                //Angle = 45,//设置文本显示的角度,取值为 –90 至 90
                FontSize = 13//设置文字大小
            };
            axisY.AxisLabels = yal;
            axisY.Title = sYUint; //Y坐标轴单位
            axisY.TitleFontSize = 14;//Y坐标轴单位字体大小
            chart.AxesY.Add(axisY);

            title.MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown);

            // Y 坐标轴 双坐标轴
            Axis axisYT = new Axis() { AxisType = AxisTypes.Secondary };// 双坐标轴
            AxisLabels yalT = new AxisLabels
            {
                //Enabled = true, //设置是否显示坐标轴上的文本,默认值为true
                //Angle = 45,//设置文本显示的角度,取值为 –90 至 90
                FontSize = 13//设置文字大小
            };
            axisYT.AxisLabels = yalT;
            axisYT.Title = sYUint2; //双坐标轴单位
            axisYT.TitleFontSize = 14;//双坐标轴单位字体大小
            chart.AxesY.Add(axisYT);

            ////设置图标字体大小
            //Legend legend = new Legend();
            //legend.FontSize = 13;
            //chart.Legends.Add(legend);
            DataSeries dataSeries1 = new DataSeries();
            dataSeries1.LegendText = sYTitle1;
            dataSeries1.RenderAs = RenderAs.Line;
            dataSeries1.AxisYType = AxisTypes.Primary;

            DataSeries dataSeries2 = new DataSeries();
            dataSeries2.LegendText = sYTitle2;
            dataSeries2.RenderAs = RenderAs.Line;
            dataSeries2.AxisYType = AxisTypes.Primary;

            DataSeries dataSeries3 = new DataSeries();
            dataSeries3.LegendText = sYTitle3;
            dataSeries3.RenderAs = RenderAs.Line;
            dataSeries3.AxisYType = AxisTypes.Secondary;

            DataPoint dp1;
            DataPoint dp2;
            DataPoint dp3;

            for (int i = 0; i < sXLabel.Length; i++)
            {
                dp1 = new DataPoint();
                dp2 = new DataPoint();
                dp3 = new DataPoint();

                dp1.AxisXLabel = sXLabel[i];
                dp1.YValue = dYValue1[i];
                dataSeries1.DataPoints.Add(dp1);

                dp2.AxisXLabel = sXLabel[i];
                dp2.YValue = dYValue2[i];
                dataSeries2.DataPoints.Add(dp2);

                dp3.AxisXLabel = sXLabel[i];
                dp3.YValue = dYValue3[i];
                dataSeries3.DataPoints.Add(dp3);
            }
            chart.Series.Add(dataSeries1);
            chart.Series.Add(dataSeries2);
            chart.Series.Add(dataSeries3);
            oGrid.Children.Add(chart);

        }

silverlight 双坐标轴,码迷,mamicode.com

silverlight 双坐标轴

发表评论

0/200
82 点赞
0 评论
收藏
为你推荐 换一批