//
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // 4 data points to represent the cash flow for the Q1 - Q4
            double[] data = { 230, 140, 220, 330, 150 };

            // We want to plot a waterfall chart showing the 4 quarters as well as the total
            string[] labels = { "Product 1", "Product 2", "Product 3", "Product 4", "Product 5", "Total" };

            // The top side of the bars in a waterfall chart is the accumulated data. We use the
            // ChartDirector ArrayMath utility to accumulate the data. The "total" is handled by
            // inserting a zero point at the end before accumulation (after accumulation it will become
            // the total).
            double[] boxTop = new ArrayMath(data).insert2(0, 1).acc().result();

            // The botom side of the bars is just the top side of the previous bar. So we shifted the top
            // side data to obtain the bottom side data.
            double[] boxBottom = new ArrayMath(boxTop).shift(1, 0).result();

            // The last point (total) is different. Its bottom side is always 0.
            boxBottom[boxBottom.Length - 1] = 0;

            // Create a XYChart object of size 500 x 280 pixels. Set background color to light blue
            // (ccccff), with 1 pixel 3D border effect.
            XYChart c = new XYChart(500, 290, 0xccccff, 0x000000, 1);

            // Add a title to the chart using 13 points Arial Bold Itatic font, with white (ffffff) text
            // on a deep blue (0x80) background
            c.addTitle("Product Revenue - Year 2004", "Arial Bold Italic", 13, 0xffffff).setBackground(
                0x000080);

            // Set the plotarea at (55, 50) and of size 430 x 215 pixels. Use alternative white/grey
            // background.
            c.setPlotArea(55, 45, 430, 215, 0xffffff, 0xeeeeee);

            // Set the labels on the x axis using Arial Bold font
            c.xAxis().setLabels(labels).setFontStyle("Arial Bold");

            // Set the x-axis ticks and grid lines to be between the bars
            c.xAxis().setTickOffset(0.5);

            // Use Arial Bold as the y axis label font
            c.yAxis().setLabelStyle("Arial Bold");

            // Add a title to the y axis
            c.yAxis().setTitle("USD (in millions)");

            // Add a multi-color box-whisker layer to represent the waterfall bars
            BoxWhiskerLayer layer = c.addBoxWhiskerLayer2(boxTop, boxBottom);

            // Put data labels on the bars to show the cash flow using Arial Bold font
            layer.setDataLabelFormat("{={top}-{bottom}}M");
            layer.setDataLabelStyle("Arial Bold").setAlignment(Chart.Center);

            // Output the chart
            viewer.Image = c.makeWebImage(Chart.PNG);

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='{xLabel}: {={top}-{bottom}} millions'");
        }
Exemple #2
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // Sample data for the Box-Whisker chart. Represents the minimum, 1st quartile, medium, 3rd
            // quartile and maximum values of some quantities
            double[] Q0Data = { 40, 45, 35 };
            double[] Q1Data = { 55, 60, 50 };
            double[] Q2Data = { 62, 70, 60 };
            double[] Q3Data = { 70, 80, 65 };
            double[] Q4Data = { 80, 90, 75 };

            // The labels for the chart
            string[] labels = { "<*img=robot1.png*><*br*>Bipedal Type",
                                "<*img=robot2.png*><*br*>Wolf Type", "<*img=robot5.png*><*br*>Bird Type" };

            // Create a XYChart object of size 540 x 320 pixels
            XYChart c = new XYChart(540, 320);

            // swap the x and y axes to create a horizontal box-whisker chart
            c.swapXY();

            //Set default directory for loading images
            c.setSearchPath(Url.Content("~/Content"));

            // Set the plotarea at (75, 25) and of size 440 x 270 pixels. Enable both horizontal and
            // vertical grids by setting their colors to grey (0xc0c0c0)
            c.setPlotArea(75, 25, 440, 270).setGridColor(0xc0c0c0, 0xc0c0c0);

            // Add a title to the chart
            c.addTitle("           Robot Shooting Accuracy Scores");

            // Set the labels on the x axis and the font to Arial Bold
            c.xAxis().setLabels(labels).setFontStyle("Arial Bold");

            // Disable x axis ticks by setting the length to 0
            c.xAxis().setTickLength(0);

            // Set the font for the y axis labels to Arial Bold
            c.yAxis().setLabelStyle("Arial Bold");

            // Add a Box Whisker layer using light blue 0x9999ff as the fill color and blue (0xcc) as the
            // line color. Set the line width to 2 pixels
            c.addBoxWhiskerLayer2(Q3Data, Q1Data, Q4Data, Q0Data, Q2Data).setLineWidth(2);

            // Output the chart
            viewer.Image = c.makeWebImage(Chart.PNG);

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='{xLabel}: min/med/max = {min}/{med}/{max}\n Inter-quartile range: {bottom} to " +
                                                "{top}'");
        }
Exemple #3
0
        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The tasks for the gantt chart
            string[] labels = { "Market Research",  "Define Specifications", "Overall Archiecture",
                                "Project Planning", "Detail Design",         "Software Development","Test Plan",
                                "Testing and QA",   "User Documentation" };

            // The task index, start date, end date and color for each bar
            double[]   taskNo    = { 0, 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 8 };
            DateTime[] startDate = { new DateTime(2004,  8, 16), new DateTime(2004, 10,  4),
                                     new DateTime(2004,  8, 30), new DateTime(2004,  9, 13),new DateTime(2004,   9, 20),
                                     new DateTime(2004,  9, 27), new DateTime(2004, 10,  4),new DateTime(2004,  10,  4),
                                     new DateTime(2004, 10, 25), new DateTime(2004, 11,  1),new DateTime(2004,  10, 18),
                                     new DateTime(2004, 11, 8) };
            DateTime[] endDate = { new DateTime(2004,  8, 30), new DateTime(2004, 10, 18),
                                   new DateTime(2004,  9, 13), new DateTime(2004,  9, 27),new DateTime(2004,  10,  4),
                                   new DateTime(2004, 10, 11), new DateTime(2004, 11,  8),new DateTime(2004,  10, 18),
                                   new DateTime(2004, 11,  8), new DateTime(2004, 11, 22),new DateTime(2004,  11,  1),
                                   new DateTime(2004, 11, 22) };
            int[]      colors = { 0x00cc00, 0x00cc00, 0x00cc00, 0x0000cc, 0x0000cc, 0xcc0000, 0xcc0000,
                                  0x0000cc,      0xcc0000, 0xcc0000, 0x00cc00, 0xcc0000 };

            // Create a XYChart object of size 620 x 325 pixels. Set background color to light red
            // (0xffcccc), with 1 pixel 3D border effect.
            XYChart c = new XYChart(620, 325, 0xffcccc, 0x000000, 1);

            // Add a title to the chart using 15 points Times Bold Itatic font, with white (ffffff)
            // text on a dark red (800000) background
            c.addTitle("Mutli-Color Gantt Chart Demo", "Times New Roman Bold Italic", 15, 0xffffff
                       ).setBackground(0x800000);

            // Set the plotarea at (140, 55) and of size 460 x 200 pixels. Use alternative
            // white/grey background. Enable both horizontal and vertical grids by setting their
            // colors to grey (c0c0c0). Set vertical major grid (represents month boundaries) 2
            // pixels in width
            c.setPlotArea(140, 55, 460, 200, 0xffffff, 0xeeeeee, Chart.LineColor, 0xc0c0c0, 0xc0c0c0
                          ).setGridWidth(2, 1, 1, 1);

            // swap the x and y axes to create a horziontal box-whisker chart
            c.swapXY();

            // Set the y-axis scale to be date scale from Aug 16, 2004 to Nov 22, 2004, with ticks
            // every 7 days (1 week)
            c.yAxis().setDateScale(new DateTime(2004, 8, 16), new DateTime(2004, 11, 22), 86400 * 7)
            ;

            // Set multi-style axis label formatting. Month labels are in Arial Bold font in "mmm d"
            // format. Weekly labels just show the day of month and use minor tick (by using '-' as
            // first character of format string).
            c.yAxis().setMultiFormat(Chart.StartOfMonthFilter(), "<*font=Arial Bold*>{value|mmm d}",
                                     Chart.StartOfDayFilter(), "-{value|d}");

            // Set the y-axis to shown on the top (right + swapXY = top)
            c.setYAxisOnRight();

            // Set the labels on the x axis
            c.xAxis().setLabels(labels);

            // Reverse the x-axis scale so that it points downwards.
            c.xAxis().setReverse();

            // Set the horizontal ticks and grid lines to be between the bars
            c.xAxis().setTickOffset(0.5);

            // Add some symbols to the chart to represent milestones. The symbols are added using
            // scatter layers. We need to specify the task index, date, name, symbol shape, size and
            // color.
            c.addScatterLayer(new double[] { 1 }, Chart.CTime(new DateTime[] { new DateTime(2004, 9, 13
                                                                                            ) }), "Milestone 1", Chart.Cross2Shape(), 13, 0xffff00).setHTMLImageMap("{disable}");
            c.addScatterLayer(new double[] { 3 }, Chart.CTime(new DateTime[] { new DateTime(2004, 10, 4
                                                                                            ) }), "Milestone 2", Chart.StarShape(5), 15, 0xff00ff).setHTMLImageMap("{disable}");
            c.addScatterLayer(new double[] { 5 }, Chart.CTime(new DateTime[] { new DateTime(2004, 11, 8
                                                                                            ) }), "Milestone 3", Chart.TriangleSymbol, 13, 0xff9933).setHTMLImageMap("{disable}")
            ;

            // Add a multi-color box-whisker layer to represent the gantt bars
            BoxWhiskerLayer layer = c.addBoxWhiskerLayer2(Chart.CTime(startDate),
                                                          Chart.CTime(endDate), null, null, null, colors);

            layer.setXData(taskNo);
            layer.setBorderColor(Chart.SameAsMainColor);

            // Divide the plot area height ( = 200 in this chart) by the number of tasks to get the
            // height of each slot. Use 80% of that as the bar height.
            layer.setDataWidth((int)(200 * 4 / 5 / labels.Length));

            // Add a legend box at (140, 265) - bottom of the plot area. Use 8pt Arial Bold as the
            // font with auto-grid layout. Set the width to the same width as the plot area. Set the
            // backgorund to grey (dddddd).
            LegendBox legendBox = c.addLegend2(140, 265, Chart.AutoGrid, "Arial Bold", 8);

            legendBox.setWidth(461);
            legendBox.setBackground(0xdddddd);

            // The keys for the scatter layers (milestone symbols) will automatically be added to
            // the legend box. We just need to add keys to show the meanings of the bar colors.
            legendBox.addKey("Market Team", 0x00cc00);
            legendBox.addKey("Planning Team", 0x0000cc);
            legendBox.addKey("Development Team", 0xcc0000);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel}: {top|mmm dd, yyyy} to {bottom|mmm dd, yyyy}'");
        }
Exemple #4
0
        public override void UpdateVisualization()
        {
            List<string>[] chartLabels = null;
            double[] dataArray = null;
            Image img = new Image();
            List<string> xLabels = new List<string>();
            int minTime = 0;

            // Get the Factor Labels
            chartLabels = GetConfigDisplayLabels();
            if (chartLabels == null)
            {
                return;
            }
            for (int i = 0; i < chartLabels[0].Count - 1; i++)
            {
                xLabels.Add(chartLabels[0][i]);
            }

            // Obtain grid
            if ((configDisplayPanel.Children == null) || (configDisplayPanel.Children.Count != 1) ||
                (!(configDisplayPanel.Children[0] is Grid)))
            {
                return;
            }
            Grid grid = configDisplayPanel.Children[0] as Grid;
            double gridWidth = grid.ColumnDefinitions[0].ActualWidth;
            double gridHeight = configDisplay.Height - (grid.RowDefinitions[0].ActualHeight + grid.RowDefinitions[1].ActualHeight);

            // Clear the grid images
            List<UIElement> removalList = new List<UIElement>();
            foreach (UIElement child in grid.Children)
            {
                if (child is Image)
                {
                    removalList.Add(child);
                }
            }
            if (removalList.Count > 0)
            {
                foreach (UIElement child in removalList)
                {
                    grid.Children.Remove(child);
                }
            }

            // The task index, start date, end date and color for each bar
            double[] taskNo = { 0, 1 };
            double[] startValues = { .5, 2.5 };
            double[] endValues = { 1.5, 3.5 };

            // Create a XYChart object of size 620 x 325 pixels. Set background color
            // to light red (0xffcccc), with 1 pixel 3D border effect.
            XYChart c = new XYChart((int)gridWidth, (int)gridHeight);

            c.setPlotArea(150, 50, (int)gridWidth - 200, (int)gridHeight - 100, 0xffffff, 0xeeeeee, Chart.LineColor,
                0xc0c0c0, 0xc0c0c0).setGridWidth(2, 1, 1, 1);

            // swap the x and y axes to create a horziontal box-whisker chart
            c.swapXY();

            // Get RT PME Data
            for (int i = 0; i < xLabels.Count; i++)
            {
                if (GetConfigDisplayData(i, ref dataArray))
                {
                    for (int j = 0; j < dataArray.Length; j++)
                    {
                        if (dataArray[j] > 0)
                        {
                            startList.Add((double)timeTick - 0.4);
                            endList.Add((double)timeTick + 0.4);
                            operatorNum.Add(i);
                            colorList.Add((int)barcodeColors[j]);
                        }
                    }
                }
            }

            timeTick++;
            // Remove old information from data lists
            if (timeTick - BARCODETIMESPAN < 0)
            {
                minTime = 0;
            }
            else
            {
                minTime = timeTick - BARCODETIMESPAN;
            }
            int pos = 0;
            while ((pos < startList.Count) && (startList[pos] <= minTime))
            {
                pos++;
            };
            if (pos != 0)
            {
                startList.RemoveRange(0, pos);
                endList.RemoveRange(0, pos);
                operatorNum.RemoveRange(0, pos);
                colorList.RemoveRange(0, pos);
            }

            // Add a multi-color box-whisker layer to represent the bars
            BoxWhiskerLayer layer = c.addBoxWhiskerLayer2(startList.ToArray(), endList.ToArray(), null, null, null, colorList.ToArray());
            layer.setXData(operatorNum.ToArray());
            layer.setBorderColor(Chart.SameAsMainColor);

            c.yAxis().setLinearScale((double)minTime, (double)timeTick + 0.5, 1, 0);

            // Set the y-axis to shown on the top (right + swapXY = top)
            c.setYAxisOnRight();

            // Set the labels on the x axis
            c.xAxis().setLabels(xLabels.ToArray());
            //c.yAxis().setLabels(yLabelsVals);

            // Reverse the x-axis scale so that it points downwards.
            c.xAxis().setReverse();

            // Set the horizontal ticks and grid lines to be between the bars
            c.xAxis().setTickOffset(0.5);
            //c.yAxis().setTickOffset(0.5);

            // Divide the plot area height ( = 200 in this chart) by the number of
            // tasks to get the height of each slot. Use 80% of that as the bar
            // height.
            //layer.setDataWidth((int)(200 * 4 / 5 / (xLabels.Count)));

            // Add a legend box at (140, 265) - bottom of the plot area. Use 8 pts
            // Arial Bold as the font with auto-grid layout. Set the width to the
            // same width as the plot area. Set the backgorund to grey (dddddd).
            /*            LegendBox legendBox = c.addLegend2(140, 265, Chart.AutoGrid,
                            "Arial Bold", 8);
                        legendBox.setWidth(461);
                        legendBox.setBackground(0xdddddd);
                        */

            /*
                        XYChart c = new XYChart(configDisplay.Width, configDisplay.Height);
                        c.setPlotArea(150, 50, configDisplay.Width - 200, configDisplay.Height - 100);
                        c.addLegend(20, 20);
                        c.xAxis().setLabels(xLabels.ToArray());

                        // Add a stacked bar layer and set the layer 3D depth to 8 pixels
                        BarLayer layer = c.addBarLayer2(Chart.Stack, 8);

                        // Enable bar label for the whole bar
                        layer.setAggregateLabelStyle();

                        // Enable bar label for each segment of the stacked bar
                        layer.setDataLabelStyle();

                        for (int i = 0; i < xLabels.Count; i++)
                        {
                            if (rtpmeConnection.GetConfigDisplayData(configDisplay.ConfigDisplayID, i, ref dataArray))
                            {
                                layer.addDataSet(dataArray, colorValues[i], xLabels[i]);
                            }
                        }
                        */

            // Generate an image of the chart
            System.Drawing.Image imgWinForms = c.makeImage();
            BitmapImage bi = new BitmapImage();

            bi.BeginInit();

            MemoryStream ms = new MemoryStream();

            // Save to a memory stream...

            imgWinForms.Save(ms, ImageFormat.Bmp);

            // Rewind the stream...

            ms.Seek(0, SeekOrigin.Begin);

            // Tell the WPF image to use this stream...
            bi.StreamSource = ms;

            bi.EndInit();
            img.Source = bi;

            Grid.SetColumn(img, 0);
            Grid.SetRow(img, 2);
            grid.Children.Add(img);
        }            
Exemple #5
0
        private void drawChart(WinChartViewer viewer)
        {
            DateTime viewPortStartDate = beginDate.AddSeconds(Math.Round(viewer.ViewPortLeft * dateRange));
            DateTime viewPortEndDate = viewPortStartDate.AddSeconds(Math.Round(viewer.ViewPortWidth * dateRange));
            TimeSpan hoursCalc = viewPortEndDate.Subtract(viewPortStartDate);
            int hours = (hoursCalc.Days * 24) + hoursCalc.Hours;
            viewPortEndDate = viewPortEndDate.AddMinutes(12 * hours); // hack to show hour labels
            Double axisLowerLimit = 0 + viewer.ViewPortTop * rowRange;
            Double axisUpperLimit = axisLowerLimit + viewer.ViewPortHeight * (rowRange);

            XYChart c = new XYChart(winChartViewer1.Width, this.winChartViewer1.Height, 0xf0f0ff, 0, 1);
            //c.setRoundedFrame(ChartDirector.Chart.CColor(BackColor));
			
			// Set the plotarea at (52, 60) and of size 520 x 192 pixels. Use white (ffffff) 
			// background. Enable both horizontal and vertical grids by setting their colors to 
			// grey (cccccc). Set clipping mode to clip the data lines to the plot area.
            int tryToBeMoreDynamic = this.Parent.Height - 200; // instead of hardcoding height
            c.setPlotArea(100, 50, 600, tryToBeMoreDynamic, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
			c.setClipping();

            c.yAxis().setWidth(2);
            c.yAxis().setDateScale(viewPortStartDate, viewPortEndDate);
            c.yAxis().setMultiFormat(ChartDirector.Chart.StartOfHourFilter(), "<*font=bold*>{value|w hh:nn}", ChartDirector.Chart.AllPassFilter(), "{value|w hh:nn}");

            c.xAxis().setWidth(2);
            c.xAxis().setLinearScale(axisLowerLimit, axisUpperLimit, 1);
            c.xAxis().setRounding(false, false);
            c.xAxis().setColors(0xcccccc, ChartDirector.Chart.Transparent);
            c.xAxis().setReverse();

            // swap the x and y axes to create a horziontal box-whisker chart
            c.swapXY();
            BoxWhiskerLayer layer = c.addBoxWhiskerLayer2(ChartDirector.Chart.CTime(timelineBlockBegins.ToArray()), ChartDirector.Chart.CTime(timelineBlockEnds.ToArray()));
            layer.setBoxColors(timelineBlockColors.ToArray());
            layer.addExtraField(timelineBlockNames.ToArray());
            layer.setXData(timelineBlockRow.ToArray());
            layer.setDataLabelFormat("{field0}");
            layer.setDataLabelStyle("Arial Bold").setAlignment(ChartDirector.Chart.Center);
            layer.setDataWidth(35);
            //layer.setDataGap(1);
            // TimelineRow parent
            Double rowParent = 0;
            Int32 colorParentIndex = 0;
            c.xAxis().addMark(0, 0x000000).setLineWidth(2);
            foreach (Double d in timelineBlockZones)
            {
                Double rowParentBegin = rowParent; // --0.5;
                Double rowParentEnd = d + 0.5; // --0.5;

                c.xAxis().addZone(rowParentBegin, rowParentEnd, timelineRowColors[colorParentIndex]);

                Mark xMark1 = c.xAxis().addMark(rowParentBegin, 0x000000, timelineRowNames[colorParentIndex]);
                xMark1.setLineWidth(2);
                xMark1.setFontStyle("Arial Bold Italic");

                // xMark1.setAlignment(ChartDirector.Chart.Center);

                //Mark xMark2 = c.xAxis().addMark(rowParentBegin, 0x000000);
                //xMark2.setLineWidth(2);

                rowParent = d;

                colorParentIndex++;
            }

            // TimelineRow child;
            double inset = 0.5;
            Int32 colorChildIndex = 0;
            foreach (String s in timelineRows)
            {
                Mark xMark = c.xAxis().addMark(colorChildIndex + inset, 0x000000, s);
                xMark.setLineWidth(0);

                colorChildIndex++;
            }

            // Milestones
            c.yAxis2().setDateScale(viewPortStartDate, viewPortEndDate);
            c.yAxis2().setColors(ChartDirector.Chart.Transparent, ChartDirector.Chart.Transparent, ChartDirector.Chart.Transparent);

            if (bShowMilestones)
            {
                Int32 timelineMilestoneCount = 0;
                int indentY = 40;
                double previousValue = 0.0;

                List<IndexedTime> indexedTimes = new List<IndexedTime>();
                for (int i = 0; i < timelineMilestoneTimes.Count; i++)
                {
                    indexedTimes.Add(new IndexedTime(timelineMilestoneTimes[i], i));
                }
                indexedTimes.Sort();

                int one = Int32.Parse("000000", System.Globalization.NumberStyles.AllowHexSpecifier);
                int two = Int32.Parse("888888", System.Globalization.NumberStyles.AllowHexSpecifier);
                int three = Int32.Parse("BB7700", System.Globalization.NumberStyles.AllowHexSpecifier);
                Int32 lineColor = one;

                foreach (IndexedTime time in indexedTimes)
                {
                    if (indentY > tryToBeMoreDynamic-10)
                    {
                        indentY = 40;
                    }

                    indentY += 20;

                    //Int32 lineColor = timelineMilestoneColors[time.Index];
                    Double value = ChartDirector.Chart.CTime(time.Time);

                    if (!value.Equals(previousValue))
                    {
                        if (lineColor == one)
                        {
                            lineColor = two;
                        }
                        else if (lineColor == two)
                        {
                            lineColor = three;
                        }
                        else if (lineColor == three)
                        {
                            lineColor = one;
                        }
                    }

                    Mark yMark = c.yAxis2().addMark(value, c.dashLineColor(lineColor, ChartDirector.Chart.DashLine), timelineMilestoneNames[time.Index]);

                    yMark.setPos(0, indentY);
                    yMark.setFontColor(lineColor);
                    yMark.setLineWidth(2);
                    yMark.setFontStyle("Arial Bold");
                    timelineMilestoneCount++;
                    previousValue = value;
                }
            }

            if (legendStrings != null)
            {
                LegendBox l = c.addLegend(5, 5);
                l.setFontSize(legendFontSize);
                l.setCols(legendStrings.Length);

                for (int i = 0; i < legendStrings.Length; i++)
                {
                    l.addKey(legendStrings[i], legendColors[i]);
                }
            }

            if (navigator != null && componentId >= 0 && legend.Items.Count == 0)
            {
                XPathNodeIterator iTLFilter = navigator.Select("//TimelineFilter");
                List<Int32> seenIDs = new List<Int32>();

                ImageList forLegend = new ImageList();
                foreach (XPathNavigator tlFilterItem in iTLFilter)
                {
                    string filterItemColor = tlFilterItem.GetAttribute(colorAttribute, tlFilterItem.NamespaceURI);

                    if (!forLegend.Images.ContainsKey(filterItemColor))
                    {
                        try
                        {
                            Bitmap bm = new Bitmap(16, 16);
                            Graphics g = Graphics.FromImage((Image)bm);
                            Brush forGraphics = new SolidBrush(HexToColor(filterItemColor));
                            
                            g.SmoothingMode = SmoothingMode.AntiAlias;
                            g.FillRectangle(forGraphics, new Rectangle(0, 0, bm.Width, bm.Height));
                            Icon icon = Icon.FromHandle(bm.GetHicon());
                            forGraphics.Dispose();
                            g.Dispose();
                            bm.Dispose();

                            forLegend.Images.Add(filterItemColor, icon);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, "Error creating icon");
                        }
                    }
                }

                legend.SmallImageList = forLegend;

                foreach (XPathNavigator tlFilterItem in iTLFilter)
                {
                    string filterItemName = tlFilterItem.GetAttribute(nameAttribute, tlFilterItem.NamespaceURI);
                    string filterItemID = tlFilterItem.GetAttribute(idAttribute, tlFilterItem.NamespaceURI);
                    string filterItemType = tlFilterItem.GetAttribute(typeAttribute, tlFilterItem.NamespaceURI);
                    string filterItemColor = tlFilterItem.GetAttribute(colorAttribute, tlFilterItem.NamespaceURI);

                    int iParse = Int32.Parse(filterItemID);
                    if (!seenIDs.Contains(iParse))
                    {
                        legend.Items.Add(filterItemName, filterItemColor);
                        seenIDs.Add(iParse);
                    }
                }
            }

            //Int32 timelineMilestoneCount = 0;
            //foreach (String milestonName in timelineMilestoneNames)
            //{
            //    Double[] xData = { 0 };
            //    Double[] yData = { ChartDirector.Chart.CTime(timelineMilestoneTimes[timelineMilestoneCount]) };
            //    Int32 color = timelineMilestoneColors[timelineMilestoneCount];
            //    ScatterLayer sLayer = c.addScatterLayer(xData, yData, "", ChartDirector.Chart.TriangleSymbol, 13, color);
            //    timelineMilestoneCount++;

            //    // Add labels to the chart as an extra field
            //    sLayer.addExtraField(timelineMilestoneNames.ToArray());

            //    // Set the data label format to display the extra field
            //    sLayer.setDataLabelFormat("{field0}");
            //}

			viewer.Chart = c;
        }