简体   繁体   English

Ember.js中的Google图表呈现

[英]Google chart rendering in Ember.js

Hey please can any one help me to solve this problem. 嘿,任何人都可以帮我解决这个问题。 my View is 我的看法是

<div id="sankey_multiple" style="width: 900px; height: 300px;"></div>

my Component.js is 我的Component.js是

App.sankeyComponent = Ember.Component.extend({
    needs: ['sankey'],
    //navigation: Ember.computed.alias('controllers.navigation'),
    isExpandedBookmarks: false,
    didInsertElement: function() {
       alert('insert');
    }
});

But didInsertElement function is not working I am not getting where exactly I need to add the google chart scripts. 但是didInsertElement函数无法正常工作,我无法准确地添加Google图表脚本。

If I add it in init function it says container not found. 如果我将其添加到init函数中,则表示找不到容器。 So I thought we need to add after didInsertElement. 所以我认为我们需要在didInsertElement之后添加。 But its not working. 但是它不起作用。 Can any one help me out in this ? 有人可以帮我吗? thank you in advance. 先感谢您。

Ember expects the naming convention for components to have a leading capital, so you should change your component as follows: Ember希望组件的命名约定具有大写的字母,因此您应按以下步骤更改组件:

App.SankeyComponent = Ember.Component.extend({
    needs: ['sankey'],
    //navigation: Ember.computed.alias('controllers.navigation'),
    isExpandedBookmarks: false,
    didInsertElement: function() {
       alert('insert');
    }
});

Also, I am not sure whether the view you posted is the view where you are trying to consume your component or the view for your component itself. 另外,我不确定发布的视图是尝试使用组件的视图还是组件本身的视图。 These should be set up as possible: 这些应尽可能设置:

The definition for your component: 组件的定义:

<script type="text/x-handlebars" id="components/sankey-component ">
    <!-- HTML for your component -->
</script>

Show the component in a view as follows: 在视图中显示组件,如下所示:

{{sankey-component}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM