0

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.

mzy
  • 1,754
  • 2
  • 20
  • 36
Alen
  • 174
  • 4
  • 11
  • 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 Jul 25 '14 at 07:01

1 Answers1

1

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);
}
  • 1) how do i add the code to extension point. extension point property gives me only two attributes to fill "arg" and "value". – Alen Jul 29 '14 at 10:11
  • Not working. here is the link for my chart http://s27.postimg.org/p6py76xoz/trendline.jpg As you can see, there is trend line even if there is no bar plotted. when i hover the bar i get three things. Series, Date Created and Value. Series : , Date Created: x-axis date value, Value: Y-axis value – Alen Jul 30 '14 at 11:51
  • 1
    Are your missing values actually null, or are they 0? The provided code only works for nulls. Place a breakpoint in the extension point code, and try to figure out why it is not working. – Duarte Cunha Leão Jul 30 '14 at 16:37