Beispiel #1
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The data for the bar chart
            double[] data = { 3.9, 8.1, 10.9, 14.2, 18.1, 19.0, 21.2, 23.2, 25.7, 36 };

            // The labels for the bar chart
            string[] labels = { "Bastic Group", "Simpa",        "YG Super", "CID",
                                "Giga Tech",    "Indo Digital", "Supreme",  "Electech","THP Thunder",
                                "Flash Light" };

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

            // Add a title to the chart using Arial Bold Italic font
            c.addTitle("Revenue Estimation - Year 2002", "Arial Bold Italic");

            // Set the plotarea at (100, 30) and of size 400 x 200 pixels. Set the
            // plotarea border, background and grid lines to Transparent
            c.setPlotArea(100, 30, 400, 200, Chart.Transparent, Chart.Transparent,
                          Chart.Transparent, Chart.Transparent, Chart.Transparent);

            // Add a bar chart layer using the given data. Use a gradient color for
            // the bars, where the gradient is from dark green (0x008000) to white
            // (0xffffff)
            BarLayer layer = c.addBarLayer(data, c.gradientColor(100, 0, 500, 0,
                                                                 0x008000, 0xffffff));

            // Swap the axis so that the bars are drawn horizontally
            c.swapXY(true);

            // Set the bar gap to 10%
            layer.setBarGap(0.1);

            // Use the format "US$ xxx millions" as the bar label
            layer.setAggregateLabelFormat("US$ {value} millions");

            // Set the bar label font to 10 pts Times Bold Italic/dark red (0x663300)
            layer.setAggregateLabelStyle("Times New Roman Bold Italic", 10, 0x663300)
            ;

            // Set the labels on the x axis
            ChartDirector.TextBox textbox = c.xAxis().setLabels(labels);

            // Set the x axis label font to 10pt Arial Bold Italic
            textbox.setFontStyle("Arial Bold Italic");
            textbox.setFontSize(10);

            // Set the x axis to Transparent, with labels in dark red (0x663300)
            c.xAxis().setColors(Chart.Transparent, 0x663300);

            // Set the y axis and labels to Transparent
            c.yAxis().setColors(Chart.Transparent, Chart.Transparent);

            // Output the chart
            viewer.Image = c.makeImage();

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{xLabel}: US${value} millions'");
        }
Beispiel #2
0
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the bar chart
            double[] data0  = { 100, 125, 245, 147, 67 };
            double[] data1  = { 85, 156, 179, 211, 123 };
            double[] data2  = { 97, 87, 56, 267, 157 };
            string[] labels = { "Mon", "Tue", "Wed", "Thur", "Fri" };

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

            // Add a title to the chart using 18pt Times Bold Italic font
            c.addTitle("Average Weekly Network Load", "Times New Roman Bold Italic", 18);

            // Set the plotarea at (50, 55) and of 440 x 280 pixels in size. Use a vertical gradient
            // color from light blue (f9f9ff) to blue (6666ff) as background. Set border and grid lines
            // to white (ffffff).
            c.setPlotArea(50, 55, 440, 280, c.linearGradientColor(0, 55, 0, 335, 0xf9f9ff, 0x6666ff), -1,
                          0xffffff, 0xffffff);

            // Add a legend box at (50, 28) using horizontal layout. Use 10pt Arial Bold as font, with
            // transparent background.
            c.addLegend(50, 28, false, "Arial Bold", 10).setBackground(Chart.Transparent);

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

            // Draw the ticks between label positions (instead of at label positions)
            c.xAxis().setTickOffset(0.5);

            // Set axis label style to 8pt Arial Bold
            c.xAxis().setLabelStyle("Arial Bold", 8);
            c.yAxis().setLabelStyle("Arial Bold", 8);

            // Set axis line width to 2 pixels
            c.xAxis().setWidth(2);
            c.yAxis().setWidth(2);

            // Add axis title
            c.yAxis().setTitle("Throughput (MBytes Per Hour)");

            // Add a multi-bar layer with 3 data sets
            BarLayer layer = c.addBarLayer2(Chart.Side);

            layer.addDataSet(data0, 0xff0000, "Server #1");
            layer.addDataSet(data1, 0x00ff00, "Server #2");
            layer.addDataSet(data2, 0xff8800, "Server #3");

            // Set bar border to transparent. Use glass lighting effect with light direction from left.
            layer.setBorderColor(Chart.Transparent, Chart.glassEffect(Chart.NormalGlare, Chart.Left));

            // Configure the bars within a group to touch each others (no gap)
            layer.setBarGap(0.2, Chart.TouchBar);

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

            // Output Javascript chart model to the browser to suppport tracking cursor
            viewer.ChartModel = c.getJsChartModel();
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // Data for the chart
            double[] data0  = { 100, 125, 245, 147, 67, 96, 160, 145, 97, 167, 220, 125 };
            double[] data1  = { 85, 156, 179, 211, 123, 225, 127, 99, 111, 260, 175, 156 };
            double[] data2  = { 97, 87, 56, 267, 157, 157, 67, 156, 77, 87, 197, 87 };
            string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct",
                                "Nov", "Dec" };

            // Create a XYChart object of size 560 x 280 pixels.
            XYChart c = new XYChart(560, 280);

            // Add a title to the chart using 14pt Arial Bold Italic font
            c.addTitle("     Average Weekly Network Load", "Arial Bold Italic", 14);

            // Set the plotarea at (50, 50) and of 500 x 200 pixels in size. Use alternating light grey
            // (f8f8f8) / white (ffffff) background. Set border to transparent and use grey (CCCCCC)
            // dotted lines as horizontal and vertical grid lines
            c.setPlotArea(50, 50, 500, 200, 0xffffff, 0xf8f8f8, Chart.Transparent, c.dashLineColor(
                              0xcccccc, Chart.DotLine), c.dashLineColor(0xcccccc, Chart.DotLine));

            // Add a legend box at (50, 22) using horizontal layout. Use 10 pt Arial Bold Italic font,
            // with transparent background
            c.addLegend(50, 22, false, "Arial Bold Italic", 10).setBackground(Chart.Transparent);

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

            // Draw the ticks between label positions (instead of at label positions)
            c.xAxis().setTickOffset(0.5);

            // Add axis title
            c.yAxis().setTitle("Throughput (MBytes Per Hour)");

            // Set axis line width to 2 pixels
            c.xAxis().setWidth(2);
            c.yAxis().setWidth(2);

            // Add a multi-bar layer with 3 data sets
            BarLayer layer = c.addBarLayer2(Chart.Side);

            layer.addDataSet(data0, 0xff0000, "Server #1");
            layer.addDataSet(data1, 0x00ff00, "Server #2");
            layer.addDataSet(data2, 0x0000ff, "Server #3");

            // Set bar shape to circular (cylinder)
            layer.setBarShape(Chart.CircleShape);

            // Configure the bars within a group to touch each others (no gap)
            layer.setBarGap(0.2, Chart.TouchBar);

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='{dataSetName} on {xLabel}: {value} MBytes/hour'");
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the chart
            double[] data = { 40, 45, 37, 24, 32, 39, 53, 52, 63, 49, 46, 40, 54, 50, 57, 57, 48, 49, 63,
                              67, 74, 72, 70, 89, 74 };
            string[] labels = { "0\nJun 4", "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",  "10", "11", "12",
                                "13",       "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "0\nJun 5" };

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

            // Set the plotarea at (80, 60) and of size 300 x 200 pixels. Turn off the grid lines by
            // setting their colors to Transparent.
            c.setPlotArea(80, 28, 300, 200).setGridColor(Chart.Transparent);

            // Add a title to the y axis
            ChartDirector.TextBox textbox = c.yAxis().setTitle("Temperature");

            // Set the y axis title upright (font angle = 0)
            textbox.setFontAngle(0);

            // Put the y axis title on top of the axis
            textbox.setAlignment(Chart.TopLeft2);

            // Add green (0x99ff99), yellow (0xffff99) and red (0xff9999) zones to the y axis to
            // represent the ranges 0 - 50, 50 - 80, and 80 - max.
            c.yAxis().addZone(0, 50, 0x99ff99);
            c.yAxis().addZone(50, 80, 0xffff99);
            c.yAxis().addZone(80, 9999, 0xff9999);

            // Add a purple (0x800080) mark at y = 70 using a line width of 2.
            c.yAxis().addMark(70, 0x800080, "Alert = 70").setLineWidth(2);

            // Add a green (0x008000) mark at y = 40 using a line width of 2.
            c.yAxis().addMark(40, 0x008000, "Watch = 40").setLineWidth(2);

            // Add a legend box at (165, 0) (top right of the chart) using 8pt Arial font. and horizontal
            // layout.
            LegendBox legend = c.addLegend(165, 0, false, "Arial Bold", 8);

            // Disable the legend box boundary by setting the colors to Transparent
            legend.setBackground(Chart.Transparent, Chart.Transparent);

            // Add 3 custom entries to the legend box to represent the 3 zones
            legend.addKey("Normal", 0x80ff80);
            legend.addKey("Warning", 0xffff80);
            legend.addKey("Critical", 0xff8080);

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

            // Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
            c.xAxis().setLabelStep(3, 1);

            // Add a 3D bar layer with the given data
            BarLayer layer = c.addBarLayer(data, 0xbbbbff);

            // Set the bar gap to 0 so that the bars are packed tightly
            layer.setBarGap(0);

            // Set the border color of the bars same as the fill color, with 1 pixel 3D border effect.
            layer.setBorderColor(Chart.SameAsMainColor, 1);

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "", "title='Temperature at {x}:00 = {value} C'");
        }
Beispiel #5
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The data for the bar chart
            double[] data0  = { 100, 125, 245, 147, 67 };
            double[] data1  = { 85, 156, 179, 211, 123 };
            double[] data2  = { 97, 87, 56, 267, 157 };
            string[] labels = { "Mon", "Tue", "Wed", "Thur", "Fri" };

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

            // Add a title to the chart using 18 pts Times Bold Italic font
            c.addTitle("Average Weekly Network Load", "Times New Roman Bold Italic",
                       18);

            // Set the plotarea at (50, 55) and of 440 x 280 pixels in size. Use a
            // vertical gradient color from light red (ffdddd) to dark red (880000)
            // as background. Set border and grid lines to white (ffffff).
            c.setPlotArea(50, 55, 440, 280, c.linearGradientColor(0, 55, 0, 335,
                                                                  0xffdddd, 0x880000), -1, 0xffffff, 0xffffff);

            // Add a legend box at (50, 25) using horizontal layout. Use 10pts Arial
            // Bold as font, with transparent background.
            c.addLegend(50, 25, false, "Arial Bold", 10).setBackground(
                Chart.Transparent);

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

            // Draw the ticks between label positions (instead of at label positions)
            c.xAxis().setTickOffset(0.5);

            // Set axis label style to 8pts Arial Bold
            c.xAxis().setLabelStyle("Arial Bold", 8);
            c.yAxis().setLabelStyle("Arial Bold", 8);

            // Set axis line width to 2 pixels
            c.xAxis().setWidth(2);
            c.yAxis().setWidth(2);

            // Add axis title
            c.yAxis().setTitle("Throughput (MBytes Per Hour)");

            // Add a multi-bar layer with 3 data sets and 4 pixels 3D depth
            BarLayer layer = c.addBarLayer2(Chart.Side, 4);

            layer.addDataSet(data0, 0xffff00, "Server #1");
            layer.addDataSet(data1, 0x00ff00, "Server #2");
            layer.addDataSet(data2, 0x9999ff, "Server #3");

            // Set bar border to transparent. Use soft lighting effect with light
            // direction from top.
            layer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Top));

            // Configure the bars within a group to touch each others (no gap)
            layer.setBarGap(0.2, Chart.TouchBar);

            // Output the chart
            viewer.Image = c.makeImage();

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} on {xLabel}: {value} MBytes/hour'");
        }
Beispiel #6
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)
        {
            //
            // This example demonstrates creating a histogram with a bell curve from raw data. About
            // half of the code is to sort the raw data into slots and to generate the points on the
            // bell curve. The remaining half of the code is the actual charting code.
            //

            // Generate a random guassian distributed data series as the input data for this
            // example.
            RanSeries r = new RanSeries(66);

            double[] samples = r.getGaussianSeries(200, 100, 10);

            //
            // Classify the numbers into slots. In this example, the slot width is 5 units.
            //
            int slotSize = 5;

            // Compute the min and max values, and extend them to the slot boundary.
            ArrayMath m    = new ArrayMath(samples);
            double    minX = Math.Floor(m.min() / slotSize) * slotSize;
            double    maxX = Math.Floor(m.max() / slotSize) * slotSize + slotSize;

            // We can now determine the number of slots
            int slotCount = (int)((maxX - minX + 0.5) / slotSize);

            double[] frequency = new double[slotCount];

            // Count the data points contained in each slot
            for (int i = 0; i < samples.Length; ++i)
            {
                int slotIndex = (int)((samples[i] - minX) / slotSize);
                frequency[slotIndex] = frequency[slotIndex] + 1;
            }

            //
            // Compute Normal Distribution Curve
            //

            // The mean and standard deviation of the data
            double mean   = m.avg();
            double stdDev = m.stdDev();

            // The normal distribution curve (bell curve) is a standard statistics curve. We need to
            // vertically scale it to make it proportion to the frequency count.
            double scaleFactor = slotSize * samples.Length / stdDev / Math.Sqrt(6.2832);

            // In this example, we plot the bell curve up to 3 standard deviations.
            double stdDevWidth = 3.0;

            // We generate 4 points per standard deviation to be joined with a spline curve.
            int bellCurveResolution = (int)(stdDevWidth * 4 + 1);

            double[] bellCurve = new double[bellCurveResolution];
            for (int i = 0; i < bellCurveResolution; ++i)
            {
                double z = 2 * i * stdDevWidth / (bellCurveResolution - 1) - stdDevWidth;
                bellCurve[i] = Math.Exp(-z * z / 2) * scaleFactor;
            }

            //
            // At this stage, we have obtained all data and can plot the chart.
            //

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

            // Set the plotarea at (50, 30) and of size 500 x 300 pixels, with transparent
            // background and border and light grey (0xcccccc) horizontal grid lines
            c.setPlotArea(50, 30, 500, 300, Chart.Transparent, -1, Chart.Transparent, 0xcccccc);

            // Display the mean and standard deviation on the chart

            c.addTitle("Mean = " + c.formatValue(mean, "{value|1}") + ", Standard Deviation = " +
                       c.formatValue(stdDev, "{value|2}"), "Arial");


            // Set the x and y axis label font to 12pt Arial
            c.xAxis().setLabelStyle("Arial", 12);
            c.yAxis().setLabelStyle("Arial", 12);

            // Set the x and y axis stems to transparent, and the x-axis tick color to grey
            // (0x888888)
            c.xAxis().setColors(Chart.Transparent, Chart.TextColor, Chart.TextColor, 0x888888);
            c.yAxis().setColors(Chart.Transparent);

            // Draw the bell curve as a spline layer in red (0xdd0000) with 2-pixel line width
            SplineLayer bellLayer = c.addSplineLayer(bellCurve, 0xdd0000);

            bellLayer.setXData2(mean - stdDevWidth * stdDev, mean + stdDevWidth * stdDev);
            bellLayer.setLineWidth(2);
            // No tooltip is needed for the spline layer
            bellLayer.setHTMLImageMap("{disable}");

            // Draw the histogram as bars in blue (0x6699bb) with dark blue (0x336688) border
            BarLayer histogramLayer = c.addBarLayer(frequency, 0x6699bb);

            histogramLayer.setBorderColor(0x336688);
            // The center of the bars span from minX + half_bar_width to maxX - half_bar_width
            histogramLayer.setXData2(minX + slotSize / 2.0, maxX - slotSize / 2.0);
            // Configure the bars to touch each other with no gap in between
            histogramLayer.setBarGap(Chart.TouchBar);
            // Use rounded corners for decoration
            histogramLayer.setRoundedCorners();
            // Tool tip for the histogram
            histogramLayer.setHTMLImageMap("", "", "title='{value}'");

            // ChartDirector by default will extend the x-axis scale by 0.5 unit to cater for the
            // bar width. It is because a bar plotted at x actually occupies (x +/- half_bar_width),
            // and the bar width is normally 1 for label based x-axis. However, this chart is using
            // a linear x-axis instead of label based. So we disable the automatic extension and add
            // a dummy layer to extend the x-axis scale to cover minX to maxX.
            c.xAxis().setIndent(false);
            c.addLineLayer2().setXData(minX, maxX);

            // For the automatic y-axis labels, set the minimum spacing to 40 pixels.
            c.yAxis().setTickDensity(40);

            // Output the chart
            viewer.Chart = c;

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable");
        }
        //
        // Create chart
        //
        private void createChart(RazorChartViewer viewer)
        {
            // The data for the bar chart
            double[] data0 = { 44, 55, 100 };
            double[] data1 = { 97, 87, 167 };
            double[] data2 = { 156, 78, 147 };
            double[] data3 = { 125, 118, 211 };

            // The labels for the bar chart. The labels contains embedded images as icons.
            string[] labels = { "<*img=service.png*><*br*>Service", "<*img=software.png*><*br*>Software",
                                "<*img=computer.png*><*br*>Hardware" };

            // Create a XYChart object of size 600 x 350 pixels, using 0xe0e0ff as the background color,
            // 0xccccff as the border color, with 1 pixel 3D border effect.
            XYChart c = new XYChart(600, 350, 0xe0e0ff, 0xccccff, 1);

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

            // Add a title to the chart using 14 points Times Bold Itatic font and light blue (0x9999ff)
            // as the background color
            c.addTitle("Business Results 2001 vs 2002", "Times New Roman Bold Italic", 14).setBackground(
                0x9999ff);

            // Set the plotarea at (60, 45) and of size 500 x 210 pixels, using white (0xffffff) as the
            // background
            c.setPlotArea(60, 45, 500, 210, 0xffffff);

            // Swap the x and y axes to create a horizontal bar chart
            c.swapXY();

            // Add a title to the y axis using 11 pt Times Bold Italic as font
            c.yAxis().setTitle("Revenue (millions)", "Times New Roman Bold Italic", 11);

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

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

            // Add a stacked bar layer to the chart
            BarLayer layer = c.addBarLayer2(Chart.Stack);

            // Add the first two data sets to the chart as a stacked bar group
            layer.addDataGroup("2001");
            layer.addDataSet(data0, 0xaaaaff, "Local");
            layer.addDataSet(data1, 0x6666ff, "International");

            // Add the remaining data sets to the chart as another stacked bar group
            layer.addDataGroup("2002");
            layer.addDataSet(data2, 0xffaaaa, "Local");
            layer.addDataSet(data3, 0xff6666, "International");

            // Set the sub-bar gap to 0, so there is no gap between stacked bars with a group
            layer.setBarGap(0.2, 0);

            // Set the bar border to transparent
            layer.setBorderColor(Chart.Transparent);

            // Set the aggregate label format
            layer.setAggregateLabelFormat("Year {dataGroupName}\n{value} millions");

            // Set the aggregate label font to 8 point Arial Bold Italic
            layer.setAggregateLabelStyle("Arial Bold Italic", 8);

            // Reverse 20% space at the right during auto-scaling to allow space for the aggregate bar
            // labels
            c.yAxis().setAutoScale(0.2);

            // Add a legend box at (310, 300) using TopCenter alignment, with 2 column grid layout, and
            // use 8pt Arial Bold Italic as font
            LegendBox legendBox = c.addLegend2(310, 300, 2, "Arial Bold Italic", 8);

            legendBox.setAlignment(Chart.TopCenter);

            // Set the format of the text displayed in the legend box
            legendBox.setText("Year {dataGroupName} {dataSetName} Revenue");

            // Set the background and border of the legend box to transparent
            legendBox.setBackground(Chart.Transparent, Chart.Transparent);

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

            // Include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("", "",
                                                "title='Year {dataGroupName} {dataSetName} {xLabel} Revenue: {value} millions'");
        }
Beispiel #8
0
        //Main code for creating chart.
        //Note: the argument img is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, string img)
        {
            // The age groups
            string[] labels = { "0 - 4",   "5 - 9",   "10 - 14", "15 - 19", "20 - 24",
                                "24 - 29", "30 - 34", "35 - 39", "40 - 44", "44 - 49","50 - 54",
                                "55 - 59", "60 - 64", "65 - 69", "70 - 74", "75 - 79","80+" };

            // The male population (in thousands)
            double[] male = { 215, 238, 225, 236, 235, 260, 286, 340, 363, 305, 259,
                              164, 135, 127, 102,  68, 66 };

            // The female population (in thousands)
            double[] female = { 194, 203, 201, 220, 228, 271, 339, 401, 384, 304, 236,
                                137, 116, 122, 112,  85, 110 };


            //=============================================================
            //    Draw the right bar chart
            //=============================================================

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

            // Set the plotarea at (50, 0) and of size 250 x 255 pixels. Use pink
            // (0xffdddd) as the background.
            c.setPlotArea(50, 0, 250, 255, 0xffdddd);

            // Add a custom text label at the top right corner of the right bar chart
            c.addText(300, 0, "Female", "Times New Roman Bold Italic", 12, 0xa07070
                      ).setAlignment(Chart.TopRight);

            // Add the pink (0xf0c0c0) bar chart layer using the female data
            BarLayer femaleLayer = c.addBarLayer(female, 0xf0c0c0, "Female");

            // Swap the axis so that the bars are drawn horizontally
            c.swapXY(true);

            // Set the bar to touch each others
            femaleLayer.setBarGap(Chart.TouchBar);

            // Set the border style of the bars to 1 pixel 3D border
            femaleLayer.setBorderColor(-1, 1);

            // Add a Transparent line layer to the chart using the male data. As it
            // is Transparent, only the female bar chart can be seen. We need to put
            // both male and female data in both left and right charts, because we
            // want auto-scaling to produce the same scale for both chart.
            c.addLineLayer(male, Chart.Transparent);

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

            // Set the labels between the two bar charts, which can be considered as
            // the x-axis labels for the right chart
            ChartDirector.TextBox tb = c.xAxis().setLabels(labels);

            // Use a fix width of 50 for the labels (height = automatic) with center
            // alignment
            tb.setSize(50, 0);
            tb.setAlignment(Chart.Center);

            // Set the label font to Arial Bold
            tb.setFontStyle("Arial Bold");

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

            //=============================================================
            //    Draw the left bar chart
            //=============================================================

            // Create a XYChart object of size 280 x 300 pixels with a transparent
            // background.
            XYChart c2 = new XYChart(280, 300, Chart.Transparent);

            // Set the plotarea at (20, 0) and of size 250 x 255 pixels. Use pale
            // blue (0xddddff) as the background.
            c2.setPlotArea(20, 0, 250, 255, 0xddddff);

            // Add a custom text label at the top left corner of the left bar chart
            c2.addText(20, 0, "Male", "Times New Roman Bold Italic", 12, 0x7070a0);

            // Add the pale blue (0xaaaaff) bar chart layer using the male data
            BarLayer maleLayer = c2.addBarLayer(male, 0xaaaaff, "Male");

            // Swap the axis so that the bars are drawn horizontally
            c2.swapXY(true);

            // Reverse the direction of the y-axis so it runs from right to left
            c2.yAxis().setReverse();

            // Set the bar to touch each others
            maleLayer.setBarGap(Chart.TouchBar);

            // Set the border style of the bars to 1 pixel 3D border
            maleLayer.setBorderColor(-1, 1);

            // Add a Transparent line layer to the chart using the female data. As it
            // is Transparent, only the male bar chart can be seen. We need to put
            // both male and female data in both left and right charts, because we
            // want auto-scaling to produce the same scale for both chart.
            c2.addLineLayer(female, Chart.Transparent);

            // Set the y axis label font to Arial Bold
            c2.yAxis().setLabelStyle("Arial Bold");

            // Set the x-axis labels for tool tip purposes.
            c2.xAxis().setLabels(labels);

            // Hide the x-axis labels by setting them to Transparent. We only need to
            // display the x-axis labels for the right chart.
            c2.xAxis().setColors(0x000000, Chart.Transparent, -1, Chart.Transparent);

            //=============================================================
            //    Use a MultiChart to contain both bar charts
            //=============================================================

            // Create a MultiChart object of size 590 x 320 pixels.
            MultiChart m = new MultiChart(590, 320);

            // Add a title to the chart using Arial Bold Italic font
            m.addTitle("Demographics Hong Kong Year 2002", "Arial Bold Italic");

            // Add another title at the bottom using Arial Bold Italic font
            m.addTitle2(Chart.Bottom, "Population (in thousands)",
                        "Arial Bold Italic", 10);

            // Put the right chart at (270, 25)
            m.addChart(270, 25, c);

            // Put the left chart at (0, 25)
            m.addChart(0, 25, c2);

            // Output the chart
            viewer.Image = m.makeImage();

            //include tool tip for the chart
            viewer.ImageMap = m.getHTMLImageMap("clickable", "",
                                                "title='{dataSetName} (Age {xLabel}): Population {value}K'");
        }