jQuery flot用200%的分数表示认为该值是100% [英] jquery flot draws points in 200% thought it says the value is 100%

查看:92
本文介绍了jQuery flot用200%的分数表示认为该值是100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用flot库绘制图表.这是我的代码:

I am using flot library to draw a chart. this is my code:

function LoadService2() {

    $.getJSON('http://localhost:4025/vmp_webservice.asmx/LoadService2',
      { fromDate: "2014-01-01", toDate: "2014-04-01" })
       .done(function (result) {

           var data = $.map(result, function (arr, key) {
               return { label: key, data: arr };
           });

           chartOptions = {
               xaxis: {
                   min: (new Date(2014, 01, 1)).getTime(),
                   max: (new Date(2014, 04, 2)).getTime(),
                   mode: "time",
                   tickSize: [1, "month"],
                   monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
                   tickLength: 0
               },
               yaxis: {

               },
               series: {
                   stack: true,
                   lines: {
                       show: true,
                       fill: true,
                       lineWidth: 3
                   },
                   points: {
                       show: false,
                       radius: 4.5,
                       fill: true,
                       fillColor: "#ffffff",
                       lineWidth: 2.75
                   }
               },
               grid: {
                   hoverable: true,
                   clickable: false,
                   borderWidth: 0
               },
               legend: {
                   show: true
               },

               tooltip: true,
               tooltipOpts: {
                   content: '%s: %y'
               },
               colors: App.chartColors
           };



           var holder = $('#stacked-area-chart');

           if (holder.length) {
               $.plot(holder, data, chartOptions);
           }
       })
}

这是输入数据:

{
  "default": [
    [
      1390608000000.0,
      0.0
    ],
    [
      1390780800000.0,
      0.0
    ],
    [
      1391040000000.0,
      0.0
    ],
    [
      1391558400000.0,
      0.0
    ],
    [
      1392249600000.0,
      0.0
    ],
    [
      1392595200000.0,
      0.0
    ],
    [
      1392681600000.0,
      0.0
    ],
    [
      1392854400000.0,
      0.0
    ],
    [
      1393286400000.0,
      0.0
    ],
    [
      1393891200000.0,
      0.0
    ],
    [
      1394064000000.0,
      0.0
    ],
    [
      1394236800000.0,
      0.0
    ],
    [
      1394323200000.0,
      0.0
    ],
    [
      1394841600000.0,
      0.0
    ],
    [
      1394928000000.0,
      0.0
    ],
    [
      1395014400000.0,
      0.0
    ],
    [
      1395100800000.0,
      0.0
    ],
    [
      1395273600000.0,
      0.0
    ],
    [
      1395446400000.0,
      0.0
    ],
    [
      1395619200000.0,
      0.0
    ],
    [
      1395705600000.0,
      0.0
    ],
    [
      1395878400000.0,
      0.0
    ],
    [
      1396137600000.0,
      0.0
    ]
  ],
  "direct": [
    [
      1390608000000.0,
      0.0
    ],
    [
      1390780800000.0,
      0.0
    ],
    [
      1391040000000.0,
      0.0
    ],
    [
      1391558400000.0,
      0.0
    ],
    [
      1392249600000.0,
      0.0
    ],
    [
      1392595200000.0,
      0.0
    ],
    [
      1392681600000.0,
      0.0
    ],
    [
      1392854400000.0,
      0.0
    ],
    [
      1393286400000.0,
      100.0
    ],
    [
      1393891200000.0,
      0.0
    ],
    [
      1394064000000.0,
      0.0
    ],
    [
      1394236800000.0,
      0.0
    ],
    [
      1394323200000.0,
      0.0
    ],
    [
      1394841600000.0,
      0.0
    ],
    [
      1394928000000.0,
      0.0
    ],
    [
      1395014400000.0,
      0.0
    ],
    [
      1395100800000.0,
      0.0
    ],
    [
      1395273600000.0,
      0.0
    ],
    [
      1395446400000.0,
      0.0
    ],
    [
      1395619200000.0,
      0.0
    ],
    [
      1395705600000.0,
      0.0
    ],
    [
      1395878400000.0,
      0.0
    ],
    [
      1396137600000.0,
      0.0
    ]
  ],
  "Sales": [
    [
      1390608000000.0,
      100.0
    ],
    [
      1390780800000.0,
      100.0
    ],
    [
      1391040000000.0,
      100.0
    ],
    [
      1391558400000.0,
      100.0
    ],
    [
      1392249600000.0,
      100.0
    ],
    [
      1392595200000.0,
      0.0
    ],
    [
      1392681600000.0,
      75.0
    ],
    [
      1392854400000.0,
      100.0
    ],
    [
      1393286400000.0,
      100.0
    ],
    [
      1393891200000.0,
      100.0
    ],
    [
      1394064000000.0,
      0.0
    ],
    [
      1394236800000.0,
      100.0
    ],
    [
      1394323200000.0,
      0.0
    ],
    [
      1394841600000.0,
      100.0
    ],
    [
      1394928000000.0,
      66.666666
    ],
    [
      1395014400000.0,
      0.0
    ],
    [
      1395100800000.0,
      100.0
    ],
    [
      1395273600000.0,
      0.0
    ],
    [
      1395446400000.0,
      0.0
    ],
    [
      1395619200000.0,
      0.0
    ],
    [
      1395705600000.0,
      0.0
    ],
    [
      1395878400000.0,
      100.0
    ],
    [
      1396137600000.0,
      100.0
    ]
  ]
}

我得到了这个结果:

有200%的值,尽管输入没有此值

there are 200% values although the input doesn't have this value

当我将鼠标悬停在该点上的图表上时,图表告诉我该值是100%,尽管它将其绘制为200%.

when I hover over the charts on that point, the chart told me that the value is 100% though it draws it as 200%.

请帮助

请问如何解决?

推荐答案

您正在堆叠图形

...
series: {
    stack: true,
...

尝试将堆栈设置为false:

Try setting stack to false:

...
series: {
    stack: false,
...

说起来有点困难,因为flot关于其选项的文档并不完美,但这可能会有所帮助.

It's a bit difficult to say as the documentation from flot about their options isn't perfect but this might help.

这篇关于jQuery flot用200%的分数表示认为该值是100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆