jQuery浮动,每个点的大小和颜色都不同 [英] jquery flot, varying size and color for each point

查看:55
本文介绍了jQuery浮动,每个点的大小和颜色都不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以更改jquery flot图中点的以下属性吗?

Can we change the following properties of the points in a jquery flot plot:

点的大小:我基本上是在尝试绘制三维图.前两个维是x和y值,第三个维值将反映在点的大小中.值越大,点越大.

the size of dots : I am basically trying to plot a three dimensional graph. First two dimensions are the x and y values and the third dimension value will be reflected in the size of the points. Larger the value, larger the point.

点的颜色:再次,我试图显示x和y值以外的属性.值越大,点越暗.

the color of the dots: Again, am trying to display a property other than the x and y values. larger the value, darker the point.

:我试图控制点的这些属性,而不是整个图.

: I am trying to control these properties for points individually and not for the whole plot.

推荐答案

我现在了解您.我看到的唯一方法是将回调函数传递给点符号选项:

I understand you now. The only way I can see doing this is by passing a callback function to the point symbol option:

function someFunc(ctx, x, y, radius, shadow) 
{
  someFunc.calls++;
   if (someFunc.calls % 2 == 0)
   {
    ctx.arc(x, y, radius * 4, 0, shadow ? Math.PI : Math.PI * 2, false);
   }
   else
   {
     ctx.arc(x, y, radius, 0, shadow ? Math.PI : Math.PI * 2, false);
   }
}
someFunc.calls = 0;

var options = {
  series: {
    lines: { show: true },
    points: { show: true, symbol: someFunc}
  }
};

somePlot = $.plot($("#placeholder"), [ d1 ], options);

在上面,我正在调整其他每个点的半径大小:

In the above I am adjusting the radius size for every other point:

此处示例

这篇关于jQuery浮动,每个点的大小和颜色都不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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