使用vue,plotly和ajax绘制散点图

时间:2019-01-09 13:49:04

标签: ajax vue.js axios plotly

我是Vue的新手,到目前为止,我很喜欢它。但是,我陷入了需要帮助的问题。直接针对该主题,我不知道将使用Axios调用的Ajax结果传递给变量,以使用https://github.com/statnett/vue-plotly将其呈现到我的散点图中。这是我尝试的方法。

     data () {
           return {
            //flag is defined as an array that I push the ajax response to
           flag:[],
           scatter:{
             data: [{ x: [2, 300,36], y: [200, 400,800] }],
             layout: {'title': String(this.flag)},
             options: {}
           },
      },        
      mounted(){           
        axios.get('http://192.168.1.10:8000/books/api/?format=json')           
          .then(response => (
            this.flag = response
          ))
      } 

当我尝试在布局中使用标志时,它表示未定义。这太奇怪了,怎么可能不定义标志,为什么呢?多谢您的协助。预先感谢。

0 个答案:

没有答案