Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

render_bar_graph()

Description

Output the Javascript to build a bar chart in the canvas denoted by $id
$data must be in the following format
$data = array(
"point_a x value" => "point_a y value",
"point_b x value" => "point_b y value",

Parameters

ColumnTypeDefaultDescription
$id string identifier for the canvas to render the chart in
$data array data to be rendered in the chart

Return

void

Location

include/reporting_functions.php lines 873 to 898

Definition

 
function render_bar_graph(string $id, array $data)
    {
    
$values "";
    foreach (
$data as $t => $c)
        {
        
$values .= "{x: $t, y: $c },\n";
        }
    
?>
    <script type="text/javascript">
        new Chart(
            document.getElementById(' echo escape($id?>'),
            {
            type: 'line',
            data: {
                datasets: [
                    {
                        data: [ echo escape($values?>]
                    }
                ]
            },
            options: chartstyling echo escape($id)?>,
        }
        );
    </script>
    
    
}

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 7th November 2024 17:40 Europe/London time.