silverlight 页面后台方法 .xaml.cs文件

public void CreateChart(Grid oGrid, ObservableCollection<ListItem> lBaseOilBar)
        {
            foreach (ListItem li in lBaseOilBar)
            {
                //图表大小,框线
                Chart chart = new MyCharts();
                chart.Width = 800;
                chart.Height = 600;
                chart.ScrollingEnabled = false;
                //图表标题
                Title title = new Title();
                string sTitle = li.Title;
                title.Text = sTitle;
                chart.Titles.Add(title);
                //Y轴数据单位
                Axis axisY = new Axis();
                string sYUint = li.YUint;
                axisY.Title = sYUint;
                chart.AxesY.Add(axisY);

title.MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown);
                //X轴数据
                string[] sXLabel = li.XAXIS.ToArray();
                string sTableName = "";
                #region 点击是否触发事件,钻取数据图表赋值一个物理表名
                bool ifGetSig = false;
                switch (li.ChartName)
                {
                    case "Stock":
                        sTableName = "StockSingleOildom";
                        ifGetSig = true;
                        break;
                    case "Drill_JC":
                        sTableName = "Drill_JCSingleOildom";
                        ifGetSig = true;
                        break;
                    case "EXTRACTIONOIL":
                        sTableName = "EXTRACTIONOILSingleOildom";
                        ifGetSig = true;
                        break;
                    case "Drill_MACHINE":
                        sTableName = "Drill_MACHINESingleOildom";
                        ifGetSig = true;
                        break;
                    case "PROVEDRILL":
                        sTableName = "PROVEDRILLSingleOildom";
                        ifGetSig = true;
                        break;

}
                #endregion
                #region 图表柱状个数,循环加载数据
                ColorSet cs = new ColorSet();
                cs.Id = "colorset1";
                //foreach (YAXIS oYAXIS in li.YAXISs)
                for (int j = 0; j < li.YAXISs.Count(); j++)
                {
                    YAXIS oYAXIS = (YAXIS)li.YAXISs[j];
                    string sYTitle = "";
                    sYTitle = oYAXIS.Name;
                    double[] dYValue = null;
                    dYValue = oYAXIS.YValue.ToArray();
                    DataSeries dataSeries = new DataSeries();
                    dataSeries.LegendText = sYTitle;
                    #region 设置柱状图的颜色 待开发
                    //ColorSet cs = new ColorSet();
                    //string strColor = oYAXIS.Color;
                    //////Colors oColors = new Colors();
                    //cs.Id = "colorset1"; // 设置ColorSet 的 Id 为 colorset1
                    //cs.Brushes.Add(new SolidColorBrush(Colors.Green));
                    //cs.Brushes.Add(new SolidColorBrush(Colors.Red));
                    //cs.Brushes.Add(new SolidColorBrush(Colors.Blue));
                    ////cs.Brushes.Add(new SolidColorBrush(Colors.Yellow));
                    ////cs.Brushes.Add(new SolidColorBrush(Colors.Orange));
                    //chart.ColorSets.Add(cs);
                    //chart.ColorSet = "colorset1";  // 设置 Chart 使用自定义的颜色集合 colorset1
                    string strColor = oYAXIS.Color;
                    switch (strColor)
                    {
                        case "Red":
                            cs.Brushes.Add(new SolidColorBrush(Colors.Red));
                            break;
                        case "Yellow":
                            cs.Brushes.Add(new SolidColorBrush(Colors.Yellow));
                            break;
                        case "Orange":
                            cs.Brushes.Add(new SolidColorBrush(Colors.Orange));
                            break;
                        case "Green":
                            cs.Brushes.Add(new SolidColorBrush(Colors.Green));
                            break;
                        case "Blue":
                            cs.Brushes.Add(new SolidColorBrush(Colors.Blue));
                            break;
                        default:
                            break;
                    }
                    #endregion
                    #region 图表类型(柱状,饼状……)
                    string sChartType = li.ChartType;
                    RenderAs oRenderAs = new RenderAs();
                    switch (sChartType)
                    {
                        case "Column":
                            oRenderAs = RenderAs.Column;
                            break;
                        case "Pie":
                            oRenderAs = RenderAs.Pie;
                            break;
                        case "Line":
                            oRenderAs = RenderAs.Line;
                            break;
                    }
                    dataSeries.RenderAs = oRenderAs;
                    #endregion
                    #region 构造数据
                    DataPoint dp;
                    if (sXLabel != null)
                    {
                        for (int i = 0; i < sXLabel.Length; i++)
                        {
                            dp = new DataPoint();
                            dp.AxisXLabel = sXLabel[i];
                            dp.YValue = dYValue[i];
                            if (ifGetSig)
                            {
                                dp.Tag = sTableName;
                                dp.MouseLeftButtonUp += new MouseButtonEventHandler(dataPoint_MouseLeftButtonUp);
                            }
                            //饼状图去除值为0的oildom
                            if (dataSeries.RenderAs == RenderAs.Pie & dp.YValue == 0)
                            {
                              
                            }
                            else
                            {
                                dataSeries.DataPoints.Add(dp);
                            }
                        }
                    }
                    #endregion
                    chart.Series.Add(dataSeries);
                }
                // 设置 Chart 使用自定义的颜色集合 colorset1
                if (cs.Brushes.Count > 0)
                {
                    chart.ColorSets.Clear();
                    chart.ColorSets.Add(cs);
                    chart.ColorSet = "colorset1";
                }
                #endregion
                oGrid.Children.Add(chart);
            }
        }

silverlight 生产图表(动态图表类型,Y轴数量) .xaml.cs文件的更多相关文章

  1. echart图表中y轴小数位数过长展示效果不佳

    业务中后端返回的精密数据,小数过长,导致所有数据差距不大,在图表中显示重合为一条直线 解决方法设置echart的min属性 min: "dataMin", 但是设置了以后又出现了问 ...

  2. matplotlib根据Y轴数量伸缩画图的py脚本

    #coding:utf-8import numpy as npimport matplotlib.pyplot as plt #X,Y轴数据y = [20,59,11,12,16,20,15,12,1 ...

  3. 让图表的Y轴 产生几个刻度距离

    动态设置max 查看官网 写入方法 获取到你数据最大值 然后+个100

  4. silverlight 生成图表 WCF 解析XML代码.svc.cs 文件

    silverlight 调用wcf 文件代码 private ListItem AnalyzeXML(string XMLCode, string Reportdate, string ChartNa ...

  5. echarts图表x,y轴的设置

    https://www.cnblogs.com/cjh-strive/p/11065005.html xAxis属性代表echarts图表的x轴设置代码如下 xAxis : [ { type : 'c ...

  6. Silverlight visifire Chart图表下载到PPT文件中

    一.Silverlight xaml.cs文件 1. //下载图表        private void btnDown_Click(object sender, RoutedEventArgs e ...

  7. 使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示

    原文:使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示 首先来看一看实现的效果: PS:原始的程序中更新曲线数据时添加了过渡的效果,具体可 ...

  8. 在线报表设计实战系列 – 制作多Y轴组合图表(8)

    葡萄城报表是一套强大的报表开发和系统搭建工具,既能与您开发的报表软件项目紧密集成,也可独立部署运行,支持多数据源,具有无编码.灵活.稳定等特性,可以帮您快速搭建专业的报表软件系统,实现各类报表的设计. ...

  9. Flash图表控件FusionCharts自定义图表y轴最大/最小值

    自定义图表y轴的最大值和最小值 用户可以使用FusionCharts图表中<chart>元素的yAxisMaxValue和yAxisMinValue属性设置图表限制. 示例: <ch ...

随机推荐

  1. QT-Demo-Colck-01

    QT += widgets QT += core HEADERS += \ mainwindow.h SOURCES += \ mainwindow.cpp \ main.cpp #ifndef MA ...

  2. Request 分别获取具有相同 name 属性表单元素值

    html 中是允许多个具有相同name属性的元素的,例如 <div> <input name="txtName" id="txtFirstName&qu ...

  3. 15--Box2D使用(一、创建物理世界)

    创建工程Box2DTest,去掉背景和精灵对象等.首先在HelloWorldScene.h头文件定义一个屏幕像素与物理世界长度转换宏,并引入box2D头文件 #define PIXEL_TO_METE ...

  4. My SQL 常用函数

    一.数学函数 数学函数主要用于处理数字,包括整型.浮点数等. ABS(x) 返回x的绝对值 SELECT ABS(-1) -- 返回1 CEIL(x),CEILING(x) 返回大于或等于x的最小整数 ...

  5. 有n人围成一圈,顺序排号。从第1个人开始报数(从1到3报数),凡报到3的人退出圈子,问最后留下的是原来的第几号的那位。

    #include <iostream> using namespace std; int main() { int i,j,n,m,k,*p,num[100];k=m=0;   cin&g ...

  6. Python学习笔记整理(五)Python中的列表.

    列表和字段,这两种类型几乎是Python所有脚本的主要工作组件.他们都可以在原处进行修改,可以按需求增加或缩短,而且包含任何种类的对象或者被嵌套. 一.列表 列表的主要属性: *任意对象的有序集合 从 ...

  7. 配置Android SDK 开发环境(转)

    1. 下载Eclipse 在前面我们配置好了JDK环境后,就可以开始配置Android的集成开发环境了,官方Google推荐的集成开发环境为Eclipse,所以我们就以Eclipse作为集成开发环境. ...

  8. wireshark抓一抓,看是不是另一个机器也企图DHCP

    早上的问题,昨晚四点睡,今早九点半起... 到公司处理此问题,不知道相关性大不大..

  9. qt鼠标事件总结(坐标,跟踪,点击判断)

    1.QMouseEvent中的坐标QMouseEvent中保存了两个坐标,一个是全局坐标,当然另外一个是局部坐标.全局坐标(globalPos())即是桌面屏幕坐标(screen coordinate ...

  10. 【转】GitHub问题之恢复本地被删除的文件

    原文网址:http://blog.csdn.net/iaiti/article/details/39557951 折腾了真久,GitHub commit之后,我手痒把本地的一个文件给删了,然后一直gi ...