Posts Tagged ‘chart’

Column Chart v.s. Bar Chart

Wednesday, October 1st, 2008

Well, it was confusing. I was thinking bar charts and column charts were doing the same thing. The distinct appearance of them is the direction of the “bar”. Actually, you could call columns “bars” if you want. Thus, I event didn’t get this critical idea that a bar chart CANNOT draw bars vertically. You know what? I struggled with this for hours. Finally I realized it.

So, please remember:
A Column Chart is showing number of columns vertically, which seems to “stand” on the horizontal axis.
A Bar Chart is showing number of bars horizontally, like a rotation column chart.
However, they are logically different.

Hide Chart Elements

Sunday, August 24th, 2008

First of all, a visual chart, generated via Flex-Charting framework, is constructed with many layers of elements. They are series(data) layer, axis layer, background elements and annotation elements. Besides, you are able to create your own chart elements by implementing IChartElement2 interface.

Here are some quick tips:

  • To kill the grid lines behind charts:
    backgroundElements=[]
  • To make the grid lines drawn with larger interval:
    GridLines#horizontalChangeCount = larger_number;
  • hide elements of axises
    AxisRenderer#showLabels = false;
    AxisRenderer#showLine = false;
    AxisRenderer#tickPlacements = "none";

用Filter Function作簡單線性圖Drill-Down

Monday, July 28th, 2008

首先,想像有一張線性圖(Line Chart),上頭的線是由許多資料點所構成。在Flex中,一旦對該資料及和作了過濾的動作,圖表會重繪。然後,Flex3的圖表都有支援selectedItems:Array的方法,以獲取你圈選的資料點,因此,我們可以藉由選取的資料點,得到一個範圍,利用範圍來過濾原資料集合,就可以做到類似Drill-Down的功能了。

這是範例(線性圖的drill down)
這是原始碼


Drill down into data in a line chart.

With Flex3 data visualization package, we are able to get the selectedItems by

ChartBase.selectionMode = "multiple";<br/>ChartBase.selectedItems

Therefore, it is handy to measure a range for filtering out our data. We have to know that every series in a chart contains a data provider. The data providers are ListCollectionView objects. So to filter out those objects will update the display of chart immediately. Those lines will be redrawn. You could see the line scaled just like drilling-down into it.

Here is a sample and source code.
Simple Drill Down into Line Chart
Source

提昇Flex圖表效能

Friday, July 25th, 2008

提昇Flex圖表元件 (Charting Components) 的效能,當你遇到圖表元件的繪製速度慢到想殺人的時候,建議你先從資料開始檢查,再看看圖表元件本身。

  • 如果可以,移除掉圖表效果,像是陰影
    ChartBase.seriesFilters=[]

  • 圖表的data-provider別餵太複雜的物件,尤其是很肥大的XML應該盡量避免,真的必要,可以作adapter物件來繪製之。
  • 當需要畫出很多條不同的資料線時,不要來一筆資料餵一次series (chartBase.series),能的話,讀完了再一次餵,因為一旦執行
    ChartBase.series = your_new_series_list

    會逼迫ChartBase重繪*所有的*的視覺元件,包含標籤、矩陣線、圖表線、軸線…等,很恐怖唷!尤其是你的資料又長到個不行時,老闆不開心、自己也難過。

  • 作線性圖( Line Chart )時,別輕易地變更線的樣式,尤其”form”, “miter”, “joint”這幾個,你可以看看官方的原始碼,對於這些屬性有非常不同的繪製演算法。用預設值吧,我相信Flex開發團隊已經先最佳化過了。
  • Gutter (gutter top, left, right, bottom) 能的話先給預設值,可以省下運算時間
  • 小心使用軸線的單位(unit),針對你的資料多寡,給予適當的單位值,如果你的資料有一千年,把單位切成秒數就不是個明智的作法。

以下是本文的英文版:

Enhance Flex Charting Components Performance

  • Clear the beautiful shadows or any other filters.
    ChartBase.seriesFilters=[]
  • Optimize your data objects to be rendered. Do not pass a bunch of huge, complex objects to the data-provider.
  • While building a line chart, do NOT change the lineStroke attributes such as “miter”, “joint” if not necessary. Flex Data-Visualization components has optimized the drawing performance to default renderers. To change these attributes may bring up a terrible risk.
  • You can remove the grid lines.
  • Set explicit gutter values while defining a chart base object.
  • If you have to render multiple series in a single chart, try to finish loading all data-providers before you assign series list to chart. Calling this method:
    ChartBase.series = your_list

    will force the chart to remove *ALL* chart elements( label, grid, axis, series items…) and re-create them. It is really time consuming to refresh the chart if re-assign the series objects again and again.

  • Set a lower quality of your flash movie( not available for AIR)
  • Mind your axis units. Be very careful while showing up a time-based data set. It is very possible to be the key to skew up your chart performance if the unit is set too small. Given an appropriate unit is highly recommended.