youcef92 / flotr

Automatically exported from code.google.com/p/flotr
0 stars 0 forks source link

Is it possible to label particular points in a graph #80

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. graph a series of points
2. add text to one or more of the points within the series
3.

This is sort of like markers but I don't want to label all of the points...
and in actual fact, I'd like to add generic text (not necessarily the x|y
values of the point...

TIA

Al

Original issue reported on code.google.com by al.caughey on 28 Jul 2009 at 4:58

GoogleCodeExporter commented 8 years ago
Sorry... I think this is an enhancement request rather than a defect (or simple 
a DFU
error)

Original comment by al.caughey on 28 Jul 2009 at 4:59

GoogleCodeExporter commented 8 years ago
Hello, you can specify only the points you want to label, for example if you 
have 
this kind of data, for bars :
{data: [[0, 5], [1, 2], [2, 18], [3, 6]], bars: {show: true}}

and that you'd only like to label the third point, put this :
{data: [[2, 18, "The biggest bar"]], markers: {show: true, labelFormatter: 
labelFormatter}}

The third value can only be taken in account by the latest revision in the 
trunk 
(r141).

Now, you can use this labelFormatter for the markers : 

function labelFormatter(obj) {
  return obj.data[obj.index][2];
}

Tell me if this is ok now

Original comment by fabien.menager on 28 Jul 2009 at 7:40

GoogleCodeExporter commented 8 years ago
Hello,
I tried your solution to add text near the points but it doesn't work even with 
the
last revision in the trunk.

I would like to draw 4 points, so I tried this :
var d=[[[-0.1,-0.2]],[[1.0,5.2]],[[-0.2,-0.1]],[[1.9,-2.1]]]
var f = Flotr.draw(
$('container'), 
d,
Options
);  

In Options I specified colors because I need to draw to groups of points, so 2
differents colors. This works well.
Now I would label my points, but it's not easy.
Is there another option like "addText" or something like that, to add labels in 
one
way for all my points?

Thank you for your help,
J.W

Original comment by jaguar.w...@gmail.com on 19 Aug 2009 at 2:47

GoogleCodeExporter commented 8 years ago
Hello, what is the content of the variable Options ?

Original comment by fabien.menager on 20 Aug 2009 at 4:56

GoogleCodeExporter commented 8 years ago
var couleurs = ['#00A8F0', '#cb4b4b', '#cb4b4b', '#00A8F0''];
Options = {
                points: {show:true, radius:3, lineWidth:3 }, 
                colors: couleurs, 
                grid: {labelMargin:10},
                xaxis: {autoscaleMargin:0.3},
                yaxis: {autoscaleMargin:0.3},
                legend: {show: true},
                mouse: {track:true, color:'#000000',position:'ne'},
}
and there is a known issue with mouse linecolor. The specified color does not 
appear
correctly. It's always red.

J.W

Original comment by jaguar.w...@gmail.com on 24 Aug 2009 at 12:29

GoogleCodeExporter commented 8 years ago
Hello, (are you French ? I'm French)
Check your syntax !
  var couleurs = ['#00A8F0', '#cb4b4b', '#cb4b4b', '#00A8F0''];
must be
  var couleurs = ['#00A8F0', '#cb4b4b', '#cb4b4b', '#00A8F0'];

and remove the last comma before the closing } after 'ne'.

set mouse.lineColor, not mouse.color if you want it black.

Contact me by e-mail, and make a configuration that suits to your needs with 
the 
Flotr playground (http://phenxdesign.net/projects/flotr/playground/) if you 
need more 
help.

Original comment by fabien.menager on 24 Aug 2009 at 1:24

GoogleCodeExporter commented 8 years ago
Ok thank's for the lineColor, it's working now. For the syntax, it's because I 
edited
it before sending message, but it's good in my script.
By the way, is there a simple solution to add text near the points like pointA,
pointB, pointC... ?

Thank you
J.W 
(Yes I m french :))

Original comment by jaguar.w...@gmail.com on 24 Aug 2009 at 1:55

GoogleCodeExporter commented 8 years ago
Doesn't Fabien's first comment answer that question?  Provide a label and a 
labelformatter, and set show to true for markers.

Original comment by peter....@solide-ict.nl on 20 Jul 2010 at 11:30

GoogleCodeExporter commented 8 years ago
This is the only solution right now to add point labels, you could make a 
helper function that would add the right coordinates in a markers object to 
make this easier.

Original comment by fabien.menager on 12 Aug 2010 at 12:48