Sunday, April 4, 2010

First look on Mirroring and Charts

Couple of quick updates before i elaborate on mirroring.
  1. Flex 4 and Flash builder 4 are up for grabs. You can download them from here
  2. Advanced Data visualization components (which include ADG, ODG and Charts) are now a part of free open source flex sdk.
There's gonna be a follow up version for flex sdk 4.0, which will include layout mirroring feature. This feature is intended to trivialize repurposing a GUI designed for a LTR language, like English, for a RTL language like Hebrew or Farsi. Following Q&As might help you to understand\ picturize the feature better. I have focussed on its impact on charts.

Q: How can I set the layout for a RTL language?
A: The mirroring API is defined by a new interface called ILayoutDirectionElement. The interface defines the layoutDirection property whose value can be "ltr" or "rtl". By setting the property value to "rtl", at the application (root) level , the layout will be mirrored.

Q: Can i set layoutDirection at component\container level, instead of setting it at application(root) level?
A: Yes. For example, you can set layoutDirection for ColumnChart by using this code

Q: How would a chart look in a RTL layout?
A: Sample image of a line chart with DateTimeAxis whose layoutDirection is set to RTL is shown below

Q: layoutDirection for the Application is ltr , and layoutDirection for chart is set as rtl. Is this a valid scenario? How would the application look at the runtime?
A: Yes. It is a valid scenario. Only the chart will be mirrored and not the application. Hence, the chart will be on the left hand side at the run time. An HLOC chart for the above scenario is shown below
Q: When layoutDirection is set to rtl, what will be the text allignment of the text in the datatip for a chart?
A: Text alignment in the datatip depends on the style "direction". If we want the text inside the datatip to be right aligned, we should set the direction to "rtl" as given below. This is independent of layoutDirection.
Comments\feedback are welcome.


Monday, January 11, 2010

How to set timezone manually for php

Recently, i was trying to fetch some data which had date in it, using XAMPP 1.7.2 and FlashBuilder 4 , and I faced the error given below.

InvocationTargetException:There was an error while invoking the operation. Check your server settings and try invoking the operation again.
Reason: Server error DateTime::__construct() [
datetime.--construct]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Calcutta' for '5.5/no DST' instead #0

To overcome this, we have to manually set the timezone. Explanation is given below.
Since PHP 5.1, there has been an extension named 'date' in the PHP core. This is the new implementation of PHP's datetime support. Although it will attempt to guess your system's timezone setting, you should set the timezone manually. You can do this in three ways :
1) in your php.ini using the date.timezone INI directive
2) on your system using the TZ environmental variable
3) from your script using the convenience function date_default_timezone_set()

I chose the step 3 to make things work. Since i reside in India, i added the below line in my php service.
  • date_default_timezone_set('Asia/Calcutta');
For other countries, timezones can be found here
Below links can be useful for further understanding, which i have used as references.