Set default carousel "index" to value of filter

Comments

1 comment

  • Avatar
    Sven Willenberger

    Working with support we have come up with the following code example that does this:

    widget.on('queryend', function(scope, args) {

    /*Configuration settings*/
    var dimension = '[Dim_Dates.Date (Calendar)]'
    var dateDimension = true
    var panel = 'Month'



    var requiredValue
    var filter = args.widget.dashboard.filters.item(dimension)
    if (filter && filter.jaql && filter.jaql.filter && filter.jaql.filter.members) {
    requiredValue = filter.jaql.filter.members[0]
    if (dateDimension) {
    requiredValue = requiredValue.substr(0, 10)
    }
    } else {
    return
    }
    var panelIndex

    args.rawResult.metadata.forEach(function(item, i) {
    if (item.PanelName === panel) {
    console.log(item);
    panelIndex = i
    }
    })

    if (typeof(panelIndex) === 'undefined') {
    return
    }

    var index
    var taleArray = []
    var headArray = []
    var expectedElement

    args.rawResult.values.forEach(function(value, i) {
    if (dateDimension && value[panelIndex].data.substr(0, 10) === requiredValue) {
    index = i
    } else if (value[panelIndex].text === requiredValue) {
    index = i
    }
    })

    if (!index) {
    return
    }
    var newOrder = []

    newOrder.push(args.rawResult.values[index])

    for (var i=index+1; i<args.rawResult.values.length; i++) {
    newOrder.push(args.rawResult.values[i])
    }

    for (var i=0; i<index; i++) {
    taleArray.push(args.rawResult.values[i])
    }

    taleArray.forEach(function(item) {
    newOrder.push(item)
    })
    if (newOrder.length === args.rawResult.values.length) {
    args.rawResult.values = newOrder
    }
    })
    1
    Comment actions Permalink

Please sign in to leave a comment.