은 내가 여기 해결책을이 답변을 내놓고있어 : http://jsfiddle.net/asgallant/6Y8jF/2/
요점은 구글의 전설을 숨기고 자신을 구축하는 것입니다. 먼저, chart.draw
의 옵션 중 하나로 legend: {position: 'none'}
을 전달하여 기본 제공 범례를 사용 중지합니다.
차트의 홀더 div를 만드는 addDiv
함수에서 범례를 보유 할 두 번째 요소를 추가하십시오.
.chart-chart {
float: left;
}
.chart-legend {
margin: 30px 0 0 0;
float: left;
list-style: none;
}
div.legendMarker {
height: 1em;
width: 1em;
display: inline-block;
margin: 0 5px 0 0;
}
이 나오지 않았어 때문에 : 당신은뿐만 아니라 바이올린에서 CSS를 포함해야합니다, 물론
function drawChart(chart, original_table,
x_attr, y_attr, x_axis_lbl, y_axis_lbl, x_min_max,
div_id) { //pass div_id to this function to be able to get legend element
var google_table = allSeriesToGoogleTable(original_table,
x_attr, y_attr, ranking_titles);
var colors = ["#3366cc","#dc3912","#ff9900"]; //use whatever colors you like
var options = {'chartArea':{width:"60%"},
vAxis: {'title': y_axis_lbl}, 'hAxis': {'title': x_axis_lbl},
'interpolateNulls':true,
colors: colors, //use the same colors for the chart and the legend
legend: {position: 'none'} //hide default legend
};
var legend = $('#legend_' + div_id);
for (var i = 1; i < ranking_titles.length; i++) {
var li = $('<li></li>'),
marker = $('<div class="legendMarker"></div>'),
explanation = $('<span></span>');
explanation.text(ranking_titles[i]); // legend marker text
marker.css({backgroundColor: colors[i-1]}); //marker color
li.append(marker).append(explanation);
legend.append(li);
}
if (! x_min_max === undefined)
//do something
chart.draw(google_table, options);
// add the data table to the chart
chart.google_table = google_table;
}
:
function addDiv(parent_id, div_id) {
$("#" + parent_id).append('<div id="' + div_id + '" class="chart-chart"></div><ul id="legend_' + div_id + '" class="chart-legend"></ul>');
}
그런 다음 drawChart
기능에, 전설 구축 코드를 바이올린에 넣지 않아도이 코드는 테스트되지 않았지만 99 %의 코드가 있어야합니다.
당신은 ([대표/최소] (http://sscce.org/)) [라이브 데모] (HTTP 제공 할 수있는 경우 : // jsfiddle을 .net /), 우리는 아마도 당신을 도울 수있을 것입니다. 덧붙여, 대표 코드 *를 여기에 올리십시오. 미래 방문객을위한 사용을 유지하기 위해 가능한 한 자기 포함 된 것으로 질문하십시오. –
@DavidThomas JSFiddle을 사용하여 XML 데이터 파일을 업로드하는 방법을 잘 모르겠습니다. http://colorfulengineering.org/test.html이 버전에는 마우스 오버 이벤트가 있지만, 전설에 마우스를 올리면 언제든지 충돌합니다. – user
Chrome v21 Ubuntu에서 오류 또는 충돌이 발생하지 않습니다. – dennmat