This project is read-only.

FoxCharts ERs

Jul 2, 2008 at 11:44 PM
Hi Cesar.

I've been playing with FoxCharts and really like what I see so far! I have a couple of enhancement suggestions:

  • Allow rotation of the X axis labels. If you have many bars and long labels, they overlap, so rotating them to something like 45 degrees would be nice.
  • Allow a format for the values displayed when ShowValuesOnShapes is .T. For example, I might like to display them as "$999,999".
  • Handle currency values. Right now, an error occurs when DrawBarChart (and likely other methods) draws a bar if the values field is a currency rather than numeric. The developer can handle this by casting their values field but it would be better to handle it in FoxCharts and not give an error.

Doug

Jul 6, 2008 at 4:34 AM
Hi DOug,
Thanks for testing and for your suggestions.



DougHennig wrote:
Hi Cesar.

  • Allow rotation of the X axis labels. If you have many bars and long labels, they overlap, so rotating them to something like 45 degrees would be nice.
How would you prefer this ? Allowing users to use any angle or giving only some predefined angles ? At this moment, the test is centered in the horizontal. If I allow users to choose the angle "zero" the test will not be centered any more. I'm thinking of allowing maybe some predefined positions, such as:
0 - Centered horizontal
1 - Horizontal, left aligned
2 - 22 degrees
3 - 45 degrees
4 - 90 defrees (vertical)

Any ideas ?




  • Allow a format for the values displayed when ShowValuesOnShapes is .T. For example, I might like to display them as "$999,999".
GREAT idea !
Some people also asked me to allow showing values in percentages



  • Handle currency values. Right now, an error occurs when DrawBarChart (and likely other methods) draws a bar if the values field is a currency rather than numeric. The developer can handle this by casting their values field but it would be better to handle it in FoxCharts and not give an error.


Believe me, I had never thought we could work with currency valuesThere are still lots of things in VFP that I still have to learn  :-D Thanks, I presume that using a simple CAST command this can be solved.


Thanks a lot, I'm converting this to a work item, and I hope to add these features in the next version !
Jul 15, 2008 at 3:41 PM
Hi Doug,

I've made the modifications in FoxCharts regarding your suggestions.

  • Rotation and Formatting:

    Now EVERY label has two new properties: Rotation and Format. "Rotation" allows you to choose any angle, and "Format" will receive the format mask that is used by the TRANSFORM() function to convert the values. So you can put in that property: "@!" for uppercase, "@$" for currency, "$.$$$.99" for more specified output, eg $1.238,50

  • Handle Currency values:

    During the class initialization, all values (numbers, integer or currency) are converted to number, according to the source cursor configuration. I used AFIELDS() to get this information. If you want to apply any formatting, then you should set the "format" property of the Legend.




    I've created a new "Planned Release" not yet published, but that can be accessed from here. Maybe you or anyone else could give it a try ? The sample "ChartsSample_new" makes it very easy for performing this test.

    http://www.codeplex.com/VFPX/Release/ProjectReleases.aspx?ReleaseId=15318

    Thanks !
  • Jul 17, 2008 at 10:50 PM
    Edited Jul 17, 2008 at 10:54 PM
    Hi Cesar.

    Thanks for the changes. The Format property works great; not only do the values display properly, I no longer have to use a CAST statement to convert currency values to numeric.

    Rotation also works well, although it would also be nice to specify where the rotation occurs. Currently, rotation occurs at the upper left corner of the object. I might want rotation to occur at the upper right corner instead; that is, I might want to use this in _Legend._DrawString:

    loPointF = .PointF.New(x1 + This._Width, y1) && this is the point of rotation

    Perhaps you could add a RotateFrom property with 0 = upper left (the default), 1 = upper right, 2 = lower left, and 3 = lower right, or something like that.

    Rotation at larger angles causes an issue with the placement of the XAxis label. Try setting it to 200 for example and see where that label goes. At 270, the bottom of the chart is drawn outside the image so it isn't visible.

    Another issue: you made the BaseClass property of _Legend and _LegendRotate hidden. This causes a problem in the latest version of ThemedControls, which has code that loops through the controls on a form, looking at BaseClass of each to decide what to do. Since BaseClass is hidden, the code causes an error. I made BaseClass public in both of those classes to eliminate that problem.

    One last issue: for some reason, I only see the first character of the side legend values. For example, I dropped a FoxChart object onto a form, named it oChart, and put the following code into the Init of the form:What I see when I run the form is the legend with "B" instead of "Beverages" and so on. It looks like the image is sized larger than the container or the calculations for the position of the legend aren't right. This worked fine in the previous release.

    with This.oChart as FoxCharts of 'FoxCharts\Source\FoxCharts.vcx'

    * Set some fixed properties for the chart object.

     .BackColor          = rgb(255, 255, 255)
     .SubTitle.Caption   = ''
     .ShowValuesonShapes = .T.
     .AlphaChannel       = 128
     .BrushType          = 2 && gradient brush
     .ColorType          = 0 && basic colors

    * Execute the SQL for the chart.

     open database home() + 'Samples\Northwind\Northwind'
     select Categories.CategoryName, ;
       sum(OrderDetails.UnitPrice * OrderDetails.Quantity) as Sales ;
      from Products ;
       join Categories on Products.CategoryID = Categories.CategoryID ;
       join OrderDetails on Products.ProductID  = OrderDetails.ProductID ;
      group by 1 ;
      into cursor ChartData

    * Specify the data source for the chart.

     .SourceAlias = 'ChartData'
     .FieldXAxis  = 'CategoryName'
     .FieldValue1 = 'Sales'
     .FieldLegend = .FieldXAxis

    * Specify the chart type and chart and axis captions.

     .ChartType             = 7
     .Title.Caption         = 'Sales by Product Category'
     .XAxis.Caption         = 'Product Category'
     .YAxis.Caption         = 'Total Sales'
     .XAxisLegend2.Rotation = 45
     .ScaleLegend.Format    = '@$ 9,999,999.99'
     .ShapeLegend.Format    = '@$ 9,999,999.99'

    * Draw the chart.

     .DrawChart()
    endwith


    Doug
    Jul 23, 2008 at 9:46 PM
    Thanks again Doug,

    Your inputs are very much apreciated.

    - About the labels rotation, I'm thinking this way:
    The point of rotation will be associated to the "Alignment" property of the object.
    For example, if the alignment is set to the left, then the rotation point will be on the left side.

    There will be no need to specify if the rotation will be on the top or at the bottom of the label. The correct is to align at the center of the height, and the "X"  at about 5 pixels. This brings an almost perfect rotation.



    - Base class hidden properties - Thanks, I'm setting "BaseClass" and some other properties to public in order to avoid this error.


    - About the last bug, thanks for sending an easy way to reproduce the error. This will be fixed in the next release too.

    Regards

    Cesar
    Jul 24, 2008 at 6:33 AM
    Edited Jul 24, 2008 at 4:55 PM
    At the "Planned Release" page you can get the fix for the last bugs reported.

    http://www.codeplex.com/VFPX/Release/ProjectReleases.aspx?ReleaseId=15318


    Now FoxCharts will draw Horizontal bar charts too (unfinished).
    Please note that one property name has been changed - "XAxisLegend2" has become just "AxisLegend2"

    Also, for the rotation to appear corectly in the X axis, the alignment property needs to be set to "Left"
    Just add the lines below to your original sample, and it should work as desired:

     

    .AxisLegend2.Rotation
    .AxisLegend2.Alignment