Created
January 27, 2011 18:40
-
-
Save tripp/798960 to your computer and use it in GitHub Desktop.
YUI3 Chart Selected State Workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var selectedMarker; //reference to highlighted marker | |
outchart.subscribe("markerEvent:click", function(e) { | |
var series = e.series, //will need series to get markers array | |
index = e.index, //index of the marker in the series' marker array | |
markers = series.get("markers"), //array of marker for the series | |
marker = markers[index], //get the marker from the markers array | |
selectedSeriesIndex, //will be used to determine the series of the selectedMarker | |
selectedSeries, //series of the selectedMarker | |
color; //default color for the selectedMarker | |
if(selectedMarker) | |
{ | |
selectedSeriesIndex = selectedMarker.node.getAttribute("id").split("_")[1]; | |
selectedSeries = outchart.getSeries(parseInt(selectedSeriesIndex, 10)); | |
color = selectedSeries.get("styles").marker.fill.color; | |
selectedMarker.update({fill: { color: color}}); | |
} | |
marker.update({fill:{color:"#f00"}});//update the marker's color | |
selectedMarker = marker; //update the selectedMarker to reflect changes | |
}); | |
//reset the the marker to you selected color after a mouseout | |
outchart.after("markerEvent:mouseout", function(e) { | |
if(selectedMarker) | |
{ | |
selectedMarker.update({fill: {color:"#f00"}}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment