We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4385
    • 372 Posts
    Here is another charting solution to try. I played around for awhile with this, but gave up. Just seems to have to many options. I need a better way to set it up.

    http://pchart.sourceforge.net/

    Here is how I called it.

    [!pChart? &chartWidth=`700` &chartHeight=`230` &chartTitle=`pChart Test` &chartType=`line` &chartData1=`[*myNumbers*]`!] 


    Here is the snippet.

    <?php
    $snippetPath = $modx->config['base_path'] . 'assets/snippets/pChart/pChart/';
    $fontPath = $modx->config['base_path'] . 'assets/snippets/pChart/Fonts/';
    
    include_once($snippetPath.'pData.class');
    include_once($snippetPath.'pChart.class');
    
    $chartWidth= (isset($chartWidth))? $chartWidth : 400;
    $chartHeight = (isset($chartHeight))? $chartHeight : 400;
    $chartTitle = (isset($chartTitle))? $chartTitle : 'Chart';
    
    
     // Dataset definition 
     $DataSet = new pData;
    $DataSet->AddPoint(array(0,70,70,0,0,70,70,0,0,70),"Serie1");
    $DataSet->AddPoint(array(0.5,2,4.5,8,12.5,18,24.5,32,40.5,50),"Serie2");
    
    
    // $DataSet->AddPoint(array($chartData1), "Serie1");
    
     $DataSet->AddAllSeries();
    //  $DataSet->SetAbsciseLabelSerie();
    //  $DataSet->SetSerieName("January","Serie1");
    //  $DataSet->SetSerieName("February","Serie2");
    
     // Initialise the graph
     $Test = new pChart($chartWidth,$chartHeight);
     $Test->setFontProperties($fontPath . "tahoma.ttf",8);
     $Test->setGraphArea(50,30,585,200);
     $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
     $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
     $Test->drawGraphArea(255,255,255,TRUE);
     $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);
     $Test->drawGrid(4,TRUE,230,230,230,50);
    
     // Draw the 0 line
     $Test->setFontProperties($fontPath . "tahoma.ttf",6);
     $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
    
     // Draw the line graph
    $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
    $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);
    
     // Set labels
     $Test->setFontProperties($fontPath . "tahoma.ttf",8);
     $Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","2","Daily incomes",221,230,174);
     $Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie2","6","Production break",239,233,195);
    
     // Finish the graph
     $Test->setFontProperties($fontPath . "tahoma.ttf",8);
     $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);
     $Test->setFontProperties($fontPath . "tahoma.ttf",10);
     $Test->drawTitle(50,22,$chartTitle,50,50,50,585);
    
     $Test->Render("assets/images/charts/chart.png");
     return '<img src="assets/images/charts/chart.png"/>';
    ?>
    
      DropboxUploader -- Upload files to a Dropbox account.
      DIG -- Dynamic Image Generator
      gus -- Google URL Shortener
      makeQR -- Uses google chart api to make QR codes.
      MODxTweeter -- Update your twitter status on publish.
      • 49302
      • 14 Posts
      Hi, please can anyone explain how to use http://code.google.com/apis/chart/ to plot graphs with place holder values in modx or from a custom database.

      I tried it and it didn't work.
        • 49302
        • 14 Posts
        Hi, please can anyone explain how to use http://code.google.com/apis/chart/ to plot graphs with place holder values in modx or from a custom database.

        I tried it and it didn't work.
          • 49302
          • 14 Posts
          Hi, please can anyone explain how to use http://code.google.com/apis/chart/ to plot graphs with place holder values in modx or from a custom database.

          I tried it and it didn't work.