grafana/grafana — pull request #981 by mbell697 (2014-10-24 19:04:13+00:00)
Title: When get_data fails the legend should be cleared

This fixes what is probably an uncommon edge case I ran into it today:

We have some dashboards that display a bunch of graphs based on a template value, some graphs for some template values don't have any data (the series doesn't even exist in the data source). Currently when switching between template values and landing on one of these situations the graph updates to be empty and displays the error indicator as expected but the legend from the previous template value persists. This can be a bit confusing to the user as they may see current/average/etc values in the legend but a blank and errored graph. This commit clears $scope.legend when get_data fails.

Side note: the same thing happens with annotations as well, the graph errors and goes black but annotations persist, I poked at that code a bit but it seems that annotations are cached in the graph directive so there wasn't a clean path to clear them out from the controller. It's also probably not as much of an issue that the annotation persist as they are still 'correct'.