update autocomplete data source and solidify the legend drawing code