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

Message ListMessage List     Post MessagePost Message

  to draw the graph for x -axis sclae with datetime
Posted by Prathika on Aug-22-2011 23:25
Hi,

I want to draw the graph with  DateTime x-axis label. I have created the graph but the scale is not unique. First day  has less values and other day has large values so x axis scale size is differ for first and second day.
Please give your suggestion for create the graph with equal x-axis scale.
I have  used the below methods:
c.xAxis().setMultiFormat(Chart.StartOfDayFilter(),
               "<*font=Arial Bold*>{value|mmm dd}", Chart.AllPassFilter(),
               "");

DateTime tempStartDate = new DateTime(2011, startDate.Month, startDate.Day, 00, 00,00);
DateTime tempEndDate = new DateTime(2011, endDate.Month, endDate.Day, 12, 00, 00);

   c.xAxis().setDateScale(tempStartDate, tempEndDate);
but no change in result.

For example,
1'st day  has  less values and start 4.pm(4pm to 12.00PM totally 8 hours data)  and 2nd day has large values (i.e.,)it starts 00.00AM to 12.00PM(1 to 24 hours totally 24 hours data).  This is the reason for getting small size scale for 1'st day and large scale for 2nd day.

Is Any other method to calculate the equal scale for  DateTime in x-axis.
is Any method/attribute  to represent AM to PM

Waiting your response,

Thanks,
K.Prathika

  Re: to draw the graph for x -axis sclae with datetime
Posted by Peter Kwan on Aug-23-2011 03:01
Hi Prathika,

If you use something like:

DateTime tempStartDate = new DateTime(2011, startDate.Month, startDate.Day, 00, 00,00);
DateTime tempEndDate = new DateTime(2011, endDate.Month, endDate.Day, 23, 59, 59);
c.xAxis().setDateScale(tempStartDate, tempEndDate);

Then all day should be of equal length on the x-axis.

If the above is not what you see, is it possible to inform me of your complete charting code, and also the chart you get with the code?

Regards
Peter Kwan

  Re: to draw the graph for x -axis sclae with datetime
Posted by Prathika on Aug-23-2011 12:00
Hi Peter,
I tried the above code which you suggested but it is not giving equal size of scale.

requirements:
I want to plot the graph for two days.
class retrieve the two days values i.e., first day start from 00:00:00 AM to second day of
current time (9.00 AM). Here first day has 24 values but second day has 9 values.
Now I plot the graph, first day scale size is large but second day scale size is small. This is
my problem.

I want to plot the graph with equal scale size and Datetime as label.

Please send the solution.


Thanks,
K.Prathika

  Re: to draw the graph for x -axis sclae with datetime
Posted by Prathika on Aug-23-2011 16:34
Hi Peter,
I am attaching my file for your reference.

thanks,
K.Prathika

  Re: to draw the graph for x -axis sclae with datetime
Posted by Peter Kwan on Aug-24-2011 02:55
Hi Prathika,

(*** NOTE ***: I have just deleted the attachment in your previous message, as it contains your license key.)

For your case, you should use Axis.setDateScale (not Axis.setLabels). When you add the line layer, you would need to provide the x-coordinates using Layer.setXData.

I have modified your original code as follows (but I have not tested it):

    // Create a XYChart object of size 250 x 250 pixels
    XYChart c = new XYChart(512, 242, 0xf4f4f4, 0x000000, 0);
    c.setPlotArea(90, 30, 320, 152, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

    c.setRoundedFrame();
    if (status != null)
    {
        status("Try to plot the graph");
    }



    c.yAxis().setLabelFormat("{value}");
    c.xAxis().setColors(Chart.Transparent);
    c.yAxis().setColors(Chart.Transparent);
    //c.xAxis().setAutoScale();


   /* if (data != null && data.Min() < 1 && !(measure.Equals("NetworkIn") || measure.Equals("NetworkOut")))
    {
            //c.yAxis().setLinearScale(-5,data.Max(),10);
            c.yAxis().setAutoScale();

    }*/


    DateTime tempStartDate = new DateTime(2011, startDate.Month, startDate.Day, 00, 00, 00);
    DateTime tempEndDate = new DateTime(2011, endDate.Month, endDate.Day, 23, 59, 59);
    c.xAxis().setDateScale(tempStartDate, tempEndDate);

    if (endDate.Subtract(startDate).TotalHours>=24)
    {
       c.xAxis().setMultiFormat(Chart.StartOfDayFilter(),
       "<*font=Arial Bold*>{value|mmm dd}", Chart.AllPassFilter(),
       "{value|hh:nn}");

    }
    else
    {
         c.xAxis().setLabelFormat("{value|hh:nn}");

    }
    if (!polling)
    {
        c.xAxis().setTitle("From " + startDate.ToShortDateString() + " To " + endDate.ToShortDateString());

    }
    else
    {
        c.xAxis().setTitle("Last-Poll-Time = " + endDate.ToLongTimeString());
        c.xAxis().setTitle("scale: x-axis: 1 units = 6 minutes   Last-Poll-Time = " + endDate.ToLongTimeString());

    }





    if (measure.Equals("CPUUtilization"))
    {
        ChartDirector.TextBox title = c.addTitle(measure + " (Percent/Minutes)","Tahoma Bold", 8);
        title.setMargin2(0, 0, 6, 6);
    }
    else
    {
        ChartDirector.TextBox title = c.addTitle(measure + " (Bytes/Minutes)",
       "Tahoma Bold", 8);
        title.setMargin2(0, 0, 6, 6);
    }
     c.addLegend(50, 9, false, "Arial Bold", 9).setBackground(
        Chart.Transparent);


    //LineLayer layer = c.addLineLayer(data);
    LineLayer layer = c.addLineLayer2();
    layer.setLineWidth(2);
    layer.setXData(labels);

    c.xAxis().setLabelStyle("Arial", 8, Chart.TextColor, 45);



    layer.addDataSet(data, 0x000080, "").setDataSymbol(
     Chart.CircleSymbol, 2);
    layer.setGapColor(c.dashLineColor(0xff6600));
    c.packPlotArea(15, 268,
    c.getWidth() - 16, c.getHeight() - 25);

    viewer.Image = c.makeImage();

    viewer.ImageMap = c.getHTMLImageMap("clickable", "",
        "title='{x|yyyy-mm-dd hh:nn} {value}'");
    if(status!=null)
        status("completed ........");



Hope this can help.

Regards
Peter Kwan

  Re: to draw the graph for x -axis sclae with datetime
Posted by Prathika on Aug-24-2011 20:12
Hi Peter,

Thank you for your timely help.

This works fine. Now I faced the same problem for plot the one hour data with  set labelStep as 6. Here 7 scale are equal but last one is small size.


Thanks,
K.Prathika

  Re: to draw the graph for x -axis sclae with datetime
Posted by Prathika on Aug-24-2011 20:15
Hi Peter,

Another question:
I used dashed lines for not running state that is if the value has Chart.NoValue. Here my application, data Array contains the starting value is Chart.NoValue and remaining has some values. Here graph is not show the dash lines for starting stage, but in middle data
has NoValue then it show dash lines.

Thanks,
K.Prathika

  Re: to draw the graph for x -axis sclae with datetime
Posted by Peter Kwan on Aug-24-2011 23:56
Hi Prathika,

It is logically not possible to show a dash line for the leading NoValue point(s). It is because you need two valid points to draw a line.

For example, suppose you data contains 5 data values:

NoValue, 10, NoValue, 100, 200

It is possible to draw a dash line connecting 10 and 100, thereby jumping through the NoValue point between 10 and 100. However, it is not possible to draw a dash line the jumps through the first NoValue point. So the only logical representation is to leave a gap for the leading NoValue point.

If you think it is possible to draw a dash line to jump through the first NoValue point, would you mind to clarify where should the two end points of the dash line?

Hope this can help.

Regards
Peter Kwan

  Re: to draw the graph for x -axis sclae with datetime
Posted by Peter Kwan on Aug-24-2011 23:59
Hi Prathika,

If you face the same problem with hourly data, you may use the same solution for hourly data. In brief, the solution is:

- Do not use Axis.setLabels or Axis.setLabelStep. Instead, use Axis.setDateScale, Axis.setLabelFormat, and Layer.setXData.

For example:

//startTime and endTime is for a duration of one hour
c.xAxis().setDateScale(startTime, endTime, 600);
c.xAxis().setLabelFormat("{value|hh}");

layer.setXData(myTimeStamps);

Hope this can help.

Regards
Peter Kwan

  Re: to draw the graph for x -axis sclae with datetime
Posted by Prathika on Aug-25-2011 11:54
Hi Peter,
Thank you . It is working.

Thanks,
K.Prathika