silverlight   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了silverlight visifire 图表辅助类大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

    在实际项目开展中,往往会牵扯到需要绘制图表的情况。而Visifire是一个比较美观大方的第三方图表控件    本文是对Visifire控件简单封装,方便大家调用。   下面都是我个人自己用的封装类,大家根据自己实际情况进行修改。    using System; using System.Net; using System.Windows; using System.Windows.Con

    在实际项目开展中,往往会牵扯到需要绘制图表的情况。而Visifire是一个比较美观大方的第三方图表控件

   本文是对Visifire控件简单封装,方便大家调用

  下面都是我个人自己用的封装类,大家根据自己实际情况进行修改

  

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;


namespace ExtendChart
{
    public class PointDrawing
    {
        public String Themetext = "Theme1";
        public String ColorSets = "Visifire1";
        public int Marksize = 20;
        public int titlesize = 16;
        public int Labelsize = 8;
        public int axisLabelsize = 8;
        public String[] Colorarray = @R_801_3320@[] { "ff96f112","ff048cd8","fff2b508","ffc506c5","ffbe3346","ffe7f503" };
        public bool IsLight = false;

        #region 委托及事件
        public delegate void SELEctControlEventHandler(String labeltext);
        public event SELEctControlEventHandler SELEctControlEvent;
        #endregion

        public PointDrawing()
        {
        }

        public Chart creatPointChar(String[] textarray,String[] valuearray,String[] legendarray,String titletext)
        {
            Chart point_chart = new Chart();
            try
            {
                //point_chart.View3D = true;
                point_chart.Theme = Themetext;
                if (IsLight)
                    point_chart.LighTingEnabled = true;
                else
                    point_chart.LighTingEnabled = false;

                point_chart.ColorSet = ColorSets;
                point_chart.ScrollingEnabled = false;
                point_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                point_chart.borderBrush = new SolidColorBrush(Colors.Transparent);
                point_chart.Animatedupdate = true;

                //标题
                title title = new title();
                title.FontSize = titlesize;
                title.Text = titletext;
                point_chart.titles.Add(titlE);

   



                Axis x_axis = new Axis();
                AxisLabels x_axislabel = new AxisLabels();
                x_axislabel.FontSize = AxisLabelsize;
                x_axis.AxisLabels = x_axislabel;

                ChartGrid chartgrid1 = new ChartGrid();
                //chartgrid1.Enabled = true;
                //chartgrid1.Interval = 1;
                //chartgrid1.LineThickness = 1;
                //chartgrid1.Linestyle = Linestyles.solid;
                //x_axis.Grids.Add(chartgrid1);

                point_chart.AxesX.Add(x_axis);


                Axis y_axis = new Axis();
                AxisLabels y_axislabel = new AxisLabels();
                y_axislabel.FontSize = AxisLabelsize;
                y_axis.AxisLabels = y_axislabel;

                //y_axis.Padding = new Thickness(4);

                chartgrid1 = new ChartGrid();
                chartgrid1.LineThickness = 0.5;
                chartgrid1.LineColor = new SolidColorBrush(Colors.black);
                chartgrid1.Linestyle = Linestyles.solid;
                y_axis.Grids.Add(chartgrid1);
                //y_axis.AxisLabels = axislabel1;
                point_chart.AxesY.Add(y_axis);

   
                PlotArea plotarea = new PlotArea();
                plotarea.BACkground = new SolidColorBrush(Colors.Transparent);
                point_chart.PlotArea = plotarea;


                int loopcount = legendarray.Length;
                int row = valuearray.Length / loopcount;

                //第一批
                DataSeries dataSeries;
                DataPoint dataPoint;

                for (int ii = 0; ii < loopcount; ii++)
                {
                    dataSeries = new DataSeries();
                    //dataSeries.Opacity = 0.8;
                    
                    dataSeries.RenderAs = RenderAs.Point;
                    dataSeries.BACkground = new SolidColorBrush(Colors.Transparent); 
                    dataSeries.LabelEnabled = true;
                    dataSeries.LabelFontSize = Labelsize;
                    dataSeries.LabelFontColor = new SolidColorBrush(Colors.WhitE);
                    dataSeries.LabelFontWeight = FontWeights.Thin;
                    dataSeries.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(ColorarraY[(ii) % 6]));

                    dataSeries.LegendText = legendarray[ii];
                    switch ((ii+1) % 6)
                    {
                        case 1:
                            dataSeries.MarkerType = MarkerTypes.Circle;
                            break;
                        case 2:
                            dataSeries.MarkerType = MarkerTypes.Triangle;
                            break;
                        case 3:
                            dataSeries.MarkerType = MarkerTypes.Square;
                            break;
                        case 4:
                            dataSeries.MarkerType = MarkerTypes.Diamond;
                            break;
                        case 5:
                            dataSeries.MarkerType = MarkerTypes.Line;
                            break;
                        case 6:
                            dataSeries.MarkerType = MarkerTypes.Cross;
                            break;

                    }
                   //dataSeries.ShadowEnabled = true;
                    dataSeries.MarkerSize = Marksize;
                    int step = loopcount - ii;

                    for (int j = 1; j <= row; j++)
                    {
                        dataPoint = new DataPoint();
                        
                        dataPoint.AxisXLabel = textarraY[j * loopcount - step];
                        dataPoint.XValue = (j * loopcount) - step;
                        dataPoint.YValue = double.Parse(valuearraY[(j * loopcount) - step]);
                        dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);

                        dataSeries.DataPoints.Add(dataPoint);
                    }
                    point_chart.Series.Add(dataSeries);
                }



            }
            catch (Exception eX)
            {
                throw ex;
            }

            return point_chart;
        }

        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; if (dataPoint == null) { return; }
  
            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.XValue + "|" + dataPoint.YValue + "|" + dataPoint.AxisXLabel);
        }
    }
}


using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;


namespace ExtendChart
{
    public class PyramidDrawing
    {
        public String Themetext = "Theme1";
        public bool Is3D = true;
        public bool IsLight = false;
        public String Labelfontcolor = "ff000000";
        public int Labelfontsize = 10;
        public String[] Datapointcolors = null;
        public String titleText = null;
        public int titlesize = 12;
        public String titlefontcolor = "ff000000";



        #region 委托及事件
        public delegate void SELEctControlEventHandler(String labeltext);
        public event SELEctControlEventHandler SELEctControlEvent;
        #endregion

        public PyramidDrawing()
        {
        }

        public Chart creatpyramid(String[,] valuearray)
        {
            Chart pyramid_chart = new Chart();

            try
            {
                if (Is3D)
                    pyramid_chart.View3D = true;
                pyramid_chart.Theme = Themetext;
                //pyramid_chart.CornerRadius = new CornerRadius(10);
                pyramid_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                pyramid_chart.borderBrush = new SolidColorBrush(Colors.Transparent);
                //pyramid_chart.BACkground = null;

                if (IsLight)
                    pyramid_chart.LighTingEnabled = true;
                else
                    pyramid_chart.LighTingEnabled = false;

                if (titleText != null)
                {
                    //标题
                    title title = new title();
                    title.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(titlefontcolor));
                    title.FontSize = titlesize;
                    title.FontWeight = FontWeights.bold;
                    title.Text = titleText;
                    pyramid_chart.titles.Add(titlE);
                }
                ////标题
                //title title = new title();
                //title.Text = "选择范围区域";
                //pyramid_chart.titles.Add(titlE);
                ////图例
                //Legend lg = new Legend();
                //lg.VerticalAlignment = VerticalAlignment.bottom;
                //lg.HorizontalAlignment = HorizontalAlignment.Center;
                //lg.FontSize = 10;
                //pyramid_chart.Legends.Add(lg);
                PlotArea plotarea = new PlotArea();
                plotarea.CornerRadius = new CornerRadius(10);
                plotarea.BACkground = new SolidColorBrush(Colors.Transparent);
                pyramid_chart.PlotArea = plotarea;

                DataSeries dataSeries;
                DataPoint dataPoint;
                //Y1_1,X
                dataSeries = new DataSeries();
                dataSeries.ToolTipText = "#AxisXLabel";
                dataSeries.RenderAs = RenderAs.Pyramid;
                
                //dataSeries.Opacity = 0.7;
                //dataSeries.bevel = true;
                for (int j = 0; j < valuearray.Length / 2; j++)
                {
                    dataPoint = new DataPoint();

                    if (Datapointcolors != null)
                    dataPoint.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Datapointcolors[j]));

                    //dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);
                    dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);
                    dataPoint.LabelFontSize = Labelfontsize;
                    dataPoint.AxisXLabel = valuearraY[j,0];
                    dataPoint.LabelFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Labelfontcolor));

                    dataPoint.YValue = double.Parse(valuearraY[j,1]);
                    dataSeries.DataPoints.Add(dataPoint);
                }
                pyramid_chart.Series.Add(dataSeries);
            }
            catch (Exception eX)
            {
                throw ex;
            }

            return pyramid_chart;
        }

        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; if (dataPoint == null) { return; }
            if (dataPoint.Exploded == truE)
                dataPoint.Exploded = false;
            else
            //if (dataPoint.Exploded != truE)
                dataPoint.Exploded = true;

            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.YValue + "|" + dataPoint.AxisXLabel);

        }
    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;

namespace ExtendChart
{
    public class SequenceDrawing
    {
        public String Themetext = "Theme1";
        public String ColorSets = "Visifire1";
        public int Marksize = 26;
        public int Labelsize = 14;
        public int axisLabelsize = 4;
        public bool IsLight = false;


        public SequenceDrawing()
        {

        }

        public Chart creatSequence(String[,] valuearray,int min,int maX)
        {
            Chart sequence_chart = new Chart();

            try
            {
                sequence_chart.View3D = true;

                //sequence_chart.ZoomingEnabled = true;
                //sequence_chart.ZoomOutText = "ZoomOut";
                if (IsLight)
                    sequence_chart.LighTingEnabled = true;
                else
                    sequence_chart.LighTingEnabled = false;

                sequence_chart.Theme = Themetext;
                sequence_chart.ColorSet = ColorSets;
                sequence_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                sequence_chart.borderBrush = new SolidColorBrush(Colors.Transparent);
      //             <vc:Axis.AxisLabels>
      //  <vc:AxisLabels Angle="-90" Rows="1"/>
      //</vc:Axis.AxisLabels>
                
                Axis x_axis = new Axis();
                AxisLabels x_axislabel = new AxisLabels();
                x_axislabel.FontSize = AxisLabelsize;
                x_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString("CC4C9DC7"));
                x_axislabel.Rows = 1;
               // x_axislabel.Angle = 90;
                x_axis.AxisLabels = x_axislabel;

                ChartGrid chartgridx = new ChartGrid();
                chartgridx.Enabled = true;
                chartgridx.Interval = 1;
                chartgridx.LineThickness = 0.5;
                chartgridx.Linestyle = Linestyles.solid;
                x_axis.Grids.Add(chartgridX);

                sequence_chart.AxesX.Add(x_axis);
                

                Axis y_axis = new Axis();
                y_axis.Axismaximum = max;
                y_axis.AxisMinimum = min;
                y_axis.Interval = 1;
                y_axis.IntervalType = IntervalTypes.Auto;
                //y_axis.FontSize = 0.1;
                y_axis.ValueFormatString = " ";
                y_axis.Ticks.Add(new Visifire.Charts.Ticks { Enabled = false });
                AxisLabels y_axislabel = new AxisLabels();
                y_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString("FFC4EDF6"));
                y_axis.AxisLabels = y_axislabel;
                CustomAxisLabels cals = new CustomAxisLabels();
                cals.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString("FFC4EDF6"));
                cals.FontSize = 12;
                //CustomAxisLabel cal ;
                //int showval = max;
                //for (int ii = min; ii <= max; ii++)
                //{
                 
                //       cal = new CustomAxisLabel { From = min.ToString(),To = min.ToString(),Text = showval.ToString() };
                //        cals.Labels.Add(cal);
                 
                //        showval--;
                //}

                CustomAxisLabel cal = new CustomAxisLabel { From = "1",To = "1",Text = "三十三" };
                cals.Labels.Add(cal);

                cal = new CustomAxisLabel { From = "3",To = "3",Text = "三十一" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "4",To = "4",Text = "三十" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "5",To = "5",Text = "二十九" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "6",To = "6",Text = "二十八" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "7",To = "7",Text = "二十七" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "8",To = "8",Text = "二十六" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "9",To = "9",Text = "二十五" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "10",To = "10",Text = "二十四" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "11",To = "11",Text = "二十三" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "12",To = "12",Text = "二十二" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "13",To = "13",Text = "二十一" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "14",To = "14",Text = "二十" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "15",To = "15",Text = "十九" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "16",To = "16",Text = "十八" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "17",To = "17",Text = "十七" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "18",To = "18",Text = "十六" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "19",To = "19",Text = "十五" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "20",To = "20",Text = "十四" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "21",To = "21",Text = "十三" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "22",To = "22",Text = "十二" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "23",To = "23",Text = "十一" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "24",To = "24",Text = "十" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "25",To = "25",Text = "九" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "26",To = "26",Text = "八" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "27",To = "27",Text = "七" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "28",To = "28",Text = "六" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "29",To = "29",Text = "五" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "30",To = "30",Text = "四" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "31",To = "31",Text = "三" };
                cals.Labels.Add(cal);
                //cal = new CustomAxisLabel { From = "32",To = "32",Text = "二" };
                //cals.Labels.Add(cal);
                cal = new CustomAxisLabel { From = "33",To = "33",Text = "一" };
                cals.Labels.Add(cal);
               
               
                y_axis.CustomAxisLabels.Add(cals);


                //AxisLabels y_axislabel = new AxisLabels();
                //y_axislabel.FontSize = AxisLabelsize;
                //y_axis.AxisLabels = y_axislabel;

                //y_axis.Padding = new Thickness(1);

                ChartGrid chartgridy = new ChartGrid();

                chartgridy.Enabled = true;
                chartgridy.Interval = 1;
                chartgridy.LineThickness = 0.5;
                //chartgridy.LineColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString);
                chartgridy.Linestyle = Linestyles.solid;
                y_axis.Grids.Add(chartgridy);
                //y_axis.AxisLabels = axislabel1;
                sequence_chart.AxesY.Add(y_axis);


                //画领先线
                TrendLine trendline1 = new TrendLine(); 
                trendline1.Value = 31; 
                trendline1.orientation = Orientation.Horizontal; 
                trendline1.AxisType = AxisTypes.PriMary; 

                trendline1.LineThickness = 8; 
                trendline1.Linestyle = Linestyles.solid;
                trendline1.LabelText = "领先线";
                trendline1.LabelFontWeight = FontWeights.bold;
                trendline1.LabelFontSize = 14;
                trendline1.LineColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString("fffde101"));   
                sequence_chart.TrendLines.Add(trendline1);


                //画平均线
                TrendLine trendline2 = new TrendLine();
                trendline2.Value = 16;
                trendline2.orientation = Orientation.Horizontal;
                trendline2.AxisType = AxisTypes.PriMary;
                trendline2.LineThickness = 8;
                trendline2.Linestyle = Linestyles.solid;
                trendline2.LabelText = "平均线";
                trendline2.LabelFontWeight = FontWeights.bold;
                trendline2.LabelFontSize = 14;
                trendline2.LineColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString("ffc31b00"));     
                sequence_chart.TrendLines.Add(trendline2);
                //TrendLine trendline1 = new TrendLine();
                //trendline1.Value = double.Parse("19");
                //trendline1.orientation = Orientation.Horizontal;
                //trendline1.LineThickness = 2;
                //trendline1.LineColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString("#fffde101"));

                PlotArea plotarea = new PlotArea();
                plotarea.ShadowEnabled = true;
                plotarea.BACkground = new SolidColorBrush(Colors.Transparent);
                sequence_chart.PlotArea = plotarea;

                DataSeries dataSeries;
                DataPoint dataPoint;
                int row = valuearray.Length / 3;


                dataSeries = new DataSeries();

                dataSeries.RenderAs = RenderAs.Point;
                dataSeries.BACkground = new SolidColorBrush(Colors.Transparent);
               // ToolTipText="#AxisXLabel"
                dataSeries.ToolTipText = "#AxisXLabel";
                dataSeries.LabelEnabled = true;
                dataSeries.LabelFontSize = Labelsize;
                dataSeries.LabelFontColor = new SolidColorBrush(Colors.WhitE);
                ////dataSeries.LabelAngle = -90;
                dataSeries.LabelFontWeight = FontWeights.Thin;
                //dataSeries.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(ColorarraY[(ii) % 6]));

               // dataSeries.LegendText = legendarray[ii];
                //dataSeries.MarkerType = MarkerTypes.Square;
                dataSeries.MarkerSize = Marksize;
                //int step = loopcount - ii;

                for (int j = 0; j < row; j++)
                {
                    dataPoint = new DataPoint();

                    dataPoint.AxisXLabel = "第" + valuearraY[j,2] + "名\r\n" + valuearraY[j,0];
           
                    dataPoint.XValue = j + 1;
                    
                    dataPoint.LabelText = "\r\n   第" + valuearraY[j,2] + "名" + "\r\n" + valuearraY[j,0] ;
                    dataPoint.YValue = double.Parse(valuearraY[j,1]);
                    //dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);

                    dataSeries.DataPoints.Add(dataPoint);
                }
                sequence_chart.Series.Add(dataSeries);
           
 
            }
            catch (Exception eX)
            {
                throw ex;
            }
            return sequence_chart;
        }
    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;

namespace ExtendChart
{
    public class DoughnutDrawing
    {
        public String Themetext = "Theme1";
        public int axisLabelsize = 16;
        public int titlesize = 14;
        public String ColorSets = "Visifire1";
        public int Lablefontsize = 14;
        public String Labelfontcolor = "ff000000";
        public String[] Datapointcolors = null;
        public String titlefontcolor = "ff000000";


        #region 委托及事件
        public delegate void SELEctControlEventHandler(String labeltext);
        public event SELEctControlEventHandler SELEctControlEvent;
        #endregion

        public DoughnutDrawing()
        {

        }

        public Chart creatDoughnut(String[,String titletext)
        {
            Chart doughnut_chart = new Chart();
            try
            {
                doughnut_chart.View3D = true;
                doughnut_chart.Theme = Themetext;
                doughnut_chart.ColorSet = ColorSets;

                doughnut_chart.bevel = false;
                doughnut_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                doughnut_chart.borderBrush = new SolidColorBrush(Colors.Transparent);
                doughnut_chart.LighTingEnabled = false;
                doughnut_chart.borderThickness = new Thickness(0.5);

                //标题
                if (titletext != null)
                {
                    title title = new title();
                    title.FontSize = titlesize;
                    title.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(titlefontcolor));
                   // title.FontStyle = new FontStyle

                    title.FontWeight = FontWeights.bold;
                    title.Text = titletext;
                    doughnut_chart.titles.Add(titlE);
                }

                int row = valuearray.Length / 2;

                //第一批
                DataSeries dataSeries;
                DataPoint dataPoint;

                dataSeries = new DataSeries();

                dataSeries.RenderAs = RenderAs.Doughnut;
                //dataSeries.Opacity = 0.7;

                //dataSeries.ShowInLegend = true;
                //dataSeries.bevel = true;

                dataSeries.LabelText = "#AxisXLabel,#YValue";
                dataSeries.ShadowEnabled = true;
                for (int j = 0; j < row; j++)
                {
                    dataPoint = new DataPoint();

                    if (Datapointcolors != null)
                        dataPoint.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Datapointcolors[j]));

                    dataPoint.AxisXLabel = valuearraY[j,0];
                    dataPoint.LabelFontSize = Lablefontsize;
                    dataPoint.LabelFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Labelfontcolor));
                    dataPoint.LabelLineThickness = 1.5;
                    dataPoint.YValue = double.Parse(valuearraY[j,1]);
                    dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);

                    dataSeries.DataPoints.Add(dataPoint);
                }
                doughnut_chart.Series.Add(dataSeries);



            }
            catch (Exception eX)
            {
                throw ex;
            }

            return doughnut_chart;
        }

        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; if (dataPoint == null) { return; }
            if (dataPoint.Exploded == truE)
                dataPoint.Exploded = false;
            else
                dataPoint.Exploded = true;
            //messageBox.Show(dataPoint.AxisXLabel);
            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.AxisXLabel);
        }
    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;

namespace ExtendChart
{
    public class SplineCharts
    {
        public String Themetext = "Theme1";
        public int Labelsize = 12;
        public int axisLabelsize = 14;
        public int titlesize = 16;
        public String DefaultColorsets = "Visifire1";
        public int axistitlesize = 14;
        public String AxisLabelfontcolor = "ff000000";
        public String titlefontcolor = "ff000000";
        public String Axistitlefontcolor = "ff000000";
        public int axistitlefontsize = 14;
        public String Labelfontcolor = "ff000000";

        public double CornerRadius = 7;
        public int Padding = 6;
        public bool Is3D = true;
        public bool IsLight = false;
        

        #region 委托及事件
        public delegate void SELEctControlEventHandler(String labeltext);
        public event SELEctControlEventHandler SELEctControlEvent;
        #endregion

        public Chart creatsplinechart(String[,String titletext,String xaxistitle,String yaxistitlE)
        {
            Chart splinechart = new Chart();

            try
            {
                //Theme="Theme1" CornerRadius="7" Animatedupdate="true"
                if (Is3D)
                    splinechart.View3D = true;

                splinechart.Theme = Themetext;
                splinechart.ColorSet = DefaultColorsets;

                splinechart.BACkground = new SolidColorBrush(Colors.Transparent);
                splinechart.borderBrush = new SolidColorBrush(Colors.Transparent);
                splinechart.Padding = new Thickness(Padding);
                splinechart.borderThickness = new Thickness(0);
                splinechart.InDicatorEnabled = true;
                splinechart.CornerRadius = new CornerRadius(CornerRadius);
               

                if (titletext != null)
                {
                    //标题
                    title title = new title();
                    title.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(titlefontcolor));

                    title.FontSize = titlesize;
                    title.Text = titletext;
                    splinechart.titles.Add(titlE);
                }


    //              <vc:Chart.AxesX> 
    //  <vc:Axis Padding="4"/> 
    //</vc:Chart.AxesX> 

                Axis x_axis = new Axis();
                if (xaxistitle != null)
                {
                    x_axis.title = xaxistitle;
                    x_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                    x_axis.titleFontSize = Axistitlefontsize;
                }

                //AxisLabels x_axislabel = new AxisLabels();
                //x_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                //x_axislabel.FontSize = AxisLabelsize;
                //x_axis.AxisLabels = x_axislabel;
                //splinechart.AxesX.Add(x_axis);

                //Axis y_axis = new Axis();
                //if (yaxistitle != null)
                //{
                //    y_axis.title = yaxistitle;
                //    y_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                //    y_axis.titleFontSize = Axistitlefontsize;
                //}

                //AxisLabels y_axislabel = new AxisLabels();
                //y_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                //y_axislabel.FontSize = AxisLabelsize;
                //y_axis.AxisLabels = y_axislabel;
                //splinechart.AxesY.Add(y_axis);

    //            <vc:Chart.PlotArea> 
    //    <vc:PlotArea ShadowEnabled="false"></vc:PlotArea> 
    //</vc:Chart.PlotArea> 
                PlotArea plotarea = new PlotArea();
                plotarea.BACkground = new SolidColorBrush(Colors.Transparent);
                plotarea.ShadowEnabled = false;
                splinechart.PlotArea = plotarea;

                DataSeries dataSeries;
                DataPoint dataPoint;

                int loopcount = legendarray.Length;
                int col = loopcount + 1;
                int row = valuearray.Length / col;

                for (int ii = 0; ii < loopcount; ii++)
                {
                    dataSeries = new DataSeries();

                    dataSeries.LegendText = legendarray[ii];
                    dataSeries.RenderAs = RenderAs.column;
                    dataSeries.LabelEnabled = true;
                    dataSeries.LabelFontSize = Labelsize;

                    double yval;
                    for (int j = 0; j < row; j++)
                    {
                        yval = double.Parse(valuearraY[j,ii + 1]);
                        dataPoint = new DataPoint();

                        dataPoint.AxisXLabel = valuearraY[j,0];

                        dataPoint.YValue = yval;
                        dataPoint.LabelFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Labelfontcolor));
                        dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);


                        dataSeries.DataPoints.Add(dataPoint);
                    }
                    splinechart.Series.Add(dataSeries);
                }


            }
            catch (Exception eX)
            {
                throw ex;
            }

            return splinechart;
        }

        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; if (dataPoint == null) { return; }

            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.AxisXLabel);
        }
    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Commons;
using Visifire.Gauges;


namespace ExtendChart
{
    public class GaugeDrawing
    {
        public int GaugeBACkgroundType = 0;

        public GaugeDrawing()
        {
        }

        public Gauge creatgauge(double val)
        {
            Gauge gauge1 = new Gauge();
          
            try
            {
                switch(GaugeBACkgroundTypE)
                {
                    case 1:
                     //仪表盘背景色设置
                     RadialGradientBrush rgb = new RadialGradientBrush { GradientOrigin = new Point(0.5,0.2),RadiusY = 0.5 };

                    rgb.GradientStops.Add(new GradientStop { Offset = 0,Color = ExtendChart.ExtendVaules.ReturnColorFromString("ff1495ba") });
                    rgb.GradientStops.Add(new GradientStop { Offset = 0.8,Color = ExtendChart.ExtendVaules.ReturnColorFromString("ff0a485a") });
                    rgb.GradientStops.Add(new GradientStop { Offset = 1,Color = ExtendChart.ExtendVaules.ReturnColorFromString("ff062e39") });
                    gauge1.BACkground = rgb;
                    break;
                 

                }
                NeedleInDicator ni = new NeedleInDicator();
                ni.Value = val;
                gauge1.InDicators.Add(ni);

                BarInDicator bi = new BarInDicator();
                bi.Value = val;
                gauge1.InDicators.Add(bi);

            }
            catch (Exception eX)
            {
                throw ex;
            }

            return gauge1;
        }
    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;

namespace ExtendChart
{
    public class MultiLineDrawing
    {
        public String Themetext = "Theme1";
        public int Labelsize = 12;
        public int axisLabelsize = 14;
        public int titlesize = 16;
        public String DefaultColorsets = "Visifire1";
        public int axistitlesize = 14;
        public String AxisLabelfontcolor = "ff000000";
        public String titlefontcolor = "ff000000";
        public String Axistitlefontcolor = "ff000000";
        public int axistitlefontsize = 14;
        public String Labelfontcolor = "ff000000";
        public String[] Colorarray = @R_801_3320@[] { "ff96f112","ffe7f503" };

        public bool Is3D = true;
        public bool IsLight = false;


        #region 委托及事件
        public delegate void SELEctControlEventHandler(String labeltext);
        public event SELEctControlEventHandler SELEctControlEvent;
        #endregion

        public MultiLineDrawing()
        {
        }


        public Chart creatline(String[,String yaxistitlE)
        {
            Chart line_chart = new Chart();

            try
            {
                //Theme="Theme1" BorderBrush="Gray" Padding="6" InDicatorEnabled="True"> 
                //if (Is3D)
                //    line_chart.View3D = true;
                line_chart.Theme = Themetext;
                line_chart.ColorSet = DefaultColorsets;

                line_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                line_chart.borderBrush = new SolidColorBrush(Colors.Transparent);
                line_chart.InDicatorEnabled = true;
                line_chart.borderThickness = new Thickness(0);

                if (titletext != null)
                {
                    //标题
                    title title = new title();
                    title.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(titlefontcolor));
                    
                    title.FontSize = titlesize;
                    title.Text = titletext;
                    title.FontWeight = FontWeights.ExtraBlack;
                    line_chart.titles.Add(titlE);
                }

                Axis x_axis = new Axis();
                if (xaxistitle != null)
                {
                    x_axis.title = xaxistitle;
                    x_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                    x_axis.titleFontSize = Axistitlefontsize;
                }

                AxisLabels x_axislabel = new AxisLabels();
                x_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                x_axislabel.FontSize = AxisLabelsize;
                x_axis.AxisLabels = x_axislabel;
                line_chart.AxesX.Add(x_axis);

                Axis y_axis = new Axis();
                if (yaxistitle != null)
                {
                    y_axis.title = yaxistitle;
                    y_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                    y_axis.titleFontSize = Axistitlefontsize;
                }

                AxisLabels y_axislabel = new AxisLabels();
                y_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                y_axislabel.FontSize = AxisLabelsize;
                y_axis.AxisLabels = y_axislabel;
                line_chart.AxesY.Add(y_axis);

                PlotArea plotarea = new PlotArea();
                plotarea.ShadowEnabled = true;
                plotarea.CornerRadius = new CornerRadius(10);
                plotarea.BACkground = new SolidColorBrush(Colors.Transparent);
                line_chart.PlotArea = plotarea;

                DataSeries dataSeries;
                DataPoint dataPoint;

                int loopcount = legendarray.Length;
                int col = loopcount + 1;
                int row = valuearray.Length / col;

                for (int ii = 0; ii < loopcount; ii++)
                {
                    dataSeries = new DataSeries();

                    dataSeries.LegendText = legendarray[ii];
                    //Legend legend1 = new Legend();
                    //legend1.
                    dataSeries.RenderAs = RenderAs.Line;
                    dataSeries.MarkerType = MarkerTypes.Circle;
                    //dataSeries.LabelEnabled = true;
                    dataSeries.SELEctionEnabled = true;
                    //dataSeries.ToolTipText = "#AxisXLabel的#LegendText: #YValue";
                    dataSeries.ToolTipText = "#LegendText: #YValue"; 
                    dataSeries.LineThickness = 3;
                    dataSeries.LabelFontSize = Labelsize;
                    dataSeries.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(ColorarraY[(ii) % 6]));

                    double yval;
                    for (int j = 0; j < row; j++)
                    {
                         yval = double.Parse(valuearraY[j,ii + 1]);
                        //yval = double.Parse(valuearraY[ii,j + 1]);
                        dataPoint = new DataPoint();

                        dataPoint.YValue = yval;

                        dataPoint.AxisXLabel = valuearraY[j,0];
                        //dataPoint.LabelText = valuearraY[j,ii];
                        dataPoint.LabelFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Labelfontcolor));
                        dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);

                            
                        
                        dataSeries.DataPoints.Add(dataPoint);
                    }
                    line_chart.Series.Add(dataSeries);
                }


            }
            catch (Exception eX)
            {
                throw ex;
            }


            return line_chart;

        }

        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; 
            if (dataPoint == null) { return; }

            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.AxisXLabel);
        }

    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;

namespace ExtendChart
{
    public class Stackeds
    {
        public String Themetext = "Theme1";
        public int Labelsize = 12;
        public int axisLabelsize = 14;
        public int titlesize = 16;
        public String DefaultColorsets = "Visifire1";
        public int axistitlesize = 14;
        public bool Is3D = true;
        public bool IsLight = false;
        public bool IsBar100 = true;
        public String[] Colorarray = null;

        #region 委托及事件
        public delegate void SELEctControlEventHandler(String labeltext);
        public event SELEctControlEventHandler SELEctControlEvent;
        #endregion

        public Stackeds()
        {
        }

        /*
        public Chart Create_stackchar(String[] legendarray,String[,String[] colorarray)
        {
            Chart stack_chart = new Chart();
           
            try
            {
                if (Is3D)
                stack_chart.View3D = true;
                stack_chart.Theme = Themetext;
                stack_chart.ColorSet = DefaultColorsets;

                stack_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                stack_chart.borderBrush = new SolidColorBrush(Colors.Transparent);

                stack_chart.borderThickness = new Thickness(0);

                if (IsLight)
                    stack_chart.LighTingEnabled = true;
                else
                    stack_chart.LighTingEnabled = false;

                Axis x_axis = new Axis();
                AxisLabels x_axislabel = new AxisLabels();
                x_axislabel.FontSize = AxisLabelsize;
                x_axis.AxisLabels = x_axislabel;
                stack_chart.AxesX.Add(x_axis);

                Axis y_axis = new Axis();
                AxisLabels y_axislabel = new AxisLabels();
                y_axislabel.FontSize = AxisLabelsize;
                y_axis.AxisLabels = y_axislabel;
                stack_chart.AxesY.Add(y_axis);



                DataSeries dataSeries;
                DataPoint dataPoint;

                int loopcount = legendarray.Length;
                int col = loopcount + 1;
                int row = valuearray.Length / col;

                for (int ii = 0; ii < loopcount; ii++)
                {
                    dataSeries = new DataSeries();

                    dataSeries.Opacity = 0.9;
                    dataSeries.LegendText = legendarray[ii];
                    dataSeries.RenderAs = RenderAs.StackedBar100;
                    dataSeries.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(colorarraY[ii]));
                    dataSeries.LabelEnabled = true;

                    dataSeries.LabelFontSize = Labelsize;


                    for (int j = 0; j < row; j++)
                    {
                        dataPoint = new DataPoint();
                        //if (ii == 0)
                            dataPoint.AxisXLabel = valuearraY[j,0];

                        dataPoint.YValue = double.Parse(valuearraY[j,ii + 1]);
                        dataPoint.LabelFontColor = new SolidColorBrush(Colors.black);
                        dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);

                        dataSeries.DataPoints.Add(dataPoint);
                    }
                    stack_chart.Series.Add(dataSeries);
                }
            }
            catch(Exception eX)
            {
                throw ex;
            }
            
            return stack_chart;
        }



        public Chart Create_stackchar(String[] legendarray,String[] colorarray,String titletext)
        {
            Chart stack_chart = new Chart();
            try
            {
                stack_chart.View3D = true;
                stack_chart.Theme = Themetext;
                stack_chart.ColorSet = DefaultColorsets;

                stack_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                stack_chart.borderBrush = new SolidColorBrush(Colors.Transparent);

                stack_chart.borderThickness = new Thickness(0);


                Axis x_axis = new Axis();
                AxisLabels x_axislabel = new AxisLabels();
                x_axislabel.FontSize = AxisLabelsize;
                x_axis.AxisLabels = x_axislabel;
                stack_chart.AxesX.Add(x_axis);

                Axis y_axis = new Axis();
                AxisLabels y_axislabel = new AxisLabels();
                y_axislabel.FontSize = AxisLabelsize;
                y_axis.AxisLabels = y_axislabel;
                stack_chart.AxesY.Add(y_axis);


                //标题
                title title = new title();
                title.FontSize = titlesize;
                title.Text = titletext;
                stack_chart.titles.Add(titlE);

                DataSeries dataSeries;
                DataPoint dataPoint;

                int loopcount = legendarray.Length;
                int col = loopcount + 1;
                int row = valuearray.Length / col;

                for (int ii = 0; ii < loopcount; ii++)
                {
                    dataSeries = new DataSeries();

                    dataSeries.Opacity = 0.9;
                    dataSeries.LegendText = legendarray[ii];
                    if (IsBar100)
                        dataSeries.RenderAs = RenderAs.StackedBar100;
                    else
                        dataSeries.RenderAs = RenderAs.StackedBar;

                    dataSeries.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(colorarraY[ii]));
                    dataSeries.LabelEnabled = true;

                    dataSeries.LabelFontSize = Labelsize;


                    for (int j = 0; j < row; j++)
                    {
                        dataPoint = new DataPoint();
                        if (ii == 0)
                            dataPoint.AxisXLabel = valuearraY[j,ii + 1]);
                        dataPoint.LabelFontColor = new SolidColorBrush(Colors.black);
                        dataPoint.MouSELEftButtonUp +=new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);

                        dataSeries.DataPoints.Add(dataPoint);
                    }
                    stack_chart.Series.Add(dataSeries);
                }
            }
            catch (Exception eX)
            {
                throw ex;
            }

            return stack_chart;
        }
        */


        public Chart Create_stackchar(String[] legendarray,String yaxistitlE)
        {
            Chart stack_chart = new Chart();
            try
            {
                if (Is3D)
                   stack_chart.View3D = true;
                stack_chart.Theme = Themetext;
                stack_chart.ColorSet = DefaultColorsets;

                stack_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                stack_chart.borderBrush = new SolidColorBrush(Colors.Transparent);

                stack_chart.borderThickness = new Thickness(0);

                if (IsLight)
                    stack_chart.LighTingEnabled = true;
                else
                    stack_chart.LighTingEnabled = false;




                //标题
                if (titletext != null)
                {
                    title title = new title();
                    title.FontSize = titlesize;
                    title.Text = titletext;
                    stack_chart.titles.Add(titlE);
                }


              

                if (xaxistitle != null)
                {
                    Axis x_axis = new Axis();
                    x_axis.title = xaxistitle;
                    x_axis.titleFontSize = 14;
                    AxisLabels x_axislabel = new AxisLabels();
                    x_axislabel.FontSize = AxisLabelsize;
                    x_axis.AxisLabels = x_axislabel;
                    stack_chart.AxesX.Add(x_axis);
                }

                if (yaxistitle != null)
                {
                    Axis y_axis = new Axis();
                    y_axis.title = yaxistitle;
                    y_axis.titleFontSize = 14;
                    AxisLabels y_axislabel = new AxisLabels();
                    y_axislabel.FontSize = AxisLabelsize;
                    y_axis.AxisLabels = y_axislabel;
                    stack_chart.AxesY.Add(y_axis);
                }

              

                DataSeries dataSeries;
                DataPoint dataPoint;

                int loopcount = legendarray.Length;
                int col = loopcount + 1;
                int row = valuearray.Length / col;

                for (int ii = 0; ii < loopcount; ii++)
                {
                    dataSeries = new DataSeries();
                    dataSeries.Opacity = 0.9;

                    dataSeries.LegendText = legendarray[ii];
                    if (IsBar100)
                        dataSeries.RenderAs = RenderAs.StackedBar100;
                    else
                        dataSeries.RenderAs = RenderAs.StackedBar;

                    if (Colorarray != null)
                        dataSeries.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(ColorarraY[ii]));

                    //dataSeries.LabelEnabled = true;
                    //dataSeries.LabelFontSize = Labelsize;

                    double val;
                    for (int j = 0; j < row; j++)
                    {
                        dataPoint = new DataPoint();
                        if (ii == 0)
                            dataPoint.AxisXLabel = valuearraY[j,0];

                        val = double.Parse(valuearraY[j,ii + 1]);
                        if (val > 0)
                        {
                            dataPoint.YValue = val;
                            dataPoint.LabelFontColor = new SolidColorBrush(Colors.black);

                            dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);

                            dataSeries.DataPoints.Add(dataPoint);
                        }
                    }
                    stack_chart.Series.Add(dataSeries);
                }
            }
            catch (Exception eX)
            {
                throw ex;
            }

            return stack_chart;
        }

        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; if (dataPoint == null) { return; }
            //if (dataPoint.Exploded == truE)
            //    dataPoint.Exploded = false;
            //else
            //    dataPoint.Exploded = true;
            //messageBox.Show(dataPoint.AxisXLabel);
            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.YValue + "|" + dataPoint.AxisXLabel);
        }
    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;

namespace ExtendChart
{
      
    public class D2columnDrawing
    {
        public String Themetext = "Theme1";
        public int Labelsize = 12;
        public int axisLabelsize = 14;
        public int titlesize = 16;
        public String DefaultColorsets = "Visifire1";
        public int axistitlesize = 14;
        public String AxisLabelfontcolor = "ff000000";
        public String titlefontcolor = "ff000000";
        public String Axistitlefontcolor = "ff000000";
        public int axistitlefontsize = 14;
        public String Labelfontcolor = "ff000000";

        public bool Is3D = true;
        public bool IsLight = false;


        #region 委托及事件
        public delegate void SELEctControlEventHandler(String labeltext);
        public event SELEctControlEventHandler SELEctControlEvent;
        #endregion

        public Chart creatbar(String[,String titletext)
        {
            Chart column_chart = new Chart();

            try
            {
                //Theme="Theme1" ShadowEnabled="True" CornerRadius="7,7,0" BorderThickness="0.5"          
  //  BorderBrush="Gray" Animatedupdate="true" > 

                if (Is3D)
                    column_chart.View3D = true;

                column_chart.Theme = Themetext;
                column_chart.ColorSet = DefaultColorsets;
                column_chart.ShadowEnabled = true;


                column_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                column_chart.borderBrush = new SolidColorBrush(Colors.Transparent);

                column_chart.borderThickness = new Thickness(0);

                if (titletext != null)
                {
                    //标题
                    title title = new title();
                    title.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(titlefontcolor));

                    title.FontSize = titlesize;
                    title.Text = titletext;
                    column_chart.titles.Add(titlE);
                }

                Axis x_axis = new Axis();
                x_axis.Interval = 2;
                //if (xaxistitle != null)
                //{
                //    x_axis.title = xaxistitle;
                //    x_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                //    x_axis.titleFontSize = Axistitlefontsize;
                //}

                AxisLabels x_axislabel = new AxisLabels();
                x_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                x_axislabel.FontSize = AxisLabelsize;
                x_axis.AxisLabels = x_axislabel;
                column_chart.AxesX.Add(x_axis);

                Axis y_axis = new Axis();
                //if (yaxistitle != null)
                //{
                //    y_axis.title = yaxistitle;
                //    y_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                //    y_axis.titleFontSize = Axistitlefontsize;
                //}

                AxisLabels y_axislabel = new AxisLabels();
                y_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                y_axislabel.FontSize = AxisLabelsize;
                y_axis.AxisLabels = y_axislabel;
                column_chart.AxesY.Add(y_axis);

                PlotArea plotarea = new PlotArea();
                plotarea.ShadowEnabled = true;
                plotarea.BACkground = new SolidColorBrush(Colors.Transparent);
                column_chart.PlotArea = plotarea;

                DataSeries dataSeries;
                DataPoint dataPoint;

                //int loopcount = legendarray.Length;
                //int col = loopcount + 1;
                int col = valuearray.Length / 2;

    //            <vc:Chart.Series> 
    //    <vc:DataSeries RenderAs="column" LabelEnabled="True"> 
    //        <vc:DataSeries.DataPoints> 
    //            <vc:DataPoint axisXLabel="USA" YValue="50"/> 
    //            <vc:DataPoint axisXLabel="China" YValue="35"/> 
    //            <vc:DataPoint axisXLabel="Russia" YValue="27"/> 
    //            <vc:DataPoint axisXLabel="Australia" YValue="17"/> 
    //            <vc:DataPoint axisXLabel="Japan" YValue="16"/> 
    //        </vc:DataSeries.DataPoints> 
    //    </vc:DataSeries> 
    //</vc:Chart.Series> 

                //for (int ii = 0; ii < col; ii++)
                //{
                dataSeries = new DataSeries();

                // dataSeries.LegendText = legendarray[ii];
                dataSeries.RenderAs = RenderAs.column;
                dataSeries.LabelEnabled = true;
               // dataSeries.LabelFontColor = 
                dataSeries.LabelFontSize = Labelsize;

                double yval;
                for (int j = 0; j < col; j++)
                {
                    yval = double.Parse(valuearraY[j,1]);
                    dataPoint = new DataPoint();

                    dataPoint.AxisXLabel = valuearraY[j,0];
                    
                    //dataPoint.AxisXLabel.
                    dataPoint.YValue = yval;
                    dataPoint.LabelFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Labelfontcolor));
                    dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);


                    dataSeries.DataPoints.Add(dataPoint);

                    DataPoint dataPoint1 = new DataPoint();
                    //dataPoint1.LabelFontColor = new SolidColorBrush(Colors.Transparent);
                    dataSeries.DataPoints.Add(dataPoint1);
                }
                column_chart.Series.Add(dataSeries);
                //}


            }
            catch (Exception eX)
            {
                throw ex;
            }


            return column_chart;

        }


        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; if (dataPoint == null) { return; }

            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.AxisXLabel);
        }
    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;

namespace ExtendChart
{
    public class PieDrawing
    {
        public String Themetext = "Theme1";
        public int axisLabelsize = 16;
        public int titlesize = 16;
        public String ColorSets = "Visifire1";
        public int Lablefontsize = 12;
        public String Labelfontcolor = "ff000000";
        public String[] Datapointcolors = null;
        public String titlecolor = "ff000000";


        #region 委托及事件
		public delegate void SELEctControlEventHandler(String labeltext);
		public event SELEctControlEventHandler SELEctControlEvent;
        #endregion
		
        public PieDrawing()
        {
        }

        public Chart creatPieChar(String[,String titletext)
        {
            Chart piechart = new Chart();
            try
            {
                piechart.View3D = true;
                piechart.Theme = Themetext;
                piechart.ColorSet = ColorSets;

                piechart.bevel = false;
                piechart.BACkground = new SolidColorBrush(Colors.Transparent);
                piechart.borderBrush = new SolidColorBrush(Colors.Transparent);
                piechart.LighTingEnabled = false;
                piechart.borderThickness = new Thickness(0.5);

                //标题
                if (titletext != null)
                {
                    title title = new title();
                    title.FontSize = titlesize;
                   
                    title.Text = titletext;
                    title.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(titlecolor));
                    title.FontWeight = FontWeights.ExtraBlack;
                    piechart.titles.Add(titlE);
                }

                int row = valuearray.Length / 2;

                //第一批
                DataSeries dataSeries;
                DataPoint dataPoint;

                dataSeries = new DataSeries();

                dataSeries.RenderAs = RenderAs.Pie;
             

                dataSeries.ShowInLegend = true;
                dataSeries.bevel = true;
                
                dataSeries.LabelText = "#AxisXLabel,#YValue";
                dataSeries.ShadowEnabled = true;
                for (int j = 0; j < row; j++)
                {
                    dataPoint = new DataPoint();

 
                    dataPoint.AxisXLabel = valuearraY[j,0];
                    if (Datapointcolors != null)
                        dataPoint.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Datapointcolors[j]));
                    dataPoint.LabelFontSize = Lablefontsize;
                    dataPoint.LabelFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Labelfontcolor));
                    dataPoint.LabelLineThickness = 1.5;
                    dataPoint.YValue = double.Parse(valuearraY[j,1]);
                    dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);
					
                    dataSeries.DataPoints.Add(dataPoint);
                }
                piechart.Series.Add(dataSeries);



            }
            catch (Exception eX)
            {
                throw ex;
            }

            return piechart;
        }

        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; if (dataPoint == null) { return; }
            if (dataPoint.Exploded == truE)
                dataPoint.Exploded = false;
            else
                dataPoint.Exploded = true;
            //messageBox.Show(dataPoint.AxisXLabel);
            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.AxisXLabel);
           // return;
        }

	 
    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;

namespace ExtendChart
{
    public class CandleStickDrawing
    {
        public String Themetext = "Theme1";
        public int Labelsize = 12;
        public int axisLabelsize = 14;
        public int titlesize = 16;
        public String AxisLabelfontcolor = "ff000000";
        public String DefaultColorsets = "Visifire1";
        public String Labelfontcolor = "ffffffff";
        public int axisLabeltitlesize = 14;
        public int axistitlesize = 14;
        public bool Is3D = false;
        public bool IsLight = false;
        public bool IsBar100 = true;
       // public String[] Colorarray = null;
        public int Labelfontsize = 12;
        public String Axistitlefontcolor = "ff000000";
        public int axistitlefontsize = 14;
        public String titleFontColor = "ff000000";
      //  public String[] Colorarray = @R_801_3320@[] { "ff96f112","ffe7f503" };


        #region 委托及事件
        public delegate void SELEctControlEventHandler(String labeltext);
        public event SELEctControlEventHandler SELEctControlEvent;
        #endregion



        public Chart Create_stick1(String[,String yaxistitle,bool colordirection)
        {
            Chart stick_chart = new Chart();
            try
            {

                if (Is3D)
                    stick_chart.View3D = true;
                stick_chart.Theme = Themetext;
                stick_chart.ColorSet = DefaultColorsets;
                //stick_chart.Padding = new Thickness(
                stick_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                stick_chart.borderBrush = new SolidColorBrush(Colors.Transparent);

                stick_chart.borderThickness = new Thickness(0);

                if (IsLight)
                    stick_chart.LighTingEnabled = true;
                else
                    stick_chart.LighTingEnabled = false;




                //标题
                if (titletext != null)
                {
                    title title = new title();
                    title.FontSize = titlesize;
                    title.FontWeight = FontWeights.ExtraBold;
                    title.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(titleFontColor));
                    title.Text = titletext;
                    stick_chart.titles.Add(titlE);
                }


                

                Axis x_axis = new Axis();
                x_axis.Interval = 3;
                if (xaxistitle != null)
                {
                    x_axis.title = xaxistitle;
                    x_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                    x_axis.titleFontSize = Axistitlefontsize;
                }

               // x_axis.Padding = new Thickness(10);

                AxisLabels x_axislabel = new AxisLabels();
                x_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                
                //x_axislabel.FontColor = new SolidColorBrush(Colors.Transparent);
                x_axislabel.FontSize = AxisLabelsize;
               
                x_axis.AxisLabels = x_axislabel;
                stick_chart.AxesX.Add(x_axis);

                Axis y_axis = new Axis();
                if (yaxistitle != null)
                {
                    y_axis.title = yaxistitle;
                    y_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                    y_axis.titleFontSize = Axistitlefontsize;
                }
                //y_axis.Padding = new Thickness(20);

                AxisLabels y_axislabel = new AxisLabels();
                y_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                y_axislabel.FontSize = AxisLabelsize;
                y_axis.AxisLabels = y_axislabel;
                stick_chart.AxesY.Add(y_axis);

  

                PlotArea plotarea = new PlotArea();
                plotarea.ShadowEnabled = true;
                plotarea.CornerRadius = new CornerRadius(5,5,0);
                plotarea.borderThickness = new Thickness(1);
                plotarea.BACkground = new SolidColorBrush(Colors.Transparent);
                stick_chart.PlotArea = plotarea;

   
                DataSeries dataSeries;
                DataPoint dataPoint;

 
                int col = valuearray.Length / 3;

                dataSeries = new DataSeries();

                dataSeries.RenderAs = RenderAs.CandleStick;
               // dataSeries.Color = new SolidColorBrush(ExtendVaules.ReturnColorFromString(ColorarraY[1]));
                //PriceDownColor="Tomato" PriceUpColor="Gray"> 
                if (colordirection)
                {
                    dataSeries.PriceDownColor = new SolidColorBrush(Colors.Red);
                    dataSeries.PriceUpColor = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    dataSeries.PriceDownColor = new SolidColorBrush(Colors.Green);
                    dataSeries.PriceUpColor = new SolidColorBrush(Colors.Red);

                }
                dataSeries.ToolTipText = "#AxisXLabel";  
                double val1,val2,min,max;

                for (int j = 0; j < col; j++)
                {
                       
                    dataPoint = new DataPoint();
                      
                    dataPoint.AxisXLabel = valuearraY[j,0];
                    val1 = double.Parse(valuearraY[j,1]);
                    val2 = double.Parse(valuearraY[j,2]);
                    if (val1 > val2)
                    {
                        max = val1;
                        min = val2;
                    }
                    else
                    {
                        max = val2;
                        min = val1;
                    }
                    //dataPoint.AxisXLabel.
                    dataPoint.YValues = new double[] { val1,max,min };
                    dataPoint.LabelText = valuearraY[j,0];
                    //dataPoint.LabelFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Labelfontcolor));
                    dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);

                    dataPoint.LabelFontColor = new SolidColorBrush(Colors.Transparent);
                   // dataPoint.StickColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Colorarray[0]));
                    dataSeries.DataPoints.Add(dataPoint);

                    DataPoint dataPoint1 = new DataPoint();
                    //dataPoint1.LabelFontColor = new SolidColorBrush(Colors.Transparent);
                    dataSeries.DataPoints.Add(dataPoint1);
                    DataPoint dataPoint2 = new DataPoint();
                    //dataPoint2.LabelFontColor = new SolidColorBrush(Colors.Transparent);
                    dataSeries.DataPoints.Add(dataPoint2);

                }
                stick_chart.Series.Add(dataSeries);
                //}
            }
            catch (Exception eX)
            {
                throw ex;
            }

            return stick_chart;
        }

        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; if (dataPoint == null) { return; }

            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.AxisXLabel);
        }
    }
}

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;


namespace ExtendChart
{
    public class BarDrawing
    {
        public String Themetext = "Theme1";
        public int Labelsize = 12;
        public int axisLabelsize = 14;
        public int titlesize = 16;
        public String DefaultColorsets = "Visifire1";
        public int axistitlesize = 14;
        public String AxisLabelfontcolor = "ff000000";
        public String titlefontcolor = "ff000000";
        public String Axistitlefontcolor = "ff000000";
        public int axistitlefontsize = 14;
        public String Labelfontcolor = "ff000000";

        public bool Is3D = true;
        public bool IsLight = false;


        #region 委托及事件
        public delegate void SELEctControlEventHandler(String labeltext);
        public event SELEctControlEventHandler SELEctControlEvent;
        #endregion

        public BarDrawing()
        {
        }


        public Chart creatbar(String[,String yaxistitlE)
        {
            Chart bar_chart = new Chart();

            try
            {
                if (Is3D)
                    bar_chart.View3D = true;
                bar_chart.Theme = Themetext;
                bar_chart.ColorSet = DefaultColorsets;

                bar_chart.BACkground = new SolidColorBrush(Colors.Transparent);
                bar_chart.borderBrush = new SolidColorBrush(Colors.Transparent);

                bar_chart.borderThickness = new Thickness(0);

                if (titletext != null)
                {
                    //标题
                    title title = new title();
                    title.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(titlefontcolor));
                    
                    title.FontSize = titlesize;
                    title.Text = titletext;
                    bar_chart.titles.Add(titlE);
                }

                Axis x_axis = new Axis();
                if (xaxistitle != null)
                {
                    x_axis.title = xaxistitle;
                    x_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                    x_axis.titleFontSize = Axistitlefontsize;
                }

                AxisLabels x_axislabel = new AxisLabels();
                x_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                x_axislabel.FontSize = AxisLabelsize;
                x_axis.AxisLabels = x_axislabel;
                bar_chart.AxesX.Add(x_axis);

                Axis y_axis = new Axis();
                if (yaxistitle != null)
                {
                    y_axis.title = yaxistitle;
                    y_axis.titleFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Axistitlefontcolor));
                    y_axis.titleFontSize = Axistitlefontsize;
                }

                AxisLabels y_axislabel = new AxisLabels();
                y_axislabel.FontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(AxisLabelfontcolor));
                y_axislabel.FontSize = AxisLabelsize;
                y_axis.AxisLabels = y_axislabel;
                bar_chart.AxesY.Add(y_axis);

                DataSeries dataSeries;
                DataPoint dataPoint;

                int loopcount = legendarray.Length;
                int col = loopcount + 1;
                int row = valuearray.Length / col;

                for (int ii = 0; ii < loopcount; ii++)
                {
                    dataSeries = new DataSeries();

                    //dataSeries.Opacity = 0.9;
                  
                    dataSeries.LegendText = legendarray[ii];
                    dataSeries.RenderAs = RenderAs.column;
                    //dataSeries.Color = new SolidColorBrush(Colors.Green);
                    dataSeries.LabelEnabled = true;
                    //dataSeries.LabelFontColor = new SolidColorBrush(Colors.Green);
                    dataSeries.LabelFontSize = Labelsize;

                    double yval;
                    for (int j = 0; j < row; j++)
                    {
                        yval = double.Parse(valuearraY[j,ii + 1]);
                        dataPoint = new DataPoint();

                        //if (yval != 0)
                        //{

                            dataPoint.AxisXLabel = valuearraY[j,0];
                            
                        //}
                            dataPoint.YValue = yval;
                            dataPoint.LabelFontColor = new SolidColorBrush(ExtendVaules.ReturnColorFromString(Labelfontcolor));
                            dataPoint.MouSELEftButtonUp += new MouseButtonEventHandler(dataPoint_MouSELEftButtonUp);

                            
                        //}
                        dataSeries.DataPoints.Add(dataPoint);
                    }
                    bar_chart.Series.Add(dataSeries);
                }


            }
            catch (Exception eX)
            {
                throw ex;
            }


            return bar_chart;

        }

        void dataPoint_MouSELEftButtonUp(object sender,MouseButtonEventArgs E)
        {
            DataPoint dataPoint = sender as DataPoint; if (dataPoint == null) { return; }

            if (this.SELEctControlEvent != null)
                this.SELEctControlEvent(dataPoint.AxisXLabel);
        }


    }
}

公共类:

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ExtendChart
{
    public class ExtendVaules
    {
        public static Color ReturnColorFromString(String color)
        {
            String alpha = color.SubString(0,2);
            String red = color.SubString(2,2);
            String green = color.SubString(4,2);
            String blue = color.SubString(6,2);
            byte alphaByte = Convert.ToByte(alpha,16);
            byte redByte = Convert.ToByte(red,16);
            byte greenByte = Convert.ToByte(green,16);
            byte blueByte = Convert.ToByte(blue,16);

            return Color.FromArgb(alphaByte,redByte,greenByte,blueBytE);
        }

    }
}

大佬总结

以上是大佬教程为你收集整理的silverlight visifire 图表辅助类全部内容,希望文章能够帮你解决silverlight visifire 图表辅助类所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。