I am using Google visualization chart API to generate a 3d pie chart for different data.
But it seems like an issue in slices colors are fixed. I want to show different colors for Pass, Failure, Errors inside pie chart slices. But I an unable to do so. I am using this below code :
Problem Statement: When I pass zero data i.e. '0' to 'Pass' and 'Failure' column then 'Error' column slices takes the color of 'Pass'. Means which is on the first coloumn will take the color of other ones. I want to fix the color code for each slices, no mater what data is present.
Do any one have expertiese in generating 3d pie chart to help me out or there is an issue with chart API?
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/ jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {'packages':['piechart']});
google.setOnLoadCallback( drawChart);
function drawChart() {
var data = new google.visualization. DataTable();
data.addColumn('string', 'list');
data.addColumn('number', 'Tutorials Pesentage');
data.addRows(5);
data.setValue(0, 0, 'Pass');
data.setValue(0, 1, 0);
data.setValue(1, 0, 'Error');
data.setValue(1, 1, 2);
data.setValue(2, 0, 'Failure');
data.setValue(2, 1,0);
var chart = new google.visualization.PieChart( document.
getElementById('9lessonschart' ));
var options2 = {width: 250, height: 180, is3D: true, title: 'Current Build Activities', slices: {0: {color: '#006EFF'}, 1:{color: '#006EFF'}, 2:{color: '#006EFF'}, 3: {color: '#006EFF'}, 4:{color: 'grey'}}};
chart.draw(data, options2);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="9lessonschart"> </div>
</body>
</html>
댓글 없음:
댓글 쓰기