In jpgraph js library, for LinePlot
, is it possible to have dots (plot marks) of different (customly defined) colors? Any experience anyone? I need to make different colors for some of the dots in the graph, for some values of x-axis.

- 3,200
- 2
- 30
- 58
-
There will be a bounty on this question as soon as I can put it. – Vladimir Despotovic Mar 31 '21 at 17:17
1 Answers
By the documentation of jpgraph:
"The colors of the marks will, if you don't specify them explicitly, follow the line color. Please note that if you want different colors for the marks and the line the call to SetColor() for the marks must be done after the call to the SetColor() for the line since the marks color will always be reset to the lines color when you set the line color."
<?php
$lineplot->mark->SetType(MARK_UTRIANGLE);
$lineplot->mark->SetColor('blue');
$lineplot->mark->SetFillColor('red');
?>
In addition the plot mark formatting shown above plot marks also supports formating through the use of a callback function. The callback function will be passed the y-value as its only argument and the callback function must return an array consisting of three value, weight, color and fill-color. This could be used to for example alter the colors of the plot marks depending on the actual value. A common use of this feature is to create "balloon" scatter plot where a variable sized filled circle is positioned at specific data points. This is a way t create a 2D plot which conveys three values at each data point, x,y and size.
The closest example to your need would be this: https://github.com/HuasoFoundries/jpgraph/blob/master/Examples/examples_line/builtinplotmarksex1.php

- 944
- 7
- 20