search

Home  >  Q&A  >  body text

javascript - chart.js如何使用动态数值?

<script>

    var lineChartData = {
        labels : ["January","February","March","April","May","June","July"],
        datasets : [
            {
                fillColor : "rgba(220,220,220,0.5)",
                strokeColor : "rgba(220,220,220,1)",
                pointColor : "rgba(220,220,220,1)",
                pointStrokeColor : "#fff",
                data : [65,59,90,81,56,55,40]
            }这里面的数据如何实现动态传值,如果我们的值是从数据库取得怎么传过去?
PHP中文网PHP中文网2835 days ago309

reply all(5)I'll reply

  • PHPz

    PHPz2017-04-10 16:41:25

    ajax吧,简单粗暴。

    reply
    0
  • PHPz

    PHPz2017-04-10 16:41:25

    js代码用后台程序动态生成就可以啦

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-10 16:41:25

    http://segmentfault.com/a/1190000004106175 是个echarts 动态获取的,原理应该一样。

    demo地址:http://cuihuan.net:1015/demo_file/echarts_realtime_demo/demo.html

    reply
    0
  • 高洛峰

    高洛峰2017-04-10 16:41:25

    么个对应一个变量,想修改时直接修改变量。

    reply
    0
  • 怪我咯

    怪我咯2017-04-10 16:41:25

    用双向绑定策略?

    reply
    0
  • Cancelreply