silverlight 双坐标轴

2020-11-15 01:36

阅读:804

标签: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             {
                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 双坐标轴,搜素材,soscw.com

silverlight 双坐标轴

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

原文地址:http://www.cnblogs.com/xuxin-1989/p/3695675.html


评论


亲,登录后才可以留言!