heavyai / heavyai-crossfilter

JavaScript library for exploring large multivariate datasets in the browser.
Other
51 stars 20 forks source link

Need to override function writeQuery with custom function #65

Open ghost opened 6 years ago

ghost commented 6 years ago

@uyanga-gb I have a requirement to override writeQuery method in the mapd crossfilter libray. Can you suggest a way in which I can override the writeQuery method in the crossfilter js using custom function by inheriting in new object without making changes in this mapd-crossfilter.js

biovisualize commented 6 years ago

That's a general javascript question, but here's one way we are extending mapd crossfilter with custom methods in Immerse:

function getTopN(column) {
  const group = this.dimension(column)
    .order("val")
    .group()
    .reduceCount(column)

  return group
    .topAsync(NUM_DEFAULT_CATEGORIES, 0, null, true)
    .then(results => results.map(result => result.key0))
}

export function extendCrossfilter(crossfilter) {
  crossfilter.getTopN = getTopN.bind(crossfilter)
  return crossfilter
}
ghost commented 6 years ago

Actually the issue is I want group by.... with having clause for ILIKE on array Column, So I need to have facility to create group by.. having queries through crossfilter.