double toDataX(double canvasX) { if (width == 0) return dataMinX; return dataMinX + (canvasX - left) / width * (dataMaxX - dataMinX); }