Turning point Labels incl. and off in jqplot

I am trying to turn pointLabels on and off. I thought this would work something like this:

var data_ = [[1,1],[2,5],[4,9]]; var graph = $.jqplot(id_graph, [data_], { series:[{pointLabels: { show:true } }] } ); graph.series[0].pointLabels.show=false; graph.replot(); 

However, this still displays label tags.

Thanks for any help!

+4
source share
3 answers

althoug this post is old I found a solution to the problem:

 var data_ = [[1,1],[2,5],[4,9]]; var graph = $.jqplot(id_graph, [data_], { series:[{pointLabels: { show:true } }] } ); graph.series[0].plugins.pointLabels.show=false; graph.replot(); 

Instead of using

 graph.series[0].pointLabels.show=false; 

using

 graph.series[0].plugins.pointLabels.show=false; 

In my case, it worked.

+2
source

I think what you really want is showMarker . Since in this code you do not set point labels, therefore they will never be displayed. showMarker allows you to turn graph points on and off.

Is that what you really are after? Otherwise, specify the example that you are using.

Here is an example made for a similar problem.

Please view this sample. Click the button to change the creators' visibility.


Update: This example shows a solution that uses the approach described above, that is, redesigning the graph when changing the new parameter "pointLabels".

 jQuery(document).ready(function () { var data = [ [1, 1], [2, 5], [4, 9] ]; var graph; var isShowPointLabels = true; function makePlot(showPointLabels) { graph = $.jqplot("chart", [data], { series: [{ pointLabels: { show: showPointLabels } }] }); } makePlot(isShowPointLabels); $("#click").click(function () { isShowPointLabels = !isShowPointLabels; makePlot(isShowPointLabels); graph.replot(); }); }); 

In this case, I could not figure out how to use drawSeries(...) to redo just one series, as @Mark shows for marker , which would be good practice here.

+1
source

Adding Boro to the answer, if you want to switch the marker in one series, it will be faster:

 graph.drawSeries({markerOptions:{show:false}},seriesIndex); //redraw single series 

Replacement calls can be expensive with lots of runs.

The previous script is here .

+1
source

Source: https://habr.com/ru/post/1415052/


All Articles