![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
I have done some Googling on this, but frankly I'm not sure what to even search
for. Here is what my boss wants: A month by month chart of sales showing revenue trends as well as projections for then next two months. He wants a solid line for actual data in existing months which turns into a dotted line with projection data for future months. I have downloaded and played with the code from quietly scheming (http://www.quietlyscheming.com/blog/.../dashed-lines/) but it seems to apply to the entire line. I'm not sure if the direction I should be taking is two different line renders based on the category axis, or a way to make the renderer smart enough to change the line at the appropriate time. Thoughts please? Thanks. |
| Sponsored Links |
|
|||
|
Oh, a 3rd option I'm not sure about is if I could have an extra series for the
projection that would only have data during the future months. I'm not sure if I can create a series that only has data for certain months though. |
|
|||
|
how do you keep your data?
are you running the projections based on numbers you have? Then doing the calculations on the client side with flex and actionscript? When i do stuff like that.. I do it on the server side.. then send it to my PC for display... I do some number crunching.. but I do all the data crunching when the usr hits the url... Then i send it as XML for display.. less work for me.. and server side is far faster for stuff like that than the users computer... |
|
|||
|
I'm still playing with this solution, but for what it's worth this is what I am
doing: I downloaded the source from quietly scheming for the dashed line renderer. (http://www.quietlyscheming.com/blog/.../dashed-lines/) I changed the DashedLineSeries to a ProjectionLineSeries and changed the DashedLineRenderer to be ProjectionLineRenderer. Then in the renderer, I changed the updateDisplayList method to loop over the LineSeriesItems (_lineSegment.items array) and find where past meets future. Note: in doing this, I made an assumption that your xValue would be a date to use this series. I then used a combination of the drawPolyLine and drawDashedPolyLine methods from their respective graphics utility classes to draw the applicable portions of the line. Here is the contents of the ProjectionLineRenderer.updateDisplayList method as I have it now. override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { var stroke:IStroke = getStyle("lineStroke"); var form:String = getStyle("form"); var pattern:Array = getStyle("dashingPattern"); pattern = (pattern == null) ? _pattern : pattern; graphics.clear(); var current_date ate = new Date();var beginning_of_month ate = newDate(current_date.getMonth(),1,current_date.getFul lYear()); var projected_items:Array = new Array(); // Loop over the lineseriesitems for(var i:int = 1;i<_lineSegment.items.length;i++) { // Grab the items whose dates are in the future if(LineSeriesItem(_lineSegment.items[i]).xValue = beginning_of_month) { // If this is the first item that is in the future, back // up and grab the previous one so our dotted has a starting point if(projected_items.length == 0 && i > 0) { projected_items.push(_lineSegment.items[i-1]); } // Add the future data points into the projected array projected_items.push(_lineSegment.items[i]); } } // Draw the solid portion of the line. Notice the end point is the size of the entire array, minus the future points. // Adjusted by two because they overlap one point and the array starts at 0. GraphicsUtilities.drawPolyLine(graphics,_lineSegme nt.items,_lineSegment.start ,_lineSegment.end,"x","y",stroke,form); // Draw the dashed portion with the projected_items array DashedGraphicUtilities.drawDashedPolyLine(graphics , stroke, pattern, projected_items); } Technically, I am also assuming that the last data point is the current month, and therefore the projected one. Based on that, the date math is probably unnecessary, but maybe I'll change that later. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise