Configure legend position and layout

Refer to the following example code to see how to change the position of legend in a chart.