jquery flot, varying size and color for each point

一笑奈何 提交于 2020-01-01 09:29:53

问题


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

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.

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.

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


回答1:


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:

EXAMPLE HERE



来源:https://stackoverflow.com/questions/8926513/jquery-flot-varying-size-and-color-for-each-point

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!