示例#1
0
        static void AddExcelChart(ExcelApplicationWrapper excelApp, EventImpactTrace eventTrace,
string name,
Dictionary<Timestamp, double> dictData,
Dictionary<Timestamp, double> dictForecast,
Dictionary<Timestamp, double> dictSigmas
)
        {
            List<Timestamp> timeline = new List<Timestamp>(dictData.Keys);
            timeline.Sort();

            Dictionary<string, Dictionary<int, string>> dictLabels =
                        new Dictionary<string, Dictionary<int, string>>(1);
            Dictionary<int, string> eventLabels = new Dictionary<int, string>();

            //Label standalone (observation) spikes
            if ((eventTrace != null) && (eventTrace.ObservationShocks != null))
            {
                foreach (int ilk in eventTrace.ObservationShocks.Keys)
                {
                    eventLabels.Add(ilk, "M");
                }
            }

            //Label inflection points in broad, deviant patterns
            foreach (int ilk in eventTrace.StateShocks.Keys)
            {
                if ((ilk >= 0) && (!eventLabels.ContainsKey(ilk)))
                {
                    eventLabels.Add(ilk, "S");
                }

            }
            dictLabels.Add(name, eventLabels);
            Dictionary<string, Dictionary<int, string>> dictNews =
                        new Dictionary<string, Dictionary<int, string>>(1);

            Dictionary<string, Dictionary<Timestamp, double>> tmp =
                new Dictionary<string, Dictionary<Timestamp, double>>(2);
            tmp.Add(name, dictData);

            Dictionary<string, Dictionary<Timestamp, double>> tmpSigmas = null;
            if (dictForecast != null)
            {
                string strForecastName = name + " (forecast)";
                tmp.Add(strForecastName, dictForecast);
                foreach (Timestamp fts in dictForecast.Keys)
                {
                    if (!timeline.Contains(fts))
                    {
                        timeline.Add(fts);
                    }
                }
                timeline.Sort();
                tmpSigmas = new Dictionary<string, Dictionary<Timestamp, double>>(1);
                tmpSigmas.Add(strForecastName, dictSigmas);
            }

            try
            {
                excelApp.CreateChart(name + ", trends", timeline,
                    tmp,
                    tmpSigmas,
                    0, int.MaxValue, dictLabels, dictNews);

            }
            catch (COMException comExIgnore)
            {
            }
        }