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;
                title.FontSize = 16;
                chart.Titles.Add(title);
                // X 坐标轴
                Axis axisX = new Axis();
                AxisLabels xal = new AxisLabels
                {
                    FontSize = 14//设置文字大小
                };
                axisX.AxisLabels = xal;
                chart.AxesX.Add(axisX);
                // Y 坐标轴
                Axis axisY = new Axis();
                AxisLabels yal = new AxisLabels
                {
                    FontSize = 14//设置文字大小
                };
                axisY.AxisLabels = yal;
                //Y轴数据单位
                string sYUint = li.YUint;
                axisY.Title = sYUint;
                axisY.TitleFontSize = 15;
                chart.AxesY.Add(axisY);
                if (li.ChartType == "Column") //柱状图
                {
                    switch (li.YAXISs.Count())
                    {
                        case 1:
                            chart.DataPointWidth = 4;//设置柱子宽度
                            break;
                        case 2:
                            chart.DataPointWidth = 2.5;
                            break;
                        case 3:
                            chart.DataPointWidth = 1.8;
                            break;
                    }
                }
                title.MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown);

////设置图标字体大小
                //Legend legend = new Legend();
                //legend.FontSize = 13;
                //chart.Legends.Add(legend);1

//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"; // 设置ColorSet 的 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 双坐标轴
                    string IsTwoY = "";
                    IsTwoY = oYAXIS.TWOY;
                    if (IsTwoY == "true")
                    {
                        Axis axisYT = new Axis() { AxisType = AxisTypes.Secondary };
                        AxisLabels yalT = new AxisLabels
                        {
                            //Enabled = true, //设置是否显示坐标轴上的文本,默认值为true
                            //Angle = 45,//设置文本显示的角度,取值为 –90 至 90
                            FontSize = 14//设置文字大小
                        };
                        axisYT.AxisLabels = yalT;
                        axisYT.AxisMinimum = 0;
                        axisYT.AxisMaximum = 100;
                        //Y轴数据单位
                        string sYUintT = li.YUintT;
                        axisYT.Title = sYUintT;
                        axisYT.TitleFontSize = 15;
                        chart.AxesY.Add(axisYT);
                        dataSeries.AxisYType = AxisTypes.Secondary;
                    }
                    #endregion
                    else
                    {
                        dataSeries.AxisYType = AxisTypes.Primary;
                    }
                    #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(Color.FromArgb(0xff, 0xff, 0x45, 0x00))); //#FFFF4500 orangeRed
                            break;
                        case "Yellow":
                            cs.Brushes.Add(new SolidColorBrush(Color.FromArgb(0xff, 0xda, 0xa5, 0x20)));//FFDAA520 Goldenrod
                            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(Color.FromArgb(0xff, 0x41, 0x69, 0xe1))); //FF4169E1 RoyalBlue
                            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;
                            //dataSeries.LabelFontSize = 14;//设置图标字体大小
                            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 || dataSeries.RenderAs == RenderAs.Line) && 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);
            }
        }

visifire 图表双坐标轴 silverlight的更多相关文章

  1. silverlight 双坐标轴

    public void CreateLine(Grid oGrid, string sTitle, string sTableName, bool ifGetSig, string sYUint, s ...

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

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

  3. Origin双坐标轴图表

    1.空白处右键Add New Colume添加新列 2.全选各个列绘制图表 3.添加新的Y轴图层Graph—New Layer—Right-Y 4.右键左上角图层2 –Layer Contents 绑 ...

  4. WPF Visifire 图表控件

    Visifire WPF 图表控件 破解 可能用WPF生成过图表的开发人员都知道,WPF虽然本身的绘图能力强大,但如果每种图表都自己去实现一次的话可能工作量就大了, 尤其是在开发时间比较紧的情况下.这 ...

  5. MATLAB绘图,绘双坐标轴,绘一图二轴等

    clc; clear all; close all; % %% 画极坐标系 % x = 0:.01 * pi:0.5 * pi; % y = cos(x) + sqrt(-1) * sin(x); % ...

  6. Visifire图表

    引用DLL: WPFToolkit WPFVisifire.Charts.dll WPFVisifire.Gauges.dll 1.柱状图 代码: public void BindChart1() { ...

  7. visifire 图表属性样式设置说明,字体,阴影设置

  8. 修改Echarts 图表的坐标轴的文本的排列位置

    option.xAxis.axisLabel['interval'] = 0 option.xAxis.axisLabel['formatter'] = function(value,index){ ...

  9. matlab双坐标轴设定

    clc; clear all; close all; x1 = 0:.1:40; y1 = 4 * cos(x1)./(x1 + 2); x2 = 1:.2:20; y2 = x2.^2 ./ x2. ...

随机推荐

  1. Objective-C基础之──多态

    Objective-C语言是面向对象的高级编程语言,因此,它具有面向对象编程所具有的一些特性,即:封装性.继承性和多态性. 今天介绍一下Objective-C中的多态性. 一.什么是多态 多态:不同对 ...

  2. jQuery自学笔记(四):jQuery DOM节点操作

    获得和设置内容:text( ).html( ) 以及 val( ) text( ) - 设置或返回所选元素的文本内容 html( ) - 设置或返回所选元素的内容(包括 HTML 标记) val( ) ...

  3. 关于 HRESULT:0x80070

    异常来自 HRESULT:0x80070057 (E_INVALIDARG) 网上看的普遍办法是: 解决方法 是 删除 C:/WINDOWS/Microsoft.NET/Framework/v2.0. ...

  4. js学习笔记——数组方法

    join() 把数组中所有元素转化为字符串并连接起来,并返回该字符串, var arr=[1,2,3]; var str=arr.join("#"); //str="1# ...

  5. 在PHP中开启CURL扩展,使其支持curl()函数

    在用PHP开发CMS的时候,要用到PHP的curl函数,默认状态下,这个函数需要开启CURL扩展,有主机使用权的,可通过PHP.ini文件开启本扩展,方法如下: 1.打开php.ini,定位到;ext ...

  6. Hadoop学习历程(四、运行一个真正的MapReduce程序)

    上次的程序只是操作文件系统,本次运行一个真正的MapReduce程序. 运行的是官方提供的例子程序wordcount,这个例子类似其他程序的hello world. 1. 首先确认启动的正常:运行 s ...

  7. C语言基础学习学习前的准备-2

    注释让程序更明了 注释帮助我们阅读代码,对代码的运行不会造成任何影响.C语言主要有两种注释方法,一种是使用//进行单行注释,注释内容放在//之后: //需要注释的内容 当你的注释内容不止一行时,可以使 ...

  8. [LinqPad妙用]-在Net MVC中反射调用LinqPad中的Dump函数

    LinqPad有个非常强大的Dump函数.这篇讲解一下如何将Dump函数应用在.Net MVC Web开发中. 先看效果: 一.用.Net Reflector反编译LinqPad.exe,找出Dump ...

  9. MyGeneration 默认设置中没有数据库驱动

    这 个问题的出现基本上是因为MyGeneration 1.3需要的是 .Net framework 4.0,如果系统安装了 .Net 2.0的版本,安装程序执行的 regasm.exe为2.0版本下的 ...

  10. Java并发编程--线程封闭(Ad-hoc封闭 栈封闭 ThreadLocal)

    线程封闭实现好的并发是一件困难的事情,所以很多时候我们都想躲避并发.避免并发最简单的方法就是线程封闭.什么是线程封闭呢?就是把对象封装到一个线程里,只有这一个线程能看到此对象.那么这个对象就算不是线程 ...