ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Chart director Graph to show central dot line and highest value dot line.
Posted by Hun Siong on May-18-2014 17:58
Dear Sir/Madam,

I am having issue to plot a graph that will have divider central dot line and highest value dot line always show in chart director.

Please help. Below is my code. Thank You.


   //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,DateTime[] datetime,Double[] depth,string titley,string titlex)
        {
            // The data for the area chart
            double[] data = {30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 89,
                60, 55, 53, 35, 50, 66, 56, 48, 52, 65, 62};

            // The labels for the area chart
            double[] labels = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
                16, 17, 18, 19, 20, 21, 22, 23, 24};

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

            // Swap the x and y axis to become a rotated chart
            c.swapXY();

            // Set the y axis on the top side (right + rotated = top)
            c.setYAxisOnRight();

            // Reverse the x axis so it is pointing downwards
            c.xAxis().setReverse();

            // Set the plotarea at (50, 50) and of size 200 x 200 pixels. Enable
            // horizontal and vertical grids by setting their colors to grey
            // (0xc0c0c0).
            c.setPlotArea(50, 50, 220, 250).setGridColor(0xc0c0c0, 0xc0c0c0);

            // Add a line chart layer using the given data
            c.addAreaLayer(depth, c.gradientColor(50, 0, 300, 0, 0xF0FFF0, 0xFFCCCC));

            // Set the labels on the x axis. Append "m" after the value to show the
            // unit.
            c.xAxis().setLabels2(datetime, "{value|hh:nn:ss}");

            // Display 1 out of 3 labels.
            c.xAxis().setLabelStep(10);

            // Add a title to the x axis
            c.xAxis().setTitle(titley);

            // Add a title to the y axis
            c.yAxis().setTitle(titlex);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                "title='Value concentration at {xLabel}: {value} mtr'");
        }

  Re: Chart director Graph to show central dot line and highest value dot line.
Posted by Peter Kwan on May-21-2014 18:09
Hi Hun,

Sorry for my late reply.

I am not exactly sure what are the "central dot line" and "highest value dot line" you
mentioned. I assume you are referrring to two vertical dotted lines, one of them is at the
average data value, and the other at the highest data value.

You may use Axis.addMark to add the horizontal lines. You may refer to the "Marks and
Zones" and "Marks and Zones (2)" for some examples:

http://www.advsofteng.com/doc/cdnet.htm#markzone.htm
http://www.advsofteng.com/doc/cdnet.htm#markzone2.htm

You may use a "dash line color" (see BaseChart.dashLineColor) as the line color. In this
way, the line can be configured to be dotted.

For example:

double avgValue = new ArrayMath(depth).avg();
double highestValue = new ArrayMath(depth).max();

c.yAxis().addMark(avgValue, c.dashLineColor(0x000000, Chart.DotLine));
c.yAxis().addMark(highestValue, c.dashLineColor(0x000000, Chart.DotLine));

If the above is not what you mean, would you mind to attach a sample image (or provide
a link) to help me understand what you need?

Regards
Peter Kwan