Круговая диаграмма Jqplot, отображающая только линии - PullRequest
0 голосов
/ 02 марта 2012

Я загружаю jqplot соответствующие файлы динамически и передаю данные в div и chart, но иногда получаю график, а в другой раз не получаю график, мой код выглядит следующим образом: я сделал ajax-вызов, чтобы получить значения и передать их график в объекте st и вывод, который я получаю, показан здесь http://i43.tinypic.com/wcfns0.png, пожалуйста, помогите мне функционировать

jsFunction3(xyz) {
 jQuery.getCSS = function( url, media )
 {
 jQuery( document.createElement('link') ).attr({ href: url, media: media || 'screen', type: 'text/css', rel: 'stylesheet' }).appendTo('head'); };

 $.getCSS('/redkanproject/plugins/jqplot-0.1/css/jqplot/jquery.jqplot.css','print'); 
 $.getScript('/redkanproject/plugins/jqplot-0.1/js/jqplot/jquery.jqplot.min.js', 

function() { }); $.getScript('/redkanproject/plugins/jqplot-0.1/js/jqplot/excanvas.min.js', function() { });
 $.getScript('/redkanproject/plugins/jqplot-0.1/js/jqplot/plugin/jqplot.pieRenderer.min.js', function() { }); 

var JSONObject = new Object; 
JSONObject.id =xyz;
 JSONstring = JSON.stringify(JSONObject); 
var url = "${createLink(controller:'page', action:'example4')}"; new Ajax.Request(url, { method:'post', contentType:'application/json', postBody:JSONstring, asynchronous:true, onSuccess: function (res) { 
st=(res.responseJSON)
 x="chart" // this is my div to display chart 
var plot1 = $.jqplot (x, [st], { title: 'Bianual Reviews percentage', grid: {
background:'#834100', shadow: true,borderWidth: 0, borderColor: 'white',shadowDepth: 0}, seriesDefaults: {
 // Make this a pie chart. 
renderer: $.jqplot.PieRenderer, rendererOptions: { 
// Put datalabels on the pie slices. 
// By default, labels show the percentage of the slice. 
sliceMargin:6,
showDataLabels: true
 }
 },
 legend: { show:true, location: 'e' } } ); 
$(x).bind('jqplotDataClick', function(ev,seriesIndex, pointIndex, data) 
{ alert(" data: "+data); } 
);
 } 
})//ajax }
------------------------------------------------------------------------

1 Ответ

1 голос
/ 06 мая 2012

У меня была похожая проблема, и оказалось, что у меня есть глобальный стиль для элемента таблицы, который устанавливает ширину на 100%. например,

table{
width:100%
}

Я изменил это на авто, и все отображается правильно

table{
width:auto;
}

Надеюсь, это поможет: -)

...