0
votes

Each bar denotes an application in my case. I am using trend lines to see performance of different application on a bar graph.

On the Trending line in bar chart, if one of the entity (bar) has no data, can we not show that trend. Currently getting a trend line on X-axis for bar having value zero.

I can see trending on the graph, but there is one more legend as "moving average". Can this be removed? Let me know in comments section if you need more Info.

Is it possible to do it via JavaScript? How? Eg: using post fetch of chart.

1
to be more specific: which property of chart should be modified in order to remove trend lines for null data. So no trend line is drawn against null data.Alen

1 Answers

1
votes

the trending calculation itself does not take null values into account. However, if you prefer not to show trend points for which "application" was null, you can hide the line segments passing through those points by using an extension point:

trendLine_strokeStyle: function(s) {
    var categ  = s.getCategory(),
        series = s.getSeries(),
        dataPart = '0',
        hasNonNull = 
            this.chart.visibleData(dataPart)
               .datums({category: categ, series: series}, {isNull: false})
               .any();

    // `delegate` returns the color that would be returned hadn't we overridden
    //  the extension point.
    // `null` means "transparent color".
    return hasNonNull ? this.delegate() : null;
}

The previous code snippet works for a default chart configuration, where you used the default dimension names (series and category), and the trend is only for the data in the main plot (the data with dataPart value '0').

For the other question, of how to hide the part of the legend that shows the trend colors, assuming once again that you did not change default values, and so that the trend plot is using the second color axis, you'd hide it by specifying the option color2AxisLegendVisible: false.

Edit: To place the code above in the CDF component's preExecution handler, you'd do it like this:

function() {
    var cccOptions = this.chartDefinition;

    // Extension points are in a array of pairs name, value format...
    var eps = Dashboards.propertiesArrayToObject(cccOptions.extensionPoints);

    // Specify the extension point
    eps.trendLine_strokeStyle = function() { ... };

    // Convert extension points to original CDF format
    cccOptions.extensionPoints = Dashboards.objectToPropertiesArray(eps);
}