Script taking too long to run when TimeAxis used in Chart

  1. #1

    Script taking too long to run when TimeAxis used in Chart

    I have a simple chart with dates on the horizontal axis. When I use a CategoryAxis like below, everything works fine.
    new CategoryAxis()
    {
       Title = "Sampling Date",
       Position = Position.Bottom,
       Grid = true,
       Fields = new string[] { "SamplingDate" },
       Label = new AxisLabel()
       {
          Font = "10px Arial",
          Rotate = new RotateAttribute() { Degrees = 270 },
          Renderer =
          {
             Handler = "return Ext.util.Format.dateRenderer('d-M-Y')(value);"
          }
       }
    }
    However, when I switch to a TimeAxis, like below, I get a script that takes too long to execute.
    new TimeAxis()
    {
       Title = "Sampling Date",
       Position = Position.Bottom,
       Grid = true,
       Fields = new string[] { "SamplingDate" },
       DateFormat = "d-M-Y",
       Label = new AxisLabel()
       {
          Font = "10px Arial",
          Rotate = new RotateAttribute() { Degrees = 270 },
       }
    }
    The warning I get is:
    Click image for larger version. 

Name:	TimeAxis_Script_Warning.PNG 
Views:	11 
Size:	40.8 KB 
ID:	7345
  2. #2
    Hello!

    Welcome to our forum!

    Could you provide a full sample to reproduce?
  3. #3
    Hi Baidaly,

    Thanks for your response.

    This chart belongs to a rather large application that I've been working on.

    I'll endeavour to "extract" a self-contained sample that reproduces the problem and post it as soon as I can.

    Cheers
  4. #4
    UPDATE:

    I figured this one out myself.

    It seems that if no StepUnit parameter is specified, Ext would try to automatically create optimal major and minor tick marks and on a long time-span it would take many cycles to process.

    The simple way I found to correct this was to add the StepUnit parameter. The modified code is below.
    new TimeAxis()
    {
       Title = "Sampling Date",
       Position = Position.Bottom,
       Grid = true,
       Fields = new string[] { "SamplingDate" },
       AdjustMinimumByMajorUnit = true,
       StepUnit = DateUnit.Year,
       MinorTickSteps = 11,
       DateFormat = "dd-MMM-Y",
       AutoDataBind = true,
       Label = new AxisLabel()
       {
          Font = "10px Arial",
          Rotate = new RotateAttribute() { Degrees = 270 }
       }
    }
    I hope someone finds this useful.

    Cheers.
  5. #5
    Thank you for update!

Similar Threads

  1. TimeAxis step
    By dnagy in forum 2.x Help
    Replies: 1
    Last Post: Nov 30, 2013, 1:20 AM
  2. Replies: 2
    Last Post: Oct 23, 2013, 7:26 PM
  3. Chart TimeAxis FromDate ToDate problem
    By bovo13 in forum 2.x Help
    Replies: 0
    Last Post: Dec 12, 2012, 9:15 AM
  4. [CLOSED] return html server response instead of just long extjs script!
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 17, 2011, 8:38 AM
  5. Replies: 7
    Last Post: Feb 17, 2011, 11:45 AM

Posting Permissions