Code Monkey home page Code Monkey logo

Comments (1)

ffflabs avatar ffflabs commented on June 1, 2024

@cdmalcl sorry it took me so long. I started refactoring and now I don't know how to merge god damned develop.

Having said that: The logic looks for the fontfiles on JPGraph's project root > src > fonts. If the requested font isn't found, it would search either in the path defined in the constant TTF_DIR (or MBTTF_DIR in a very specific case).

As of version 4.0.1, I'm uploading a hotfix to enable this feature. 👍

image

The code for the graph above is at

<?php
/**
* JPGraph v4.0.1
*/
require_once __DIR__ . '/../../src/config.inc.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data = [40, 60, 21, 33];
$__width = 300;
$__height = 250;
$graph = new Graph\PieGraph($__width, $__height);
$graph->SetShadow();
$example_title = ' Using Arial';
$graph->title->set($example_title);
$graph->title->SetFont(
FF_ARIAL,
FS_NORMAL,
14
);
$p1 = new Plot\PiePlot($data);
$graph->Add($p1);
$data2 = [60, 30, 11, 53];
$graph2 = new Graph\PieGraph($__width, $__height);
$graph2->SetShadow();
$example_title2 = 'Using Ubuntu Sans Serif';
$graph2->title->set($example_title2);
$graph2->SetUserFont1(
'/usr/share/fonts/truetype/ubuntu/Ubuntu-M.ttf',
'/usr/share/fonts/truetype/ubuntu/Ubuntu-B.ttf',
'/usr/share/fonts/truetype/ubuntu/Ubuntu-I.ttf'
);
$graph2->title->SetFont(
FF_USERFONT1,
FS_NORMAL,
14
);
$p2 = new Plot\PiePlot($data2);
$graph2->Add($p2);
$data3 = [60, 30, 11, 53];
$graph3 = new Graph\PieGraph($__width, $__height);
$graph3->SetShadow();
$example_title3 = 'Using Lato Italic';
$graph3->title->set($example_title3);
$graph3->SetUserFont2(
'/usr/share/fonts/truetype/lato/Lato-Regular.ttf',
'/usr/share/fonts/truetype/lato/Lato-Bold.ttf',
'/usr/share/fonts/truetype/lato/Lato-Italic.ttf',
'/usr/share/fonts/truetype/lato/Lato-BoldItalic.ttf'
);
$graph3->title->SetFont(
FF_USERFONT2,
FS_ITALIC,
14
);
$p3 = new Plot\PiePlot($data3);
$graph3->Add($p3);
$graph4 = new Graph\PieGraph($__width, $__height);
$graph4->SetShadow();
$example_title4 = 'Using Carlito BoldItalic';
$graph4->title->set($example_title4);
$graph4->SetUserFont3(
'/usr/share/fonts/crosextra/lato/Carlito-Regular.ttf',
'/usr/share/fonts/truetype/crosextra/Carlito-Bold.ttf',
'/usr/share/fonts/truetype/crosextra/Carlito-Italic.ttf',
'/usr/share/fonts/truetype/crosextra/Carlito-BoldItalic.ttf'
);
$graph4->title->SetFont(
FF_USERFONT3,
FS_BOLDITALIC,
14
);
$p4 = new Plot\PiePlot($data);
$graph4->Add($p4);
//-----------------------
// Create a multigraph
//----------------------
$mgraph = new Graph\MGraph();
$mgraph->SetMargin(2, 2, 2, 2);
$mgraph->SetFrame(true, 'darkgray', 2);
$mgraph->SetFillColor('lightgray');
$mgraph->Add($graph);
$mgraph->Add($graph2, 300, 0);
$mgraph->Add($graph3, 0, 255);
$mgraph->Add($graph4, 300, 255);
$mgraph->Stroke();

from jpgraph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.