NPellet / visualizer

Other
42 stars 24 forks source link

Spectra Displayer and chart object with color property #1022

Open jobo322 opened 7 years ago

jobo322 commented 7 years ago

The "spectra displayer" module don't draw a chart object with color property in visualizer versions upper to 2.61 In the following view you can observe the problem swich the version of visualizer between 2.61 and 2.63 or higher.

https://my.cheminfo.org/?v=v2.63.1&viewURL=https%3A%2F%2Fmydb.cheminfo.org%2Fdb%2Fvisualizer%2Fentry%2F53c69fe93b8643d0690c769c7d266372%2Fview.json

lpatiny commented 7 years ago

This is a working test case:

https://my.cheminfo.org/?v=v2.61.0&viewURL=https%3A%2F%2Fmydb.cheminfo.org%2Fdb%2Fvisualizer%2Fentry%2F53c69fe93b8643d0690c769c7d266372%2Fview.json

Indeed it happens between 2.61.0 and 2.63.1

https://github.com/NPellet/visualizer/compare/v2.61.0...v2.63.1

lpatiny commented 7 years ago

@NPellet

The format of the json looks strange to me:

https://github.com/cheminfo/json-chart/blob/master/examples/colorLine.json

What is the correct way to encode set the color of each segment of a line. It used to work before 2.61.0 meaning before jsgraph 1.15.2

NPellet commented 7 years ago

Well there was indeed a problem in line.color

I patched it 1.16.24, but you cannot use markers anymore (you never could actually...)


    for( var i = 0; i < Math.PI * 10; i += 0.001 ) {
        data.push( i );
        data.push( Math.sin( i ) );
        colors.push( HSVtoRGB( Math.pow(Math.sin( i ), 2), 0.8, 0.8 ) );
    }

        var s = graph.newSerie("a", {}, "line.color").autoAxis().setData(data);
        s.setColors([ colors ]);

Don't attempt to make a draw if the colors have not been set. I don't even check if they exist and jsGraph will fail if they don't. I opened a ticket to improve this in jsGraph 2

andcastillo commented 7 years ago

It is working now in the HEAD.