NGINX URL redirect matching a specific rule

I am not new to nginx but unfortunately never understood well the redirect/rewrite rules.
I have a dilemma and already tried what I know with no success.

What I want is a simple URL rewrite/redirect, when I type in browser bar:
https://example.com/chart.php?id=1234
the URL to automatically transform into the following and ofc showing the same content as original:
https://example.com/chart/1234

I already tried in many ways ex:

location /chart/{
      rewrite ^chart/((0-9)+)/?$ chart.php?id=$1 break;
      proxy_pass  _to_apache;
    }

Many thanks in advance!