Cspro-D3-chart

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Yihun_Shegnew
Posts: 25
Joined: November 30th, 2017, 11:56 am

Cspro-D3-chart

Post by Yihun_Shegnew »

Dear programmers,

To customize the cspro-d3-chart which part of the application is update ?
In this folder there are many files associated with cspro data visualization.
Under the "report" folder there are html files and Java scripts codes so which one is editable to run based on the kind of data dictionary and report files?



Thanks in advance
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Cspro-D3-chart

Post by Gregory Martin »

You can study Josh's example here:

https://github.com/jhandley/cspro-D3-charts

Here is the logic:

https://github.com/jhandley/cspro-D3-ch ... ts.ent.apc

Look, for example, at the countsVsExpectedReport function. He is writing out a JavaScript file with the input for the D3 chart.
    string reportDataFilename = maketext("%scounts-vs-expected-data.js", reportDataDirectory);
    setfile(tempFile, reportDataFilename);
    filewrite(tempFile, "var data = [");
    do i = 1 while i <= maxEa
        if householdsByEa(i) > 0 then
            EC_EA = i;
            if loadcase(EXPECTEDCOUNTS_DICT, EC_EA) then
                filewrite(tempFile, "  {EA: '%03d', households: %d, expected: %d},",
                          i, householdsByEa(i), EC_HOUSEHOLDS);
            endif;
        endif;
    enddo;
    filewrite(tempFile, "];");
    close(tempFile);
Post Reply