EzDevInfo.com

pivot.js

Build Pivot Tables from CSV/JSON Data Pivot.js

ReferenceError: c3 is not defined while generating charts using pivot.js/Require/Angular

I am using pivot.js with AngularJS and loading all dependencies with Require.js.

I want to generate Bar chart and Area chart, but I am getting error as "ReferenceError: c3 is not defined".

I was able to generate the chart without angularJS, but when I am trying to generate the chart with AngularJs I am getting the above error.

can any one post some code How to load the required dependencies using RequireJS and AngularJS


Source: (StackOverflow)

How do I use aggregators as calculation of two aggregators?

I am using Pivot.js and I am having problem with calculation of two aggregators.

How do I make "calculated" aggregator based on already defined two aggregators?

$(function (){
    var derivers = $.pivotUtilities.derivers;
    var aggregators = $.pivotUtilities.aggregators;
    var aggTemplates = $.pivotUtilities.aggregatorTemplates;
    $("#output").pivotUI(JSON_data, {

        aggregators: {                  
            "Number": function() { return aggTemplates.sum(0,1)(["Number"])},
            "Amount": function() { return aggTemplates.sum(0,1)(["Amount"])},
            "Calculated":  ???? "Number" / "Amount" ???? - help in this line    
        },

        cols:["year"], rows: ["age"],

    }, true);

});

Source: (StackOverflow)

Advertisements

AJAX call returning empty object from json_encode

I'm making an AJAX call to a fairly simple PHP function. The response should be a JSON object to be manipulated, but my response is always an empty object.

Relevant Code:

index.html's AJAX Call:

$( function() {
    $('#dates').on('submit', function (e) {
        var start_time = new Date().getTime();
        e.preventDefault();
        var submitData = $('#dates').serialize();
        console.log(submitData);
        $.ajax({
            type:'POST',
            url:'inflow.php',
            data:$('#dates').serialize(),
            dataType: 'json',
            beforeSend: function(){
                $('#loading').show();
            },
            success: function(data) {
                console.log(data);
                $('#loading').hide();
            },
            error:function(xhr, desc, err){
                alert('You tried to send an AJAX request, but something went wrong.\n Please Contact the NASR WebDev Team');
                console.log(xhr);
                console.log("Details: " + desc +"\nError: "+ err);
            }
        });
    });
});

inflow.php's array creation and echo:

<?php

$msqlStart = $_POST['start_date'];
$msqlEnd = $_POST['end_date'];

$inflowQuery=
    "SELECT
        COUNT,
        QUEUE_ID,
        QUEUE_GROUP,
        INFLOW_DATE,
        LINE_OF_BUSINESS
    FROM
        ticket_inflow.inflow
    WHERE
        ROUTE_STATUS = 'Inflow'
        AND inflow_date between ? and ?";

    $connect = new mysqli($host, $user, $password, $database);
    if ($connect->connect_error){
        die("Failed to Connect:.".$connect->connect_errno.": ".$connect->connect_error);
    }
    if(!($statment = $connect->prepare($inflowQuery))){
        die('Error in Preparation Error Number:%d Error: %s');
    }
    if(!$statment->bind_param('ss', $msqlStart, $msqlEnd)){
        die ('Error in Binding');
    }
    if(!$statment->execute()){
        die('Error In Execution');
    }
    $statment->bind_result($inflowCount, $inflowQueue, $inflowQG, $inflowDate, $inflowLOB);

    $a_json = array();
    $jsonRow = array();

    While($statment->fetch()){
        $UID = 0;
        $jsonRow['UID'] = $UID++;
        $jsonRow['count'] = utf8_encode($inflowCount);
        $jsonRow['inflow_date'] = utf8_encode($inflowDate);
        $jsonRow['queue'] = utf8_encode($inflowQueue);
        $jsonRow['queue_group'] = utf8_encode($inflowQG);
        $jsonRow['lob'] = utf8_encode($inflowLOB);
        array_push($a_json, $jsonRow);
    }


    $jsonReturn = json_encode($a_json);

    echo $jsonReturn; 

?>

If I go directly to inflow.php and pass it parameter's identical to what the page passes it, I get what appears to be a nice JSON object, however when I look at the response Chrome Developer's Tools I get:

[]

And nothing more.


Source: (StackOverflow)

How to fix pivot.js table rendering error?

I am using pivot.js to allow users to explore some data sets.

I am having a recurring error with the table rendering, however. It is rendering some table cells stacked vertically instead of in standard table layout, and the 'totals' column ends up being empty, because the cells were shifted to the left.

Example image:

rendering problem example

My data looks like this:

[{"Age (Years)":11.272980339929,"$":623.1816,"Type":"D","Group":"CSB","Code":"07"},{"Age (Years)":8.4756059107052,"$":2.376,"Type":"","Group":"CSB","Code":"07"},{"Age (Years)":7.5797154997463,"$":14.208,"Type":"","Group":"CSB","Code":"02"},{"Age (Years)":7.5797154997463,"$":131.868,"Type":"","Group":"CSB","Code":"02"},{"Age (Years)":7.4346241755454,"$":0,"Type":"","Group":"NLV","Code":"46"},{"Age (Years)":6.9031173262303,"$":0,"Type":"D","Group":"NLC","Code":"07"},{"Age (Years)":6.3305145865043,"$":59.94,"Type":"","Group":"CSB","Code":"09"},{"Age (Years)":5.7331401572806,"$":3954.09432,"Type":"D","Group":"CGP","Code":"19"},{"Age (Years)":5.8098524860477,"$":53.44352,"Type":"D","Group":"HCR","Code":"03"},{"Age (Years)":5.4811995180112,"$":0,"Type":"D","Group":"NLC","Code":"07"},{"Age (Years)":5.4784597919838,"$":0,"Type":"D","Group":"NLC","Code":"07"}]

jquery 1.8, jqueryui 1.9.2

Any tips?


Source: (StackOverflow)