如何解决阻止加载图形的错误("TypeError: popover is not a function")?



update :看来,通过在html文件本身中包括bootstrap.min.js来解决所有内容,由于其他因素的组件没有被它们访问)。除非其他人可以这样做,否则我会作为答案发表答案(我可能不明白这个问题。

我正在尝试使用web2py测试一个简单的指标图示例,但浏览器中没有图形加载。

当前错误阻止图形显示:

TypeError: $(args.target+' h2.chart_title').popover is not a function. (In '$(args.target+' h2.chart_title').popover', '$(args.target+' h2.chart_title').popover' is undefined)

错误发生在MetricsGraphics.min.js

html文件:

{{extend 'layout.html'}}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script src="{{=URL('static','js/d3/d3.min.js')}}"></script>
<link href="{{=URL('static','js/metric-graphics/css/metricsgraphics.css')}}" rel='stylesheet' type="text/css">
<script src="{{=URL('static','js/metric-graphics/js/metricsgraphics.min.js')}}"></script>

<h3>Graph</h3>
<div class="result text-center col-xs-5">
<script>
 data_graphic({
  title: "UFO Sightings",
  description: "Yearly UFO sightings from 1945 to 2010.",
  data: [{'year':1964, 'sightings':6}] // JSON.parse({{=sample}}), // also tried as JSON.parse([{"year":1945, "sightings":"6"}])
  markers: [{'year': 1964, 'label': '"The Creeping Terror" released'}],
  width: 600,
  height: 250,
  target: ".result",
  x_accessor: "year",
  y_accessor: "sightings",
});
</script>
{{#=BEAUTIFY(response._vars)}}

python控制器功能:

def chart_view():
    '''This will show the graph for a feed (axes)'''
    # sample = [{"year": "1945", "count": 6}, {"year": "1950", "sightings": 35}, {"year": "1964", "sightings": 6}]
    return dict()

要在视图中写下python对象,必须先用一个等符号:

{{=sample}}

可能还有其他错误,因为尚不清楚您是如何将sample获取的。

相关内容

  • 没有找到相关文章

最新更新