\t google.charts.load('current', {packages: ['corechart']});
\t google.charts.setOnLoadCallback(draw_chart); \t
\t function draw_chart() {
\t \t // Create DataTable object from DataTable constructor or arrayToDatable()
\t \t var data = new google.visualization.DataTable({"rows":[{"c":[{"v":"Sacramento"},{"v":97},{"v":79},{"v":67},{"v":100}]},{"c":[{"v":"Montpelier"},{"v":96},{"v":74},{"v":32},{"v":96}]},{"c":[{"v":"Juneau"},{"v":24},{"v":44},{"v":54},{"v":64}]},{"c":[{"v":"Montgomery"},{"v":26},{"v":69},{"v":51},{"v":56}]},{"c":[{"v":"Little Rock"},{"v":87},{"v":69},{"v":78},{"v":41}]}],"cols":[{"type":"string","id":"cities","label":"cities"},{"type":"number","id":"A","label":"A"},{"type":"number","id":"B","label":"B"},{"type":"number","id":"C","label":"C"},{"type":"number","id":"D","label":"D"}]});
\t \t // Add formatters, if any
\t \t // Create ChartWrapper
\t \t var my_chart = new google.visualization.ChartWrapper({
\t \t \t "containerId": "chart_id",
\t \t \t "dataTable": data,
\t \t \t "chartType": "ColumnChart",
\t \t \t "options": {"bar": {"groupWidth": 67}, "chartArea": {"width": 440, "top": 20, "height": 295, "left": 60}, "height": 375, "width": 500, "fontSize": 12, "legend": "none"}
\t \t });
\t \t var bar_rect_set;
\t \t var num_rows = 5;
\t \t var num_cols = 4;
\t \t var num_series = num_rows * num_cols;
\t \t var parent_g;
\t \t \t
\t \t function get_bar_rect_set() {
\t \t \t // get all the rects in the parent except for the white outline rects
\t \t \t // on selected bars, if any.
\t \t \t bar_rect_set = parent_g.find('rect[fill!="#ffffff"]'); \t \t \t \t
\t \t }
\t \t google.visualization.events.addOneTimeListener(my_chart, 'ready', function() {
\t \t \t // Get an initial collection of the bar rects, along with their parent.
\t \t \t // Hereafter, get the bar rects with the method above.
\t \t \t \t \t \t \t
\t \t \t // get all rects three layers down, including gridlines and axis
\t \t \t var g_set_1 = $("svg g g g rect");
\t \t \t // slice out the gridlines at the beginning and the axis line at the end
\t \t \t bar_rect_set = g_set_1.slice(g_set_1.length - num_series - 1, g_set_1.length - 1);
\t \t \t parent_g = $(bar_rect_set[0]).parent();
\t \t });
\t \t \t
\t \t my_chart.draw();
\t \t function highlight_bars(series_num) {
\t \t \t if (series_num > num_cols - 1) {
\t \t \t \t return false;
\t \t \t }
\t \t \t get_bar_rect_set();
\t \t \t var start_index = series_num * num_rows;
\t \t \t var end_index = start_index + num_rows;
\t \t \t var series_g_set = bar_rect_set.slice(start_index, end_index)
\t \t \t var styles = {'stroke-width': "1.5px", "stroke": "#AAAAAA", "opacity": .8};
\t \t \t series_g_set.css(styles);
\t \t }
\t \t \t
\t \t function remove_highlight() {
\t \t \t var styles = {'stroke-width': "0", "opacity": 1};
\t \t \t bar_rect_set.css(styles);
\t \t }
\t \t
\t \t $("#legend tr").each(function(index, row) {
\t \t \t $(row).mouseover(function() {
\t \t \t \t highlight_bars(index);
\t \t \t }).mouseout(function() {
\t \t \t \t remove_highlight();
\t \t \t });
\t \t });
\t }
\t .color_bar {
\t \t width:24px;
\t \t height:12px;
\t \t margin-right:5px;
\t \t vertical-align:middle;
\t }
\t #legend td {
\t \t font-size:12;
\t \t height:19px;
\t \t font-family:"Arial";
\t }
\t <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
\t <script src="https://www.gstatic.com/charts/loader.js"></script>
\t <table id="legend">
\t \t <tr>
\t \t \t <td><div class='color_bar' style="background-color:#3366cc"></div></td>
\t \t \t <td>A</td>
\t \t </tr>
\t \t <tr>
\t \t \t <td><div class='color_bar' style="background-color:#dc3912"></div></td>
\t \t \t <td>B</td>
\t \t </tr>
\t \t <tr>
\t \t \t <td><div class='color_bar' style="background-color:#ff9900"></div></td>
\t \t \t <td>C</td>
\t \t </tr>
\t \t <tr>
\t \t \t <td><div class='color_bar' style="background-color:#109618"></div></td>
\t \t \t <td>D</td>
\t \t </tr>
\t </table>
\t <div id="chart_id" ></div>
Sie könnten versuchen, [Brennen der ' 'mouseover'' Ereignis manuell] (https://developers.google.com/chart/interactive/docs/dev/events#firing-an -event) ... – WhiteHat
@WhiteHat, ich habe versucht, verschiedene Aufrufe von 'google.visualization.events.trigger (myChartWrapper.getChart(), 'onmouseover', {}) aufzurufen;' aber das war ich nicht alles überhaupt passieren lassen. Weißt du, wie man es feuert? – broccoli2000
Obwohl ich das Ereignis auslösen konnte, wurde _focus_ nicht angezeigt. Ich kann als Antwort hinzufügen, wenn interessiert ... – WhiteHat