double currentX = minX;
while (currentX <= maxX) {
x = chartRect.x + (int) ((currentX - minXVal) * dxForDVal);
int yHeight = (int) ((cs.interpolate(currentX) - minYVal) * dyForDVal);
y = chartRect.y + chartRect.height - yHeight;
//prevent out of range
if (y < chartRect.y) {
y = chartRect.y;