52North / js-sensorweb-client

Interative timeseries visualisation with JavaScript.
Apache License 2.0
11 stars 14 forks source link

Adding renderingHints in the TS API results in diagram not drawn #92

Open EHJ-52n opened 10 years ago

EHJ-52n commented 10 years ago

I am adding some renderingHints in the TS API in the file WEB-INF/classes/config-rendering-hints.json like this

"phenomenonStyles": {
    "phe_5345345345": {
        "style": {
            "properties": {
                "color": "#0000ff"
            }
        }
    }
},

After relaunching the TS API and the js-sensorweb-client, the according time series gets rendered using the defined color in the legend but not in the diagram anymore.

When requesting the timeseries details from the TS API directly, the rendering hints are present like this:

renderingHints": {
    "chartType": "line",
    "properties": {
        "color": "#0000ff"
    }
}

In the Chart View the timeseries is not drawn.

In chrome, the console and network tab show no error according data retrieval or something similar.

EHJ-52n commented 10 years ago

The problem is solved if all required properties are defined. The required properties are documented in the TS API documentation:

The enhancement should be, that partially defined rendering hints should work, too. As a user I want to define only the color and nothing more. Hence, the client should use a default style and update it with the values from the rendering hints. The according code section is here:

var style = {};
if(meta.hasOwnProperty('renderingHints')) {
    var chartType = meta.renderingHints.chartType;
    var width = meta.renderingHints.properties.width;
    var color = meta.renderingHints.properties.color;
    var interval = meta.renderingHints.properties.interval;
    var lineType = meta.renderingHints.properties.type;
    style = new TimeseriesStyle(chartType, width, color, interval, lineType);
} else {
    style = TimeseriesStyle.createDefault(tsId);
}