AS per your requirement, you could follow the below mentioned steps:
a. Call your own PHP function on "onClick" event of HTML anchor tag, which will generate the required XML (as you have already done).
b. Then call another function (after generating required XML string) which will generate the chart using the provided XML data, in "renderChart()" method.