Page 1 of 1

Cspro-D3-chart

Posted: January 15th, 2018, 9:34 am
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

Re: Cspro-D3-chart

Posted: January 15th, 2018, 10:03 am
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);