2015-05-13 5 views
0

я пытаюсь из jqplot просто использовать для гистограмм, но независимо от того, какой пример я стараюсь, я не получаю эту ошибку в консоли:Не удается прочитать свойство «BarRenderer» неопределенной

«Не удается прочитать свойство«BarRenderer 'undefined'

Я сделал поиск в Google и не могу найти что-либо на этом, и я не понимаю .. любая помощь была бы замечательной. Я использую asp.net MVC 4

@{ 
    ViewBag.Title = "View1"; 
} 

<h2>View1</h2> 

<script src="~/Scripts/jqPlot/jquery.min.js"></script> 
<script src="~/Scripts/jqPlot/jquery.jqplot.min.js"></script> 
<script src="~/Scripts/jqPlot/plugins/jqplot.barRenderer.min.js"></script> 
<script src="~/Scripts/jqPlot/plugins/jqplot.categoryAxisRenderer.min.js"></script> 
<script src="~/Scripts/jqPlot/plugins/jqplot.pointLabels.min.js"></script> 
<link href="~/Scripts/jqPlot/jquery.jqplot.css" rel="stylesheet" type="text/css"> 


<div id="chart1" style="height:400px;width:300px; "></div> 

<script> 
    $(document).ready(function() { 
     var s1 = [200, 600, 700, 1000]; 
     var s2 = [460, -210, 690, 820]; 
     var s3 = [-260, -440, 320, 200]; 
     // Can specify a custom tick Array. 
     // Ticks should match up one for each y value (category) in the series. 
     var ticks = ['May', 'June', 'July', 'August']; 

     var plot1 = $.jqplot('chart1', [s1, s2, s3], { 
      // The "seriesDefaults" option is an options object that will 
      // be applied to all series in the chart. 
      seriesDefaults: { 
       renderer: $.jqplot.BarRenderer, 
       rendererOptions: { fillToZero: true } 
      }, 
      // Custom labels for the series are specified with the "label" 
      // option on the series option. Here a series option object 
      // is specified for each series. 
      series: [ 
       { label: 'Hotel' }, 
       { label: 'Event Regristration' }, 
       { label: 'Airfare' } 
      ], 
      // Show the legend and put it outside the grid, but inside the 
      // plot container, shrinking the grid to accomodate the legend. 
      // A value of "outside" would not shrink the grid and allow 
      // the legend to overflow the container. 
      legend: { 
       show: true, 
       placement: 'outsideGrid' 
      }, 
      axes: { 
       // Use a category axis on the x axis and use our custom ticks. 
       xaxis: { 
        renderer: $.jqplot.CategoryAxisRenderer, 
        ticks: ticks 
       }, 
       // Pad the y axis just a little so bars can get close to, but 
       // not touch, the grid boundaries. 1.2 is the default padding. 
       yaxis: { 
        pad: 1.05, 
        tickOptions: { formatString: '$%d' } 
       } 
      } 
     }); 
    }); 
</script> 

ответ

1

Я воссоздал приведенный выше фрагмент, и он отлично работает. Вы уверены, что все файлы, которые вы включили в начало вашего скрипта, были загружены на ваш сервер? Единственный способ реплицировать вашу ошибку - не загружать «jquery.jqplot.min.js» на мой сервер.

Uncaught TypeError: Cannot set property 'BarRenderer' of undefined(anonymous function) @ jqplot.barRenderer.min.js:57(anonymous function) @ jqplot.barRenderer.min.js:57

+0

я выбрал все файлы вручную (я на самом деле просмотрел в файл непосредственно, чтобы убедиться, что я не принимать или делать орфографические ошибки), поэтому я уверен, что файл есть .. я в конечном итоге с помощью Google, Chart API вместо которой работал , благодарю вас за ответ – user1189352

0

Я столкнулся с такой же проблемой. В основном это связано с проблемой загрузки js. Поместите эти справочные файлы на главную страницу макета

0

Решено, удалив скрипты.Render в нижней части View_Layout.cshtml , поскольку он дважды вызывал jquery.

<div class="container body-content"> 
     @RenderBody() 
    </div> 

    @Scripts.Render("~/bundles/jquery")  <-- remove this line 
    @Scripts.Render("~/bundles/bootstrap")  <-- remove this line 
    @RenderSection("scripts", required: false) <-- remove this line 

    </body> 
    </html> 
Смежные вопросы