/// class ProspectDirector.Web.UI.Canvas.Charts.ChartUtilities

/**
@class ChartUtilities
@namespace Web.UI.Canvas.Charts
@constructor
**/
ProspectDirector.Web.UI.Canvas.Charts.ChartUtilities = Class.extend({
});

//==============================
// STATIC METHODS
//==============================

ProspectDirector.Web.UI.Canvas.Charts.ChartUtilities.FormatFieldName = function (data) {

    var result = "",
        hasFunction = false,
        hasScalarFunction = false,
        hasAggregateFunction = false;

    hasScalarFunction =
        data.scalarFunctionName !== undefined
        && data.scalarFunctionName !== null;

    hasAggregateFunction =
        data.aggregateFunctionName !== undefined
        && data.aggregateFunctionName !== null;

    hasFunction = hasScalarFunction || hasAggregateFunction;

    if (data.columnName !== undefined && data.columnName !== null) {

        result = data.columnName;

        if (hasFunction) {
            result = "<span style=\"color:#000000;\">" + result + "</span>";
        }

        if (hasScalarFunction) {
            result = "<span style=\"color:#0000FF;\">" + data.scalarFunctionName + " of " + result + "</span>";
        }

        if (hasAggregateFunction) {
            result = "<span style=\"color:#AA0000;\">" + data.aggregateFunctionName.toUpperCase() + " ( " + result + " )</span>";
        }

    }
    else {
        result = "#error#";
    }

    return result;

};

ProspectDirector.Web.UI.Canvas.Charts.ChartUtilities.GetQuerySettings = function (featureSet) {

    var documentTypes = featureSet.getValue("documentTypes"),
        entityTypes = featureSet.getValue("entityTypes");

    return {
        anchor: {
            entityTypes: entityTypes || { groups: [] },
            documentTypes: documentTypes || { types: [] }
        },
        templateId: featureSet.getValue("templateId"),
        templateIsDocumentBased: featureSet.getValue("templateIsDocumentBased")
    }

}