COM-FSM
Template:MindTouch > Reports > Controls > RatingChart

RatingChart

Page last modified 14:15, 31 Oct 2010 by Admin
    Table of contents
    No headers
    /**
     * Rating Reports Chart Control
     *
     * @param str $name - name of the report
     * @param map $data - report data from reporting service
     * @param num $total - total number of pages
     * @param uri $resetUri - uri to main site report
     * @param map $site - site level report data (optional)
     */
    var reportType = $type;
    var reportData = $data;
    var totalPages = $total;
    var siteData = $site;
    var resetUri = $resetUri;
    
    // shorthand for localization keys
    var localizePrefix = "MindTouch.ContentAnalytics.".. reportType;
    
    if (reportData.meta[reportType].count == 0) {
        <div class="no-results">
            <div class="no-results-text">
                wiki.localize( localizePrefix .. ".data.empty");
            </div>
        </div>
    } 
    
    // results output
    if (!siteData) {
        <h3 class="reports">wiki.localize(localizePrefix ..".title")</h3>
    } else {  
        <h3 class="reports">
            wiki.localize(localizePrefix ..".title.search");
            if (reportData.meta[reportType].query) {
                 <div class="reset-search">
                    <a href=(resetUri)>wiki.localize("MindTouch.Reports.search.reset")</a>
                </div>
            }            
        </h3>
    }
    <div class="mt-report-overview">
        <dl class="stats">
            <dt class="first">
                <span class="title">wiki.localize(localizePrefix .. ".stat.pagecount")</span>
                if (siteData) {
                    <span class="site">
                        wiki.localize("MindTouch.ContentAnalytics.stat.site");
                        " ";
                        siteData.meta[reportType].count;
                    </span>
                }
            </dt>
            <dd class="first">
                <span>
                wiki.localize(localizePrefix .. ".stat.pagecount.value", [reportData.meta[reportType].count]);
                </span>
                <span class="help">wiki.localize(localizePrefix .. ".stat.pagecount.tip")</span>    
            </dd>
            <dt class="second">
                <span class="title">wiki.localize(localizePrefix .. ".stat.average")</span>
                if (siteData) {
                    <span class="site">
                        wiki.localize("MindTouch.ContentAnalytics.stat.site");
                        " ";
                        wiki.localize(
                            localizePrefix .. ".stat.average.value",
                            [siteData.meta[reportType].average]
                        );
                    </span>
                }
            </dt>
            <dd class="second">
                <span>
                wiki.localize(
                    localizePrefix .. ".stat.average.value",
                    [reportData.meta[reportType].average]
                );
                </span>
                <span class="help">wiki.localize(localizePrefix .. ".stat.average.tip")</span>
             </dd>
            switch (reportType) {
            case "rating":
                <dt class="third">
                    <span class="title">wiki.localize(localizePrefix .. ".stat.unrated");</span>
                    if (siteData) {
                    <span class="site">
                        wiki.localize("MindTouch.ContentAnalytics.stat.site");
                        " ";
                        let percent =  num.round(
                            (1 - (siteData.meta[reportType].count / totalPages)) * 100, 2
                        );
                        wiki.localize(
                            localizePrefix .. ".stat.unrated.value",
                            [percent]
                        );
                    </span>
                    }
                </dt>
                <dd class="third">
                    <span>
                        let percent =  num.round(
                            (1 - (reportData.meta[reportType].count / totalPages)) * 100, 2
                        );
                        wiki.localize(
                            localizePrefix .. ".stat.unrated.value",
                            [percent]
                        );
                    </span>
                    <span class="help">wiki.localize(localizePrefix .. ".stat.unrated.tip")</span> 
                </dd>
    
            case "aging":
                <dt class="third">
                    <span class="title">wiki.localize(localizePrefix .. ".stat.archaic");</span>
                        if (siteData) {
                        <span class="site">
                            wiki.localize("MindTouch.ContentAnalytics.stat.site");
                            " ";
                            siteData.meta[reportType].countAboveTwoYears;
                        </span>
                    }
                </dt>
                <dd class="third">
                    <span>
                        reportData.meta[reportType].countAboveTwoYears;
                    </span>
                    <span class="help">wiki.localize(localizePrefix .. ".stat.archaic.tip")</span> 
                </dd>
            }
            <dt class="information">
                <div>
                wiki.localize(
                    localizePrefix .. ".information",
                    [reportData.meta[reportType]["csv.uri"]]
                )
                </div>
            </dt>
        </dl>
    
        // determine if the charting component is available
        if (__env["anychart"]) {
        <div class="chart">
            var seriesLabel = wiki.localize(localizePrefix ..".chart.series");
            template("MindTouch/Controls/Chart", {
                width: "500",
                height: "325",
                min: 0,
                type: "line", 
                data:  {
                    (seriesLabel): reportData.series[reportType]
                },
                xaxis: wiki.localize(localizePrefix ..".chart.xaxis"), 
                yaxis: wiki.localize(localizePrefix ..".chart.yaxis"),
                title: wiki.localize(localizePrefix ..".chart.title")
            });
        </div>
        } else {
        <div class="chart ui-state-disabled"><div>wiki.localize("MindTouch.ContentAnalytics.charting.disabled");</div></div>
        } 
    </div>
    // end no-results
    
    Powered by MindTouch Core