Fixing issue #8

Very simple fix to prevent Legends from getting created twice. 
I think there could be an issue where the legend is never displayed if the data is initialised asynchronously after the type was set dynamically. I think it'd be better to initialise a flag `legendCreated` when we create the legend and check the flag as you are doing. It removes the need to pass the boolean as an argument. This flag should be scoped to the `link` function.