Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay, Here I found a solutions for the problem. Similar to what @fotomut mentioned above. I have copied all the code from 'CategoryAxis' except rewrote the 'udpate()' method. This is where the labels get generated. Here is my implementation of update method, may not be a perfect solution....</p> <p>But, I am facing an issue here. For some reason, the graph and labels looks a bit shifted towards the right hand side. I am unable to post a picture comparing my CustomDateAxis to flex provided CategoryAxis to better explain this, as I am restricted not to upload any files. I am trying to fix this, yet to find a solution...</p> <pre><code>if (!_labelSet) { //I do not need label for each item in my dataprovider. //Hence creating a 'categoryValues' array with limited labels. var chartDP:ArrayCollection = this.dataProvider as ArrayCollection; var axisLabels:Array /* of AxisLabel */ = []; var labelsArr:Array = []; var categoryItems:Array = []; var dataMap:Object = {}; _catMap = {}; _categoryValues = []; _labelsMatchToCategoryValuesByIndex = []; if(chartDP.length != 0) { for(var indx:int=0; indx&lt;chartDP.length; indx++){ // Add each item to the map. //This is mandatory as it's being used internally to draw the Y-value _catMap[chartDP.getItemAt(indx).timeStamp.toString()] = indx; } var firstItem:Object = chartDP.getItemAt(0); var lastItem:Object = chartDP.getItemAt(chartDP.length - 1); var incrCounter:int; var timeDiffInMillis:Number = (lastItem.timeStamp) - (firstItem.timeStamp); var arrIndx:int=0; if(timeDiffInMillis &lt;= MILLISECONDS_IN_HOUR){ LIMIT_LABEL_CNT = 12; INT_LBL_UNITS = "MINUTES"; }else if(timeDiffInMillis &gt; MILLISECONDS_IN_HOUR &amp;&amp; timeDiffInMillis &lt;= MILLISECONDS_IN_DAY){ LIMIT_LABEL_CNT = 12; INT_LBL_UNITS = "HOURS"; }else if(timeDiffInMillis &gt; MILLISECONDS_IN_DAY &amp;&amp; timeDiffInMillis &lt;= MILLISECONDS_IN_WEEK){ LIMIT_LABEL_CNT = 7; INT_LBL_UNITS = "DAYS"; }else if(timeDiffInMillis &gt; MILLISECONDS_IN_WEEK &amp;&amp; timeDiffInMillis &lt;= MILLISECONDS_IN_MONTH){ LIMIT_LABEL_CNT = 4; INT_LBL_UNITS = "WEEKS"; }else if(timeDiffInMillis &gt; MILLISECONDS_IN_MONTH &amp;&amp; timeDiffInMillis &lt;= MILLISECONDS_IN_YEAR) { LIMIT_LABEL_CNT = 12; INT_LBL_UNITS = "MONTHS" } if(chartDP.length &lt;= LIMIT_LABEL_CNT) incrCounter = 1; else incrCounter = chartDP.length/LIMIT_LABEL_CNT; var i:int=0; for(i=0,arrIndx=0; i&lt;chartDP.length; i=i+incrCounter){ arrIndx = i; _categoryValues[arrIndx] = chartDP.getItemAt(i).timeStamp; dataMap[arrIndx] = chartDP.getItemAt(i); //There is a very good chance for the incrCounter to omit //the last items in the DataProvider. if((chartDP.length-i) &lt;= incrCounter){ arrIndx=arrIndx+incrCounter; _categoryValues[arrIndx] = chartDP.getItemAt(chartDP.length-1).timeStamp; dataMap[arrIndx] = chartDP.getItemAt(chartDP.length-1); } } var min:Number = -_padding; var max:Number = _categoryValues.length - 1 + _padding; var alen:Number = max - min; var label:AxisLabel; var n:int = _categoryValues.length; if (_labelFunction != null) { var previousValue:Object = null; for (i=0; i&lt;n; i++) { if (_categoryValues[i] == null) continue; if(previousValue != null &amp;&amp; _categoryValues[i] != null){ if(previousValue == _categoryValues[i]) continue; } label = new AxisLabel((i - min) / alen, _categoryValues[i], timeLblFormatFunction(_categoryValues[i], previousValue, this, dataMap[i])); _labelsMatchToCategoryValuesByIndex[i] = label; axisLabels.push(label); previousValue = _categoryValues[i]; } } else { for (i = 0; i &lt; n; i++) { if (!_categoryValues[i]) continue; label = new AxisLabel((i - min) / alen, _categoryValues[i], _categoryValues[i].toString()); _labelsMatchToCategoryValuesByIndex[i] = label; axisLabels.push(label); } } } _labelSet = new AxisLabelSet(); _labelSet.labels = axisLabels; _labelSet.accurate = true; _labelSet.minorTicks = minorTicks; _labelSet.ticks = generateTicks(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload