示例#1
0
 public void addSerie(ChartDataSerie serie)
 {
     if (!SeriesNames.Keys.Contains(serie.Name)){
         Series.Add(serie);
         SeriesNames.Add(serie.Name, Series.IndexOf(serie));
     }
 }
示例#2
0
 public static ChartDataSerie getDataSerie(string serieName, SortedList<DateTime, double> data, int correctTime)
 {
     ChartDataSerie serie=new ChartDataSerie();
     serie.Name = serieName;
     foreach (KeyValuePair<DateTime,double> de in data) {
         serie.Points.Add(new ChartDataPoint(de.Key.AddMinutes(correctTime), de.Value));
     }
     return serie;
 }
示例#3
0
 public void refresh(ChartDataSerie serieData)
 {
     int count=0;
     switch (silverChartControl.XAxesType) {
         case XAxisTypeEnum.numeric:
             DataSeries<double,double> dataSeries=new DataSeries<double, double> { Title = Name };
             foreach (ChartDataPoint point in serieData.Points) {
                 dataSeries.Add(new DataPoint<double, double>(point.XValDouble, point.YVal));
                 count++;
             }
             if (Enabled) {
                 Serie.DataSeries = dataSeries;
             }
             SeriesData = dataSeries;
             break;
         case XAxisTypeEnum.datetime:
             DataSeries<DateTime,double> dataSeriesDate=new DataSeries<DateTime, double> { Title = Name };
             foreach (ChartDataPoint point in serieData.Points) {
                 dataSeriesDate.Add(new DataPoint<DateTime, double>(point.XVal, point.YVal));
                 count++;
             }
             if (Enabled) {
                 Serie.DataSeries = dataSeriesDate;
             }
             SeriesData = dataSeriesDate;
             break;
     }
     ShowToolTip=count<100;
 }
示例#4
0
        public void init(ChartDataSerie serieData, ChartSerieProperties serieProp)
        {
            SerieIndex = silverChartControl.ChartSeries.Count;
            TagName = serieData.Name;
            Name = serieProp.Title;
            SerieType = serieProp.SerieType;
            Brush tr=new SolidColorBrush(Colors.Transparent);

            Serie=null;
            Brush br=new SolidColorBrush(Color.FromArgb(255,0,0,0));
            if (serieProp.Color != null) {
                string[] colors=serieProp.Color.Split('-');
                byte r=Byte.Parse(colors[0]);
                byte g=Byte.Parse(colors[1]);
                byte b=Byte.Parse(colors[2]);
                br = new SolidColorBrush(Color.FromArgb(255, r, g, b));

            } else {
                //br = ChartActions.Actions().getNextColor();
            }
            switch (serieProp.SerieType){
                case ChartSerieType.line:
                    LineSeries lineSerie=new LineSeries();
                    lineSerie.LineStrokeThickness=serieProp.LineWidth+1;
                    lineSerie.LineStroke = br;
                    LineStroke = lineSerie.LineStroke;
                    lineSerie.HighlightingEnabled=true;
                    lineSerie.PointSize = 10;
                    lineSerie.PointFill = tr;
                    lineSerie.PointStroke = tr;
                    Serie = lineSerie;
                    break;
                case ChartSerieType.stepLine:
                    StaircaseSeries stairSerie=new StaircaseSeries();
                    stairSerie.LineStrokeThickness=serieProp.LineWidth+1;
                    stairSerie.LineStroke = br;
                    stairSerie.HighlightingEnabled = true;
                    LineStroke = stairSerie.LineStroke;
                    Serie = stairSerie;
                    stairSerie.PointSize = 10;
                    stairSerie.PointFill = tr;
                    stairSerie.PointStroke = tr;
                    break;
                case ChartSerieType.column:
                    ColumnSeries columnSerie=new ColumnSeries();
                    columnSerie.HighlightingEnabled = true;
                    columnSerie.PointFill = br;
                    columnSerie.PointStroke = br;
                    LineStroke = br;
                    Serie = columnSerie;
                    columnSerie.ToolTipEnabled = true;
                    break;
            }
            Serie.ToolTipTemplate = XamlReader.Load
                (TemplateStr.Replace("~serieName~", this.Name).
                    Replace("~xFormat~",silverChartControl.XAxesForamtString).
                    Replace("~yFormat~", "#,0.##")) as ControlTemplate;

            Serie.PropertyChanged += new PropertyChangedEventHandler(Serie_PropertyChanged);
            silverChartControl.CurrentChart.Series.Add(Serie);

            YAxisIndex = serieProp.YAxisIndex;

            silverChartControl.TrackBehaviour.PropertyChanged += new PropertyChangedEventHandler(TrackBehaviour_PropertyChanged);
            refresh(serieData);
            Enabled = serieProp.Enabled;
        }
示例#5
0
        public void AddChartData(ChartData data)
        {
            ChartDataSerie prognozNBSerie=new ChartDataSerie();
            foreach (KeyValuePair<DateTime,double> de in Prognoz) {
                prognozNBSerie.Points.Add(new ChartDataPoint(de.Key,de.Value));
            }

            ChartDataSerie prognozQSerie=new ChartDataSerie();
            foreach (KeyValuePair<DateTime,double> de in Rashods) {
                prognozQSerie.Points.Add(new ChartDataPoint(de.Key, de.Value));
            }

            ChartDataSerie prognozNaporSerie=new ChartDataSerie();
            foreach (KeyValuePair<DateTime,double> de in Napors) {
                prognozNaporSerie.Points.Add(new ChartDataPoint(de.Key, de.Value));
            }

            prognozNBSerie.Name = "NBPrognoz";
            prognozQSerie.Name = "QPrognoz";
            prognozNaporSerie.Name = "NaporPrognoz";

            data.addSerie(prognozNBSerie);
            data.addSerie(prognozQSerie);
            data.addSerie(prognozNaporSerie);
        }
示例#6
0
文件: Report.cs 项目: rj128x/VotGES
        public virtual void CreateChart()
        {
            Answer.Chart = new ChartAnswer();
            Answer.Chart.Properties = new ChartProperties();
            Answer.Chart.Data = new ChartData();

            ChartAxisProperties ax=new ChartAxisProperties();
            ax.Auto = true;
            ax.Index = 0;

            ChartAxisProperties ax1=new ChartAxisProperties();
            ax1.Auto = true;
            ax1.Index = 1;

            Answer.Chart.Properties.addAxis(ax);
            Answer.Chart.Properties.addAxis(ax1);

            ChartSerieType type=ChartSerieType.stepLine;
            if (Interval == IntervalReportEnum.quarter || Interval == IntervalReportEnum.month) {
                type = ChartSerieType.column;
            }

            Answer.Chart.Properties.XAxisType = XAxisTypeEnum.datetime;

            Answer.Chart.Properties.XValueFormatString = getDateFormat();

            Random r=new Random();
            int indexColor=0;
            foreach (RecordTypeBase recordType in RecordTypes.Values) {
                if (recordType.ToChart) {
                    ChartSerieProperties props=new ChartSerieProperties();
                    props.Title = recordType.Title;
                    props.TagName = recordType.ID;
                    props.LineWidth = 2;
                    props.Color = ChartColor.GetColorStr(indexColor++);
                    props.SerieType = type;
                    props.YAxisIndex = 0;
                    Answer.Chart.Properties.addSerie(props);

                    ChartDataSerie data=new ChartDataSerie();
                    data.Name = recordType.ID;
                    foreach (DateTime date in Dates) {
                        DateTime dt=GetCorrectedDateForChart(date);
                        data.Points.Add(new ChartDataPoint(dt, Data[date][recordType.ID]));
                    }
                    Answer.Chart.Data.addSerie(data);
                }
            }
        }
示例#7
0
        public virtual void writeFaktData(ChartData data)
        {
            ChartDataSerie nbFaktSerie=new ChartDataSerie();
            nbFaktSerie.Name = "NBFakt";
            foreach (KeyValuePair<DateTime,double> de in NBFakt){
                nbFaktSerie.Points.Add(new ChartDataPoint(de.Key, de.Value));
            }
            data.addSerie(nbFaktSerie);

            ChartDataSerie pFaktSerie=new ChartDataSerie();
            pFaktSerie.Name = "PFakt";
            foreach (KeyValuePair<DateTime,double> de in PFakt) {
                pFaktSerie.Points.Add(new ChartDataPoint(de.Key, de.Value));
            }
            data.addSerie(pFaktSerie);

            ChartDataSerie pbrSerie=new ChartDataSerie();
            pbrSerie.Name = "PBR";
            foreach (KeyValuePair<DateTime,double> de in PBR) {
                pbrSerie.Points.Add(new ChartDataPoint(de.Key, de.Value));
            }
            data.addSerie(pbrSerie);

            ChartDataSerie qFaktSerie=new ChartDataSerie();
            qFaktSerie.Name = "QFakt";
            foreach (KeyValuePair<DateTime,double> de in QFakt) {
                qFaktSerie.Points.Add(new ChartDataPoint(de.Key, de.Value));
            }
            data.addSerie(qFaktSerie);

            ChartDataSerie naporFaktSerie=new ChartDataSerie();
            naporFaktSerie.Name = "Napor";
            foreach (KeyValuePair<DateTime,double> de in NaporFakt) {
                naporFaktSerie.Points.Add(new ChartDataPoint(de.Key, de.Value));
            }
            data.addSerie(naporFaktSerie);

            ChartDataSerie vbFaktSerie=new ChartDataSerie();
            vbFaktSerie.Name = "VB";
            foreach (KeyValuePair<DateTime,double> de in VBFakt) {
                vbFaktSerie.Points.Add(new ChartDataPoint(de.Key, de.Value));
            }
            data.addSerie(vbFaktSerie);

            ChartDataSerie tFaktSerie=new ChartDataSerie();
            tFaktSerie.Name = "T";
            foreach (KeyValuePair<DateTime,double> de in TFakt) {
                tFaktSerie.Points.Add(new ChartDataPoint(de.Key, de.Value));
            }
            data.addSerie(tFaktSerie);
        }
示例#8
0
        public virtual void CreateChart(List<Report> reportAddList = null)
        {
            Answer.Chart = new ChartAnswer();
            Answer.Chart.Properties = new ChartProperties();
            Answer.Chart.Data = new ChartData();

            ChartAxisProperties ax=new ChartAxisProperties();
            ax.Auto = true;
            ax.Index = 0;

            ChartAxisProperties ax1=new ChartAxisProperties();
            ax1.Auto = true;
            ax1.Index = 1;

            Answer.Chart.Properties.addAxis(ax);
            Answer.Chart.Properties.addAxis(ax1);

            ChartSerieType type=ChartSerieType.stepLine;
            if (Interval == IntervalReportEnum.quarter || Interval == IntervalReportEnum.month || Interval == IntervalReportEnum.year) {
                type = ChartSerieType.column;
            }

            Answer.Chart.Properties.XAxisType = XAxisTypeEnum.datetime;

            Answer.Chart.Properties.XValueFormatString = getDateFormat(reportAddList != null);

            Random r=new Random();
            int indexColor=0;
            foreach (RecordTypeBase recordType in RecordTypes.Values) {
                if (recordType.ToChart) {
                    ChartSerieProperties props=new ChartSerieProperties();
                    string title=reportAddList != null ? recordType.Title + " " + AddReportTitle : recordType.Title;
                    props.Title = title;
                    props.TagName = recordType.ID;
                    props.LineWidth = 2;
                    props.Color = ChartColor.GetColorStr(indexColor++);
                    props.SerieType = type;
                    props.YAxisIndex = 0;
                    Answer.Chart.Properties.addSerie(props);

                    ChartDataSerie data=new ChartDataSerie();
                    data.Name = recordType.ID;
                    foreach (DateTime date in Dates) {
                        DateTime dt=GetCorrectedDateForChart(date);
                        data.Points.Add(new ChartDataPoint(dt, Data[date][recordType.ID]));
                    }
                    Answer.Chart.Data.addSerie(data);

                    if (reportAddList != null) {
                        foreach (Report reportAdd in reportAddList) {
                            int diffY = reportAdd.DateStart.Year - DateStart.Year;
                            int diffM = reportAdd.DateStart.Month - DateStart.Month;
                            int diffD = reportAdd.DateStart.Day - DateStart.Day;
                            props = new ChartSerieProperties();
                            props.Title = recordType.Title + " " + reportAdd.AddReportTitle;
                            props.TagName = recordType.ID + "_" + reportAdd.AddReportTitle;
                            props.LineWidth = 1;
                            props.Color = ChartColor.GetColorStr(indexColor++);
                            props.SerieType = type;
                            props.YAxisIndex = 0;
                            Answer.Chart.Properties.addSerie(props);

                            data = new ChartDataSerie();
                            data.Name = recordType.ID + "_" + reportAdd.AddReportTitle;
                            foreach (DateTime date in Dates) {
                                DateTime dt=GetCorrectedDateForChart(date);
                                try {
                                    DateTime newDate=date.AddYears(diffY).AddMonths(diffM).AddDays(diffD);
                                    data.Points.Add(new ChartDataPoint(dt, reportAdd.Data[newDate][recordType.ID]));
                                } catch { }
                            }
                            Answer.Chart.Data.addSerie(data);
                        }
                    }
                }
            }
        }