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. php 邮件发送代码-php邮件群发

    php 邮件发送如何进行的呢? php邮件发送是通过smtp协议进行的. 下面是一个php邮件发送的类的一个函数. 文件下载 function sendmail($to, $from, $subjec ...

  2. itext poi 学习之旅 (2)创建excel

    Computer.java package com.qiang.poi; public class Computer { private int id; private String name; pr ...

  3. maven, sesame, openrdf, eclipse 的初始学习

    初始学习如下: http://rdf4j.org/sesame/tutorials/getting-started.docbook?view

  4. CREATE DATABASE

    CREATE DATABASE IF NOT EXISTS `focusdata` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;USE `fo ...

  5. ATM Solved Problem code: HS08TES

    # ATM import sys withdraw, balance = map(float, sys.stdin.readline().strip().split()) # strip()用法去除结 ...

  6. JUnit使用Eclipse建立Test Suite - 就是爱Java

    当JUnit有多个或所有的Test Case要执行,此时就需要Test Suite来管理众多的Test Case,利用Eclipse的整合开发环境,可以针对多个不相关的Test Case或Test S ...

  7. 通过select选项动态异步加载内容

    通过监听select的change事件来异步加载数据. 1:效果图: 选择Good: 选择 Bad: 2:index.html <!DOCTYPE html> <html lang= ...

  8. Leetcode_ Best Time to Buy and Sell Stock II

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  9. 使用CPU的AVX指令

    arch:AVX 很抱歉GCC还不行……有……倒是 但是不是这么写的 我忘记了……官网上有 http://www.oschina.net/news/66980/kreogist-0-9

  10. MySQL常用聚合函数

    官方文档:Aggregate (GROUP BY) Functions Name Description AVG() Return the average value of the argument ...