Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    dynamic portelts

    I am using

    SmartClient_81_PowerEdition on FireFox 15.0.1,
    There is no error messages on the logs.

    The issue:

    I am attempting to dynamically create charts (and assign unique ID’s) by iterating through a Resultset as in code below and push/add them into an array to be available as portlets as per example in Feature Explorer. The difference between my scenario and the example is that in mine the charts (except that facets layout are known upfront) info is not known upfront but data-driven. However, it does not seem my “makeProcessChart” function is creating ALL charts with different ID’s. How would you suggest I approach the problem?

    var processPortlets = [];

    isc.DataSource.get("sc_FetchMyProcessesDS").fetchData(null,
    function (dsResponse, data) { //this is a callback
    isc.ResultSet.create({
    ID:"myProcessesRS", dataSource:"sc_FetchMyProcessesDS",
    allRows:data
    });
    for (var i=0; i<myProcessesRS.getLength(); i++) {
    var chartID ="";
    chartID = data[i]["Metric"].toString() +data[i]["idBUprocesses"].toString();
    processPortlets.push({
    title:data[i]["Metric"],
    className:"FacetChart",
    makeComponent : function () {
    return makeProcessChart(chartID);
    }
    })
    } )
    Below is the makeProcessChart function which I was hoping I could pass a string literal to serve as ID for each component.
    function makeProcessChart(_chartID) {

    return isc.FacetChart.create({
    ID:_chartID,
    showDataPoints: true,
    facets: [
    {
    inlinedValues:true,
    values : [{id:"Actual"}, {id : "UAL"},{id : "LAL"},{id : "Goal",title:"Goal"}]
    },
    {id:"Date"}
    ],
    chartType: "Line",stacked: false,shouldAnimateShow:true,autoDraw:false,

    getPointHoverHTML : function (value, record) {
    return (
    '<b>' + record.Process + '</b><br />' +
    '<i>' + record.Metric + '</i><br />' +
    '<b>Date:</b> ' + record.Date + '<br />' +
    '<hr>'+
    '<b>Actual:</b> ' + record.Actual + '<br />' +
    '<b>UCL:</b> ' + record.UAL + '<br />' +
    '<b>LCL:</b> ' + record.LAL + '<br />' +
    '<b>Goal:</b> ' + record.Goal + '<br />'
    );
    },
    updateData : function (dynamicCriteria, title) {
    var self = this; // So we can refer to ourself in the callback below, where "this" will have changed
    var ds = isc.DataSource.get("scFetchChartPMdataDS");
    var criteria = {idBUprocesses:dynamicCriteria};

    ds.fetchData(criteria,
    function (dsResponse, data) {
    self.setData(data);
    self.setProperty('title',title);
    }
    )
    }
    })
    }
Working...
X