We have two conditions to decide that we should use data from history instead of trends:
1. the history period of the item has to be longer then half of the selected period;
2. the ratio of the selected period to graph X size must not be larger then the ratio of ZBX_MAX_TREND_DIFF to ZBX_GRAPH_MAX_SKIP_CELL.
The second condition is irrelevant for pie graphs and must be removed. The corresponding code can be found in CPie::selectData().