silverlight visifire 图表辅助类

2016-06-08 11:24:56来源:CSDN作者:luozhuang人点击

    在实际项目开展中,往往会牵扯到需要绘制图表的情况。而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 = new string[] { "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[,] valuearray, 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[,] valuearray, string[] legendarray, 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 = new string[] { "ff96f112", "ff048cd8", "ffc506c5", "ffbe3346", "fff2b508", "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[,] valuearray, string[] legendarray, string titletext, string xaxistitle, 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[,] valuearray,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[,] valuearray, 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, 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[,] valuearray,string titletext, string xaxistitle, 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[,] valuearray, string titletext)        {            Chart column_chart = new Chart();            try            {                //Theme="Theme1" ShadowEnabled="True" CornerRadius="7,7,0,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[,] valuearray, 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 = new string[] { "ff96f112", "ff048cd8", "ffc506c5", "ffbe3346", "fff2b508", "ffe7f503" };        #region 委托及事件        public delegate void SelectControlEventHandler(string labeltext);        public event SelectControlEventHandler SelectControlEvent;        #endregion        public Chart Create_stick1(string[,] valuearray, string titletext, string xaxistitle, 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, 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, val2, 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[,] valuearray, string[] legendarray, string titletext, string xaxistitle, 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);        }    }}


最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台