Commit ecc0fb378ac4bac1ee149db8aa4fbf492706c1a6
Merge branch 'master' of https://archives.plil.fr/grouille/IMA3_P10
Showing
788 changed files
with
70360 additions
and
223 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 788 files are displayed.
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +172.26.145.111 |
Ansible/inventaire.ini
Ansible/roles/arduino/tasks/main.yml
1 | --- | 1 | --- |
2 | - name: "envoyer du fichier binaire.c" | 2 | - name: "envoyer du fichier binaire.c" |
3 | get_url: | 3 | get_url: |
4 | - url: http://projet-p10.plil.fr/upload/binaire.c | 4 | + url: http://projet-p10.plil.fr/IMA3_P10/site/upload/binaire.c |
5 | dest: /home/pi/capteur{{capteur}}/binaire.c | 5 | dest: /home/pi/capteur{{capteur}}/binaire.c |
6 | mode: '0644' | 6 | mode: '0644' |
7 | 7 |
Ansible/roles/arduino_Setup/tasks/main.yml
README.md
1 | # Administration système, déploiement et surveillances de logiciels dans un réseau de capteurs | 1 | # Administration système, déploiement et surveillances de logiciels dans un réseau de capteurs |
2 | 2 | ||
3 | + | ||
3 | Dans le cadre de recherches dans le domaine des réseaux de capteurs et des objets connectés, notre projet consiste à développer une solution de maintenance et de reconfiguration à distance d'un ensemble de nœuds déployés dans un environnement réel. Afin de faciliter la vie de ces chercheurs sur le test de leurs hypothèses, ils pourront facilement et rapidement déployer leurs créations sur tout les nœuds souhaités grâce à un système de sélection ou au téléchargement du nouveau code sur tous les nœuds du réseau. | 4 | Dans le cadre de recherches dans le domaine des réseaux de capteurs et des objets connectés, notre projet consiste à développer une solution de maintenance et de reconfiguration à distance d'un ensemble de nœuds déployés dans un environnement réel. Afin de faciliter la vie de ces chercheurs sur le test de leurs hypothèses, ils pourront facilement et rapidement déployer leurs créations sur tout les nœuds souhaités grâce à un système de sélection ou au téléchargement du nouveau code sur tous les nœuds du réseau. |
4 | 5 | ||
5 | L'objectif principal de notre projet est de créer une interface permettant de tester des programmes ou logiciels en les déployant sur le vaste réseau de capteurs. Nous devons rendre accessible chaque nœud indépendamment des autres, tout en permettant un lien entre tous, afin d'envoyer le contenu vers tout ou une partie des nœuds disponibles. | 6 | L'objectif principal de notre projet est de créer une interface permettant de tester des programmes ou logiciels en les déployant sur le vaste réseau de capteurs. Nous devons rendre accessible chaque nœud indépendamment des autres, tout en permettant un lien entre tous, afin d'envoyer le contenu vers tout ou une partie des nœuds disponibles. |
@@ -10,17 +11,20 @@ Vous trouverez tous les fichiers et dossiers liés à ce projet sur ce dépôt g | @@ -10,17 +11,20 @@ Vous trouverez tous les fichiers et dossiers liés à ce projet sur ce dépôt g | ||
10 | 11 | ||
11 | ## Démarrage | 12 | ## Démarrage |
12 | 13 | ||
13 | -A déterminer précisément | 14 | +- _Etape 1_ : Rendez-vous sur le site : **http://projet-p10.plil.fr/IMA3_P10/site/index.html** ; |
15 | +- _Etape 2_ : Connectez-vous ; | ||
16 | +- _Etape 3_ : Utilisez le site pour envoyer des codes aux capteurs et pour récupérer des valeurs ou un historique. | ||
14 | 17 | ||
15 | ## Fonctionnalités | 18 | ## Fonctionnalités |
16 | 19 | ||
17 | ### Equipe 1 | 20 | ### Equipe 1 |
18 | 21 | ||
19 | -A décrire | 22 | +- Uploader les codes reçu sur la bonne carte (i.e. le bon capteur). |
23 | +- Récupérer les valeurs de retour des capteurs et les envoyer sur le serveur. | ||
20 | 24 | ||
21 | ### Equipe 2 | 25 | ### Equipe 2 |
22 | 26 | ||
23 | -A décrire | 27 | +Script Ansible permettant l'initialisation et la mise à jour des données présentes sur les Raspberry Pi. |
24 | 28 | ||
25 | ### Equipe 3 | 29 | ### Equipe 3 |
26 | 30 | ||
@@ -34,21 +38,28 @@ Site web permettant différentes choses : | @@ -34,21 +38,28 @@ Site web permettant différentes choses : | ||
34 | 38 | ||
35 | ### Equipe 1 | 39 | ### Equipe 1 |
36 | 40 | ||
37 | -A décrire | 41 | +- Les Raspberry communiquent parfaitement avec le site par wget et requete POST |
42 | +- Les codes sont modifiés et prêts (code température et code distance) | ||
43 | +- Un Makefile générique est opérationel et en cours de finition | ||
44 | +- Il faut écrire une script pour les raspberry qui récupère le numéro de capteur (pour l'associer à un numéro de port) et la version pour l'envoyer au Makefile | ||
45 | +- Le Makefile choisira d'abord quel commande d'upload il va effectuer (en fonction du numéro de version) puis spécifiera le port dans la commande avrdude | ||
46 | +- La carte Nucléo M4 est en suspend tant que le reste n'est pas fonctionnel | ||
38 | 47 | ||
39 | ### Equipe 2 | 48 | ### Equipe 2 |
40 | 49 | ||
41 | -A décrire | 50 | +- Gestion au niveau des Arduino (Nucléo laissée de côté) |
51 | +- L'installation des logiciels et bibliothèques nécessaire au fonctionnement des codes est ok | ||
52 | +- La transmission des fichiers et le lancement du script fonctionne. | ||
53 | +- Il faut gérer l'envoi automatique des clé ssh aux raspberry pour qu'Ansible puisse fonctionner de manière 100% autonome | ||
54 | +- Il faudrait récupérer le code envoyé depuis le site dans le télécharger (car Ansible est aussi sur le serveur) | ||
42 | 55 | ||
43 | ### Equipe 3 | 56 | ### Equipe 3 |
44 | 57 | ||
45 | -Le site web est terminé. | ||
46 | -Il reste à incorpoter Ansible dans les codes. | 58 | +- Site 95% terminé par rapport à ce qui a été demandé |
59 | +- Reste le lancement des scripts Ansible depuis le site | ||
47 | 60 | ||
48 | ## Fabriqué avec | 61 | ## Fabriqué avec |
49 | 62 | ||
50 | -* **nano** - Editeur de textes | ||
51 | -* **Geany** - Editeur de textes | ||
52 | * **emacs** - Editeur de textes | 63 | * **emacs** - Editeur de textes |
53 | 64 | ||
54 | ## Auteurs | 65 | ## Auteurs |
@@ -0,0 +1,88 @@ | @@ -0,0 +1,88 @@ | ||
1 | +export CC = avr-gcc | ||
2 | + | ||
3 | +export MCU = atmega328p | ||
4 | +export TARGET_ARCH = -mmcu=$(MCU) | ||
5 | + | ||
6 | +export CFLAGS = -Wall -I. -DF_CPU=16000000 -Os #-pedantic -std=c99#-g | ||
7 | +export LDFLAGS = -g $(TARGET_ARCH) -lm -Wl,--gc-sections # -Os | ||
8 | + | ||
9 | +TARGET = libretour | ||
10 | +TERM0 = /dev/ttyACM0 | ||
11 | +TERM1 = /dev/ttyACM1 | ||
12 | +CPPFLAGS = -mmcu=$(MCU) | ||
13 | +#PGMER = -c stk500v1 -b 57600 -P $(TERM) | ||
14 | +#Dans le cas de l'upload par USB (selon le port) | ||
15 | +PGMERISP0 = -c stk500v1 -b 115200 -P $(TERM0) | ||
16 | +PGMERISP1 = -c stk500v1 -b 115200 -P $(TERM1) | ||
17 | +ARVDUDECONF= -C /usr/local/arduino/arduino-0021/hardware/tools/avrdude.conf | ||
18 | +export DUDE = /usr/bin/avrdude -F -v -p $(MCU) $(AVRDUDECONF) | ||
19 | +#Dans le cas de l'upload par SPI depuis la raspberry | ||
20 | +PGMERISP_RPI = -c pi_3 | ||
21 | +ARVDUDECONF_RPI = -C ~/avrdude_gpio.conf | ||
22 | +export DUDE_RPI = avrdude -v -p $(MCU) $(AVRDUDECONF_RPI) | ||
23 | + | ||
24 | +CLIB=ar cq | ||
25 | +C_SRC = $(wildcard *.c) | ||
26 | +OBJS = $(C_SRC:.c=.o) | ||
27 | + | ||
28 | +all: $(TARGET).a | ||
29 | + | ||
30 | + | ||
31 | +clean: | ||
32 | + rm -f *.o *.hex *.elf *.a build-uno | ||
33 | + | ||
34 | +$(TARGET).o: $(TARGET).c $(TARGET).h | ||
35 | + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ | ||
36 | + | ||
37 | + | ||
38 | +$(TARGET).elf: $(OBJS) | ||
39 | + $(CC) $(LDFLAGS) -o $@ $(OBJS) | ||
40 | + | ||
41 | +$(TARGET).hex: $(TARGET).elf | ||
42 | + avr-objcopy -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex | ||
43 | + avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex $(TARGET).elf eeprom.hex | ||
44 | + | ||
45 | +$(TARGET).a: $(TARGET).o | ||
46 | + rm -rf $@ | ||
47 | + $(CLIB) $@ $+ | ||
48 | + | ||
49 | + | ||
50 | +#UPLOAD CONDITIONNEL | ||
51 | +FOLDER = $(notdir $(CURDIR)) | ||
52 | + | ||
53 | +upload: $(TARGET).hex | ||
54 | +#CAPTEUR 1 connecté en USB | ||
55 | +ifeq ($(FOLDER), capteur1-0) | ||
56 | + | ||
57 | + stty -F $(TERM0) hupcl # reset | ||
58 | + # $(DUDE) $(PGMER) -U flash:w:$(TARGET).hex | ||
59 | + $(DUDE) $(PGMERISP0) -U flash:w:$(TARGET).hex | ||
60 | +endif | ||
61 | + | ||
62 | +#CAPTEUR 1 connecté en SPI | ||
63 | +ifeq ($(FOLDER), capteur1-1) | ||
64 | + | ||
65 | + stty -F $(TERM0) hupcl # reset | ||
66 | + # $(DUDE) $(PGMER) -U flash:w:$(TARGET).hex | ||
67 | + $(DUDE_RPI) $(PGMERISP_RPI) -U flash:w:$(TARGET).hex | ||
68 | +endif | ||
69 | + | ||
70 | +#CAPTEUR 2 connecté en USB | ||
71 | +ifeq ($(FOLDER), capteur2-0) | ||
72 | + | ||
73 | + stty -F $(TERM1) hupcl # reset | ||
74 | + # $(DUDE) $(PGMER) -U flash:w:$(TARGET).hex | ||
75 | + $(DUDE) $(PGMERISP1) -U flash:w:$(TARGET).hex | ||
76 | +endif | ||
77 | + | ||
78 | +#CAPTEUR 2 connecté en SPI | ||
79 | +ifeq ($(FOLDER), capteur2-1) | ||
80 | + | ||
81 | + stty -F $(TERM1) hupcl # reset | ||
82 | + # $(DUDE) $(PGMER) -U flash:w:$(TARGET).hex | ||
83 | + $(DUDE_RPI) $(PGMERISP_RPI) -U flash:w:$(TARGET).hex | ||
84 | +endif | ||
85 | + | ||
86 | +size: $(TARGET).elf | ||
87 | + avr-size --format=avr --mcu=$(MCU) $(TARGET).elf | ||
88 | + |
@@ -0,0 +1,82 @@ | @@ -0,0 +1,82 @@ | ||
1 | +#include <avr/io.h> | ||
2 | +#include <avr/interrupt.h> | ||
3 | +#include <util/delay.h> | ||
4 | +#include <string.h> | ||
5 | +#include <stdlib.h> | ||
6 | +#include <stdio.h> | ||
7 | + | ||
8 | +//#ifndef RETOUR_H_ | ||
9 | +//#define RETOUR_H_ | ||
10 | + | ||
11 | +#include "libretour.h" | ||
12 | + | ||
13 | +//#endif | ||
14 | +#define PRESCALER 1024 | ||
15 | +#define TIME_SLOT 20 | ||
16 | +#define BAUDRATE 103 | ||
17 | + | ||
18 | +static volatile int pulse = 0; | ||
19 | +static volatile int i = 0; | ||
20 | + | ||
21 | + | ||
22 | +////////////////////////////////////////////// | ||
23 | + | ||
24 | +ISR(INT0_vect){ | ||
25 | + //i=1 indique l'écho HIGH | ||
26 | + if(i == 1) | ||
27 | + { | ||
28 | + //On arrête le timer | ||
29 | + TCCR1B = 0; | ||
30 | + //On stocke la valeur précédente du timer (l'aller-retour) | ||
31 | + pulse = TCNT1; | ||
32 | + //On reset la valeur de TCNT1 et de i à Zero | ||
33 | + TCNT1 = 0; | ||
34 | + i = 0; | ||
35 | + } | ||
36 | + | ||
37 | + //i=0 indique l'écho à LOW | ||
38 | + if(i==0) | ||
39 | + { | ||
40 | + //On set le bit CS10 à HIGH, debut du timer qui compte | ||
41 | + TCCR1B |= (1<<CS10); | ||
42 | + i = 1; | ||
43 | + } | ||
44 | +} | ||
45 | + | ||
46 | + | ||
47 | +int main(void){ | ||
48 | + init_serial(); | ||
49 | + int16_t count_a = 0; | ||
50 | + char show_a[16]; | ||
51 | + //Trigger = PIND0 et ECHO = PIND2 | ||
52 | + DDRD = 0b11111011; | ||
53 | + _delay_ms(50); | ||
54 | + //Selection INT0 | ||
55 | + EIMSK |= (1<<INT0); | ||
56 | + //Interruption sur changement logique | ||
57 | + EICRA = 0x01; | ||
58 | + sei(); | ||
59 | + | ||
60 | + while(1) | ||
61 | + { | ||
62 | + //TRIGGER HIGH | ||
63 | + PORTD |= 1<<PIND0; | ||
64 | + //Durée de l'impulsion TRIGGER | ||
65 | + _delay_us(15); | ||
66 | + //TRIGGER LOW | ||
67 | + PORTD &= ~(1<<PIND0); | ||
68 | + //On calcule la distance en cm : pulse/(58/2/10) (en cm) | ||
69 | + count_a = pulse/1160.0; | ||
70 | + | ||
71 | + itoa(count_a,show_a,10); | ||
72 | + //dtostrf(count_a, 5,2, show_a); | ||
73 | + sprintf(show_a, "%d", count_a); | ||
74 | + //send_serial('D'); | ||
75 | + //send_serial('='); | ||
76 | + //RETOUR | ||
77 | + retour(show_a); | ||
78 | + _delay_ms(1000); | ||
79 | + | ||
80 | + } | ||
81 | + return 0; | ||
82 | +} |
@@ -0,0 +1,73 @@ | @@ -0,0 +1,73 @@ | ||
1 | +#include <avr/io.h> | ||
2 | +#include <avr/interrupt.h> | ||
3 | +#include <util/delay.h> | ||
4 | +#include <string.h> | ||
5 | +#include <stdlib.h> | ||
6 | +#include <stdio.h> | ||
7 | + | ||
8 | + | ||
9 | +#define PRESCALER 1024 | ||
10 | +#define TIME_SLOT 20 | ||
11 | +#define BAUDRATE 103 | ||
12 | + | ||
13 | +//// INIT SERIAL ///// | ||
14 | + | ||
15 | +void init_serial(void) | ||
16 | +{ | ||
17 | + /* ACHTUNG : we suppose UBRR value < 0xff */ | ||
18 | + /* Not true in all case */ | ||
19 | + uint8_t baudrate = BAUDRATE; | ||
20 | + /* Set baud rate */ | ||
21 | + UBRR0H = 0; | ||
22 | + UBRR0L = baudrate; | ||
23 | + | ||
24 | + UCSR0B = (1<<TXEN0); | ||
25 | + /* Set frame format */ | ||
26 | + UCSR0C = 0x06; | ||
27 | + | ||
28 | +} | ||
29 | + | ||
30 | +//// ENVOI DE MESSAGES ///// | ||
31 | + | ||
32 | +void send_serial(unsigned char c) | ||
33 | +{ | ||
34 | + loop_until_bit_is_set(UCSR0A, UDRE0); | ||
35 | + UDR0 = c; | ||
36 | +} | ||
37 | + | ||
38 | + | ||
39 | +void send_msg2(char Donnee[]){ | ||
40 | + | ||
41 | + while (( UCSR0A & (1<<UDRE0)) == 0){}; | ||
42 | + | ||
43 | + for (int i = 0; i < strlen(Donnee); i++){ | ||
44 | + while (( UCSR0A & (1<<UDRE0)) == 0){}; | ||
45 | + UDR0 = Donnee[i]; | ||
46 | + if (i == (strlen(Donnee) - 1)){ | ||
47 | + send_serial('\n'); | ||
48 | + send_serial('\r'); | ||
49 | + } | ||
50 | + } | ||
51 | +} | ||
52 | + | ||
53 | +void send_msg(char Donnee[]){ | ||
54 | + int i=0; | ||
55 | + for(i=0; i<strlen(Donnee); i++){ | ||
56 | + if (i==strlen(Donnee)-1){ | ||
57 | + send_serial(Donnee[i]); | ||
58 | + send_serial('\n'); | ||
59 | + send_serial('\r'); | ||
60 | + } | ||
61 | + else{ | ||
62 | + send_serial(Donnee[i]); | ||
63 | + } | ||
64 | + _delay_ms(100); | ||
65 | + } | ||
66 | +} | ||
67 | + | ||
68 | +//////// RETOUR ///////// | ||
69 | +void retour(char* show_a){ | ||
70 | + send_msg2(show_a); | ||
71 | +} | ||
72 | + | ||
73 | + |
@@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
1 | +#include <avr/io.h> // for the input/output register | ||
2 | +#include <avr/interrupt.h> | ||
3 | +#include <util/delay.h> | ||
4 | +#include <string.h> | ||
5 | +#include <stdio.h> | ||
6 | +#include <stdlib.h> | ||
7 | + | ||
8 | +#include "libretour.h" | ||
9 | + | ||
10 | +#define PRESCALER 1024 | ||
11 | +#define TIME_SLOT 20 | ||
12 | +#define BAUDRATE 103 | ||
13 | + | ||
14 | +#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) | ||
15 | +#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) | ||
16 | + | ||
17 | +char Donnee[24]; | ||
18 | +float temp; | ||
19 | + | ||
20 | +// équivalent de analogueRead() | ||
21 | +int analogReadNew(uint8_t pin) { | ||
22 | + //Selection de la fréquence du prescaler | ||
23 | + ADCSRA |= (1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); | ||
24 | + //Définition de la référence de tension | ||
25 | + ADMUX |= (1<<REFS0)|(1<<ADLAR); | ||
26 | + //Sélection de l'entrée analogique selon le pin | ||
27 | + ADMUX = (ADMUX&0xf0)|pin; | ||
28 | + //Activation de l'ADC | ||
29 | + ADCSRA |= (1<<ADEN); | ||
30 | + //Lancement de la conversion | ||
31 | + ADCSRA |= (1<<ADSC); | ||
32 | + //On attend la fin de la conversion | ||
33 | + while(bit_is_set(ADCSRA, ADSC)); | ||
34 | + //Résultat | ||
35 | + return ADCH; | ||
36 | +} | ||
37 | + | ||
38 | +int main() | ||
39 | +{ | ||
40 | + int reading; | ||
41 | + init_serial(); | ||
42 | + while(1){ | ||
43 | + reading=analogReadNew(0); | ||
44 | + temp = reading * 1.9607843; | ||
45 | + dtostrf(temp, 4, 1, Donnee); | ||
46 | + //send_serial('T'); | ||
47 | + //send_serial('='); | ||
48 | + //RETOUR | ||
49 | + retour(Donnee); | ||
50 | + _delay_ms(2000); | ||
51 | + } | ||
52 | + return 0; | ||
53 | +} |
site/accesBase.php
1 | <?php | 1 | <?php |
2 | function connexion() | 2 | function connexion() |
3 | { | 3 | { |
4 | - $machine='serveur-etu.polytech-lille.fr' ; | 4 | + $machine = 'localhost' ; |
5 | $user='grouille' ; | 5 | $user='grouille' ; |
6 | $pwd='postgres' ; | 6 | $pwd='postgres' ; |
7 | $db='projetCapteurs' ; | 7 | $db='projetCapteurs' ; |
@@ -88,11 +88,27 @@ | @@ -88,11 +88,27 @@ | ||
88 | //Test3: extension | 88 | //Test3: extension |
89 | $ext = substr(strrchr($_FILES[$index]['name'],'.'),1); | 89 | $ext = substr(strrchr($_FILES[$index]['name'],'.'),1); |
90 | if ($extensions !== FALSE AND !in_array($ext,$extensions)) return FALSE; | 90 | if ($extensions !== FALSE AND !in_array($ext,$extensions)) return FALSE; |
91 | - $name = 'binaire'; | 91 | + $name = "binaire"; |
92 | $extension_upload = strtolower( substr( strrchr($_FILES['fichier']['name'], '.') ,1) ); | 92 | $extension_upload = strtolower( substr( strrchr($_FILES['fichier']['name'], '.') ,1) ); |
93 | - $fichier = "upload/{$name}.{$extension_upload}"; | 93 | + $dossier = "upload/"; |
94 | + $fichier = $name.".".$extension_upload; | ||
94 | //$fichier = basename($_FILES[$index]['name']); | 95 | //$fichier = basename($_FILES[$index]['name']); |
95 | - return move_uploaded_file($_FILES['fichier']['tmp_name'],$fichier); | 96 | + return move_uploaded_file($_FILES['fichier']['tmp_name'],$dossier.$fichier); |
97 | + } | ||
98 | + | ||
99 | + function load($tmp_name, $name) | ||
100 | + { | ||
101 | + $dossier = "upload/"; | ||
102 | + $fichier = "binaire.c"; | ||
103 | + $taille_max = 100000; | ||
104 | + $taille = filesize($tmp_name); | ||
105 | + $extensions = Array('.c'); | ||
106 | + $extension = strrchr($name, '.'); | ||
107 | + if(in_array($extension, $extensions) && taille <= taille_max) | ||
108 | + { | ||
109 | + return move_uploaded_file($tmp_name, $dossier.$fichier); | ||
110 | + } | ||
111 | + return False; | ||
96 | } | 112 | } |
97 | 113 | ||
98 | function update_values() | 114 | function update_values() |
@@ -113,14 +129,14 @@ | @@ -113,14 +129,14 @@ | ||
113 | deconnexion($db); | 129 | deconnexion($db); |
114 | } | 130 | } |
115 | 131 | ||
116 | - function update_bdd($ip_address, $numero, $name, $data, $date) | 132 | + function update_bdd($ip_address, $numero, $data, $date) |
117 | { | 133 | { |
134 | + $name = getSensorName($ip_address, $numero); | ||
118 | $db = connexion(); | 135 | $db = connexion(); |
119 | $ip_address = (string)$ip_address; | 136 | $ip_address = (string)$ip_address; |
120 | $numero = (int)$numero; | 137 | $numero = (int)$numero; |
121 | - $name = (string)$name; | ||
122 | $data = (float)$data; | 138 | $data = (float)$data; |
123 | - $query = "UPDATE capteurs SET value='$data' WHERE raspberry='$ip_address' and numero='$numero' and nom='$name'"; | 139 | + $query = "UPDATE capteurs SET value=$data WHERE raspberry='$ip_address' and numero=$numero and nom='$name'"; |
124 | $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); | 140 | $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); |
125 | $query = "INSERT INTO history VALUES('$name', '$data', '$date')"; | 141 | $query = "INSERT INTO history VALUES('$name', '$data', '$date')"; |
126 | $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); | 142 | $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); |
@@ -171,7 +187,74 @@ | @@ -171,7 +187,74 @@ | ||
171 | return $tab; | 187 | return $tab; |
172 | } | 188 | } |
173 | 189 | ||
174 | - function add($nom, $type, $raspberry, $numero, $unite) | 190 | + function getSensorName($raspberry, $numero) |
191 | + { | ||
192 | + $db = connexion(); | ||
193 | + $query = "SELECT nom FROM capteurs where raspberry = '$raspberry' AND numero = $numero"; | ||
194 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | ||
195 | + $tab = pg_fetch_assoc($result); | ||
196 | + deconnexion($db); | ||
197 | + return $tab['nom']; | ||
198 | + } | ||
199 | + | ||
200 | + function getSensorVersion($raspberry, $numero) | ||
201 | + { | ||
202 | + $db = connexion(); | ||
203 | + $query = "SELECT version FROM capteurs where raspberry = '$raspberry' AND numero = $numero"; | ||
204 | + $result = pg_query($db, $query) or die("La requète a echoué : ".pg_last_error()); | ||
205 | + $tab = pg_fetch_assoc($result); | ||
206 | + deconnexion($db); | ||
207 | + return (int)$tab['version']; | ||
208 | + } | ||
209 | + | ||
210 | + function getRaspberrys() | ||
211 | + { | ||
212 | + $db = connexion(); | ||
213 | + $query = "SELECT * FROM raspberry"; | ||
214 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | ||
215 | + $tab = pg_fetch_all($result); | ||
216 | + deconnexion($db); | ||
217 | + return $tab; | ||
218 | + } | ||
219 | + | ||
220 | + function getSetup($raspberry) | ||
221 | + { | ||
222 | + $db = connexion(); | ||
223 | + $query = "SELECT setup FROM raspberry WHERE ip = '$raspberry'"; | ||
224 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | ||
225 | + $tab = pg_fetch_assoc($result); | ||
226 | + deconnexion($db); | ||
227 | + return $tab['setup']; | ||
228 | + } | ||
229 | + | ||
230 | + function setup($raspberry) | ||
231 | + { | ||
232 | + $db = connexion(); | ||
233 | + $query = "UPDATE raspberry SET setup = 0 WHERE ip = '$raspberry'"; | ||
234 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | ||
235 | + deconnexion($db); | ||
236 | + } | ||
237 | + | ||
238 | + function addRpi($ip) | ||
239 | + { | ||
240 | + $raspberry = "172.26.145.".$ip; | ||
241 | + $db = connexion(); | ||
242 | + $query = "SELECT * FROM raspberry WHERE ip = '$raspberry'"; | ||
243 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | ||
244 | + if (pg_affected_rows($result)!=0) | ||
245 | + { | ||
246 | + deconnexion($db); | ||
247 | + return False; | ||
248 | + } | ||
249 | + else{ | ||
250 | + $query = "INSERT INTO raspberry VALUES('$raspberry', 1)"; | ||
251 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | ||
252 | + deconnexion($db); | ||
253 | + return pg_affected_rows($result)==1; | ||
254 | + } | ||
255 | + } | ||
256 | + | ||
257 | + function add($nom, $type, $raspberry, $numero, $unite, $version) | ||
175 | { | 258 | { |
176 | $db = connexion(); | 259 | $db = connexion(); |
177 | $query = "SELECT * FROM capteurs WHERE nom = '$nom' OR (raspberry = '$raspberry' AND numero = '$numero')"; | 260 | $query = "SELECT * FROM capteurs WHERE nom = '$nom' OR (raspberry = '$raspberry' AND numero = '$numero')"; |
@@ -181,7 +264,7 @@ | @@ -181,7 +264,7 @@ | ||
181 | } | 264 | } |
182 | else | 265 | else |
183 | { | 266 | { |
184 | - $query = "INSERT INTO capteurs VALUES($numero, '$nom', '$raspberry', '$type', 0, '$unite')"; | 267 | + $query = "INSERT INTO capteurs VALUES($numero, '$nom', '$raspberry', '$type', 0, '$unite', $version)"; |
185 | $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); | 268 | $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); |
186 | if (pg_affected_rows($result)!=0){ | 269 | if (pg_affected_rows($result)!=0){ |
187 | return True; | 270 | return True; |
@@ -190,5 +273,40 @@ | @@ -190,5 +273,40 @@ | ||
190 | return False; | 273 | return False; |
191 | } | 274 | } |
192 | } | 275 | } |
193 | - } | 276 | + } |
277 | + | ||
278 | + function makeArray($tab, $column) | ||
279 | + { | ||
280 | + foreach($tab as $element) | ||
281 | + { | ||
282 | + $array[] = $element[$column]; | ||
283 | + } | ||
284 | + return $array; | ||
285 | + } | ||
286 | + | ||
287 | + function getLegend($nom) | ||
288 | + { | ||
289 | + $db = connexion(); | ||
290 | + $query = "SELECT type, unite FROM capteurs WHERE nom = '$nom'"; | ||
291 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | ||
292 | + $tab = pg_fetch_assoc($result); | ||
293 | + deconnexion($db); | ||
294 | + return $tab; | ||
295 | + } | ||
296 | + | ||
297 | + function historyExist($sensor) | ||
298 | + { | ||
299 | + $db = connexion(); | ||
300 | + $query = "SELECT * FROM history WHERE sensor = '$sensor'"; | ||
301 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | ||
302 | + deconnexion($db); | ||
303 | + if(pg_affected_rows($result)!=0) | ||
304 | + { | ||
305 | + return True; | ||
306 | + } | ||
307 | + else | ||
308 | + { | ||
309 | + return False; | ||
310 | + } | ||
311 | + } | ||
194 | ?> | 312 | ?> |
site/add.php
@@ -18,10 +18,31 @@ session_start(); | @@ -18,10 +18,31 @@ session_start(); | ||
18 | <div class="row"> | 18 | <div class="row"> |
19 | <div class="col-6 col-md-6 offset-md-3 offset-3"> | 19 | <div class="col-6 col-md-6 offset-md-3 offset-3"> |
20 | <br/> | 20 | <br/> |
21 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-history"></i> Historique</h1> | 21 | + <h1 style="margin-bottom:20px; margin-top:70px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-history"></i> Historique</h1> |
22 | <?php | 22 | <?php |
23 | - if(add($_POST['nom'], $_POST['type'], $_POST['raspberry'], $_POST['numero'], $_POST['unite'])) | 23 | + if(add($_POST['nom'], $_POST['type'], $_POST['raspberry'], $_POST['numero'], $_POST['unite'], $_POST['version'])) |
24 | { | 24 | { |
25 | + $arduino_simple = "[Arduino_init]\r\n"; | ||
26 | + $arduino_spi = "[Arduino_spi_init]\r\n"; | ||
27 | + $nucleo = "[Nucleo_init]\r\n"; | ||
28 | + | ||
29 | + $setup = getSetup($_POST['raspberry']); | ||
30 | + | ||
31 | + if($_POST['version'] == 0) | ||
32 | + { | ||
33 | + $ini = $arduino_simple; | ||
34 | + } | ||
35 | + elseif($_POST['version'] == 1) | ||
36 | + { | ||
37 | + $ini = $arduino_spi; | ||
38 | + } | ||
39 | + elseif($_POST['version'] == 2) | ||
40 | + { | ||
41 | + $ini = $nucleo; | ||
42 | + } | ||
43 | + $ini = $ini.$_POST['raspberry']." capteur=".$_POST['numero']." setup=".$setup."\n"; | ||
44 | + file_put_contents('upload/inventaire.ini', $ini); | ||
45 | + setup($_POST['raspberry']); | ||
25 | ?> | 46 | ?> |
26 | <div class="alert alert-success" role="alert"> | 47 | <div class="alert alert-success" role="alert"> |
27 | Le capteur a bien été ajouté ! | 48 | Le capteur a bien été ajouté ! |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +<div class="row"> | ||
2 | + <div class="col-6 col-md-6 offset-md-3 offset-3"> | ||
3 | + <br/> | ||
4 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="far fa-plus-square"></i> Ajout d'une Raspberry</h1> | ||
5 | + <form action="addRpi.php" method="post"> | ||
6 | + <table class="table table-striped table-bordered"> | ||
7 | + <tbody> | ||
8 | + <tr> | ||
9 | + <td><label for="ip">Adresse IP : 172.26.145. </label></td> | ||
10 | + <td><input type="text" id="ip" name="ip" placeholder="114" size="3" minlength="3" maxlength="3"/></td> | ||
11 | + </tr> | ||
12 | + </tbody> | ||
13 | + </table> | ||
14 | + <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px; margin-bottom:20px;" value="Ajouter la Raspberry"/> | ||
15 | + <br/> | ||
16 | + </form> | ||
17 | + </div> | ||
18 | +</div> |
site/test.php renamed to site/addRpi.php
@@ -18,24 +18,24 @@ session_start(); | @@ -18,24 +18,24 @@ session_start(); | ||
18 | <div class="row"> | 18 | <div class="row"> |
19 | <div class="col-6 col-md-6 offset-md-3 offset-3"> | 19 | <div class="col-6 col-md-6 offset-md-3 offset-3"> |
20 | <br/> | 20 | <br/> |
21 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-history"></i> Historique</h1> | 21 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-history"></i> Historique</h1> |
22 | <?php | 22 | <?php |
23 | - if(add($_POST['nom'], $_POST['type'], $_POST['raspberry'], $_POST['numero'], $_POST['unite']) | 23 | + if(addRpi($_POST['ip'])) |
24 | { | 24 | { |
25 | ?> | 25 | ?> |
26 | <div class="alert alert-success" role="alert"> | 26 | <div class="alert alert-success" role="alert"> |
27 | - Le capteur a bien été ajouté ! | 27 | + La Raspberry a bien été ajouté ! Vous devez maintenant suivre le protocole ci-dessous pour terminer l'installation. |
28 | </div> | 28 | </div> |
29 | - <meta http-equiv="Refresh" content="3;url=accueil.php" /> | 29 | + Protocole |
30 | <?php | 30 | <?php |
31 | } | 31 | } |
32 | else | 32 | else |
33 | { | 33 | { |
34 | ?> | 34 | ?> |
35 | <div class="alert alert-danger" role="alert"> | 35 | <div class="alert alert-danger" role="alert"> |
36 | - Echec lors de l'ajout. Vérifiez vos informations ! | 36 | + Echec lors de l'ajout. La Raspberry existe peut-être déjà ! |
37 | </div> | 37 | </div> |
38 | - <meta http-equiv="Refresh" content="3;url=ajoutCapteur.php" /> | 38 | + <meta http-equiv="Refresh" content="3;url=ajoutRaspberry.php" /> |
39 | <?php | 39 | <?php |
40 | } | 40 | } |
41 | ?> | 41 | ?> |
site/addSensor.php
1 | +<?php | ||
2 | +$raspberrys = getRaspberrys(); | ||
3 | +?> | ||
1 | <div class="row"> | 4 | <div class="row"> |
2 | <div class="col-4 col-md-4 offset-md-4 offset-4"> | 5 | <div class="col-4 col-md-4 offset-md-4 offset-4"> |
3 | <br/> | 6 | <br/> |
4 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="far fa-plus-square"></i> Ajout d'un capteur</h1> | 7 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="far fa-plus-square"></i> Ajout d'un capteur</h1> |
5 | <form action="add.php" method="post"> | 8 | <form action="add.php" method="post"> |
6 | <table class="table table-striped table-bordered"> | 9 | <table class="table table-striped table-bordered"> |
7 | <tbody> | 10 | <tbody> |
@@ -17,7 +20,17 @@ | @@ -17,7 +20,17 @@ | ||
17 | 20 | ||
18 | <tr> | 21 | <tr> |
19 | <td><label for="raspberry">Raspberry : </label></td> | 22 | <td><label for="raspberry">Raspberry : </label></td> |
20 | - <td><input type="text" id="raspberry" name="raspberry" /></td> | 23 | + <td> |
24 | + <div class="form-group my-1 mr-sm-2"> | ||
25 | + <select class="custom-select my-1 mr-sm-2" id="raspberry" name="raspberry"> | ||
26 | + <?php | ||
27 | + foreach($raspberrys as $raspberry) | ||
28 | + { ?> | ||
29 | + <option><?php echo $raspberry['ip'];?></option> | ||
30 | + <?php }?> | ||
31 | + </select> | ||
32 | + </div> | ||
33 | + </td> | ||
21 | </tr> | 34 | </tr> |
22 | 35 | ||
23 | <tr> | 36 | <tr> |
@@ -29,13 +42,21 @@ | @@ -29,13 +42,21 @@ | ||
29 | <td><label for="unite">Unite de mesure : </label></td> | 42 | <td><label for="unite">Unite de mesure : </label></td> |
30 | <td><input type="text" id="unite" name="unite" /></td> | 43 | <td><input type="text" id="unite" name="unite" /></td> |
31 | </tr> | 44 | </tr> |
32 | - | 45 | + |
33 | <tr> | 46 | <tr> |
34 | - <td></td> | ||
35 | - <td><input type="submit" class="btn btn-dark" value="Ajouter le capteur"/></td> | 47 | + <td><label for="version">Version : </lavel></td> |
48 | + <td> | ||
49 | + <select id="version" name="version"> | ||
50 | + <option value=0 selected>Arduino USB</option> | ||
51 | + <option value=1>Arduino SPI</option> | ||
52 | + <option value=2>Nucléo USB</option> | ||
53 | + </select> | ||
54 | + </td> | ||
36 | </tr> | 55 | </tr> |
37 | </tbody> | 56 | </tbody> |
38 | </table> | 57 | </table> |
58 | + <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px; margin-bottom:20px;" value="Ajouter le capteur"/> | ||
59 | + <br/> | ||
39 | </form> | 60 | </form> |
40 | </div> | 61 | </div> |
41 | </div> | 62 | </div> |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +<?php | ||
2 | +session_start(); | ||
3 | +?> | ||
4 | +<!DOCTYPE html> | ||
5 | + | ||
6 | +<html> | ||
7 | + <head> | ||
8 | + <?php include("head.php"); ?> | ||
9 | + </head> | ||
10 | + | ||
11 | + <!-- Contenu du site --> | ||
12 | + <body> | ||
13 | + <?php | ||
14 | + include("header.php"); | ||
15 | + if(isset($_SESSION['Login'], $_SESSION['Password'])) | ||
16 | + { | ||
17 | + include("addRaspberry.php"); | ||
18 | + } | ||
19 | + else | ||
20 | + { | ||
21 | + include("formConnexion.php"); | ||
22 | + } | ||
23 | + ?> | ||
24 | + </body> | ||
25 | +</html> | ||
26 | + |
site/capteurs.php
@@ -5,8 +5,8 @@ $sensors = getSensors(); | @@ -5,8 +5,8 @@ $sensors = getSensors(); | ||
5 | <div class="row"> | 5 | <div class="row"> |
6 | <div class="col-6 col-md-6 offset-md-3 offset-3"> | 6 | <div class="col-6 col-md-6 offset-md-3 offset-3"> |
7 | <br/> | 7 | <br/> |
8 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-bars"></i> Choix du capteur</h1> | ||
9 | - <form action="envoiFichiers.php" method="post" enctype="multipart/form-data"> | 8 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-bars"></i> Choix du capteur</h1> |
9 | + <form action="reception.php" method="post" enctype="multipart/form-data"> | ||
10 | <table class="table table-striped table-bordered"> | 10 | <table class="table table-striped table-bordered"> |
11 | <tbody> | 11 | <tbody> |
12 | <tr> | 12 | <tr> |
@@ -34,17 +34,17 @@ $sensors = getSensors(); | @@ -34,17 +34,17 @@ $sensors = getSensors(); | ||
34 | </tbody> | 34 | </tbody> |
35 | </table> | 35 | </table> |
36 | 36 | ||
37 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-file-upload"></i> Uploader un fichier</h1> | ||
38 | - <div class="panel panel-default"> | 37 | + <h1 style="margin-bottom:20px; margin-top:30px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-file-upload"></i> Uploader un fichier</h1> |
38 | + <div class="panel panel-default"> | ||
39 | 39 | ||
40 | <div class="form-group"> | 40 | <div class="form-group"> |
41 | - <label for="exampleFormControlFile1">Charger un fichier</label> | ||
42 | - <input type="file" name="fichier" class="form-control-file" id="fichier"> | ||
43 | - <input type="hidden" name="MAX_FILE_SIZE" value="1048576" /> | 41 | + <label for="fichier">Charger un fichier</label> |
42 | + <input type="file" name="fichier" class="form-control-file" id="fichier"> | ||
44 | </div> | 43 | </div> |
45 | 44 | ||
46 | </div> | 45 | </div> |
47 | - <input type="submit" class="btn btn-dark btn-lg btn-block"style="margin-top:50px;" value="Envoyer"/> | 46 | + <input type="submit" class="btn btn-dark btn-lg btn-block"style="margin-top:20px;" value="Envoyer"/> |
47 | + <br/> | ||
48 | </form> | 48 | </form> |
49 | </div> | 49 | </div> |
50 | -</div> | ||
51 | \ No newline at end of file | 50 | \ No newline at end of file |
51 | +</div> |
site/connecter.php
1 | <?php | 1 | <?php |
2 | session_start(); | 2 | session_start(); |
3 | require("accesBase.php") ; | 3 | require("accesBase.php") ; |
4 | + | ||
5 | +if(verifPwd($_POST["id"], $_POST["pwd"])) | ||
6 | +{ | ||
7 | + $_SESSION['Login'] = $_POST['id']; | ||
8 | + $_SESSION['Password'] = $_POST['pwd']; | ||
9 | + $connect = true; | ||
10 | +} | ||
11 | +else | ||
12 | +{ | ||
13 | + $connect = false; | ||
14 | +} | ||
4 | ?> | 15 | ?> |
5 | 16 | ||
6 | <!DOCTYPE html> | 17 | <!DOCTYPE html> |
@@ -15,28 +26,27 @@ require("accesBase.php") ; | @@ -15,28 +26,27 @@ require("accesBase.php") ; | ||
15 | <?php include("header.php"); ?> | 26 | <?php include("header.php"); ?> |
16 | 27 | ||
17 | <!-- Centre de la page --> | 28 | <!-- Centre de la page --> |
18 | - <div class="container-fluid"> | ||
19 | - <div class="row"> | ||
20 | 29 | ||
21 | - <!-- Contenu de la page --> | ||
22 | - <!-- Connexion --> | ||
23 | - <div class="row syst"> | ||
24 | - <div class="connect"> | ||
25 | - <?php | ||
26 | - if (verifPwd($_POST["id"], $_POST["pwd"])){ | ||
27 | - $_SESSION['Login'] = $_POST['id']; | ||
28 | - $_SESSION['Password'] = $_POST['pwd']; | ||
29 | - ?><meta http-equiv="Refresh" content="0;url=accueil.php" /><?php | ||
30 | - } | ||
31 | - else | ||
32 | - echo "---------------------erreur de mdp";?> | ||
33 | - </div> | ||
34 | - </div> | ||
35 | - <!-- fin connexion --> | 30 | + <?php |
31 | + if($connect) | ||
32 | + { | ||
33 | + ?><meta http-equiv="Refresh" content="0;url=accueil.php" /><?php | ||
34 | + } | ||
35 | + else | ||
36 | + { | ||
37 | + ?> | ||
38 | + <div class="row"> | ||
39 | + <div class="col-4 col-md-4 offset-4 offset-md-4"> | ||
40 | + <br/> | ||
41 | + <div class="alert alert-danger" role="alert"> | ||
42 | + Identifiant ou mot de passe incorrect ! | ||
36 | </div> | 43 | </div> |
37 | - <!-- fin contenu de la page --> | ||
38 | </div> | 44 | </div> |
39 | </div> | 45 | </div> |
40 | - <!-- fin centre de la page --> | 46 | + <!-- <meta http-equiv="Refresh" content="5;url=accueil.php" /> --> |
47 | + <?php | ||
48 | + include("formConnexion.php"); | ||
49 | + } | ||
50 | + ?> | ||
41 | </body> | 51 | </body> |
42 | </html> | 52 | </html> |
site/envoiFichiers.php deleted
@@ -1,99 +0,0 @@ | @@ -1,99 +0,0 @@ | ||
1 | -<?php | ||
2 | -session_start(); | ||
3 | -$error = false; | ||
4 | - | ||
5 | -if ( isset($_POST['sensor']) && count($_POST['sensor']<>0) ) { | ||
6 | - $xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\r\n" | ||
7 | - .'<all>'; | ||
8 | - foreach($_POST['sensor'] as $sensor => $value) | ||
9 | - { | ||
10 | - $val = explode(":", $value); | ||
11 | - if(count($types)<>0 && !in_array($val[2], $types)) {$error = true;} | ||
12 | - else {$types[] = $val[2];} | ||
13 | - $xml = $xml. '<sensor>' . '<raspberry>' . htmlspecialchars($val[0]) . '</raspberry>' . '<numero>' . htmlspecialchars($val[1]) . '</numero>' . '</sensor>'; | ||
14 | - $xml = $xml."\r\n"; | ||
15 | - } | ||
16 | - $xml = $xml.'</all>'; | ||
17 | - if(!$error) {file_put_contents('upload/sensor.xml', $xml) ;} | ||
18 | -} | ||
19 | -?> | ||
20 | -<!DOCTYPE html> | ||
21 | - | ||
22 | -<html> | ||
23 | - <head> | ||
24 | - <?php include("head.php"); ?> | ||
25 | - </head> | ||
26 | - | ||
27 | - <!-- Contenu du site --> | ||
28 | - <body> | ||
29 | - <?php | ||
30 | - include("header.php"); | ||
31 | - if(!$error) | ||
32 | - { | ||
33 | - $upload1 = upload('fichier',FALSE, array('c', 'txt') ); | ||
34 | - ?> | ||
35 | - <div class="row"> | ||
36 | - <div class="col-4 col-md-4 offset-md-4 offset-4"> | ||
37 | - <br/> | ||
38 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-cloud"></i> Envoi du fichier en ligne</h1> | ||
39 | - <?php if($upload1){ | ||
40 | - ?> | ||
41 | - <div class="alert alert-success" role="alert"> | ||
42 | - Upload du fichier réussi ! | ||
43 | - </div> | ||
44 | - <?php | ||
45 | - } | ||
46 | - else {?> | ||
47 | - <div class="alert alert-danger" role="alert"> | ||
48 | - Erreur lors du transfert du fichier ! | ||
49 | - </div><?php | ||
50 | - } | ||
51 | - ?> | ||
52 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-info-circle"></i> Informations complémentaires</h1> | ||
53 | - <table class="table table-striped table-bordered"> | ||
54 | - <tbody> | ||
55 | - <tr> | ||
56 | - <td>Nom du fichier</td> | ||
57 | - <td><?php echo $_FILES['fichier']['name'];?></td> | ||
58 | - </tr> | ||
59 | - <tr> | ||
60 | - <td>Type</td> | ||
61 | - <td><?php echo $_FILES['fichier']['type'];?></td> | ||
62 | - </tr> | ||
63 | - <tr> | ||
64 | - <td>Localisation</td> | ||
65 | - <td><?php echo $_FILES['fichier']['tmp_name'];?></td> | ||
66 | - </tr> | ||
67 | - <tr> | ||
68 | - <td>Erreur</td> | ||
69 | - <td><?php echo $_FILES['fichier']['error'];?></td> | ||
70 | - </tr> | ||
71 | - <tr> | ||
72 | - <td>Taille</td> | ||
73 | - <td><?php echo $_FILES['fichier']['size'];?></td> | ||
74 | - | ||
75 | - </tr> | ||
76 | - </tbody> | ||
77 | - </table> | ||
78 | - | ||
79 | - </div> | ||
80 | - </div> | ||
81 | - <?php } | ||
82 | - else | ||
83 | - { | ||
84 | - ?> | ||
85 | - <div class="row"> | ||
86 | - <div class="col-4 col-md-4 offset-md-4 offset-4"> | ||
87 | - <br/> | ||
88 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-cloud"></i> Envoi du fichier en ligne</h1> | ||
89 | - <div class="alert alert-danger" role="alert"> | ||
90 | - Vous devez choisir des capteurs de même type ! | ||
91 | - </div> | ||
92 | - <meta http-equiv="Refresh" content="3;url=send.php" /> | ||
93 | - </div> | ||
94 | - </div> | ||
95 | - <?php | ||
96 | - } | ||
97 | - ?> | ||
98 | - </body> | ||
99 | -</html> |
site/formConnexion.php
1 | <div class="row"> | 1 | <div class="row"> |
2 | <div class="col-4 col-md-4 offset-md-4 offset-4"> | 2 | <div class="col-4 col-md-4 offset-md-4 offset-4"> |
3 | <br/> | 3 | <br/> |
4 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-user-shield"></i> Connexion</h1> | 4 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-user-shield"></i> Connexion</h1> |
5 | <form action="connecter.php" method="post"> | 5 | <form action="connecter.php" method="post"> |
6 | <table class="table table-striped table-bordered"> | 6 | <table class="table table-striped table-bordered"> |
7 | <tbody> | 7 | <tbody> |
@@ -12,9 +12,10 @@ | @@ -12,9 +12,10 @@ | ||
12 | <tr><td>Mot de passe :</td> | 12 | <tr><td>Mot de passe :</td> |
13 | <td><input type="password" name="pwd" placeholder="Entrez votre mot de passe" required="true" class="case" /></td> | 13 | <td><input type="password" name="pwd" placeholder="Entrez votre mot de passe" required="true" class="case" /></td> |
14 | </tr> | 14 | </tr> |
15 | - <tr><td></td><td><input type="submit" class="btn btn-dark" value="Se connecter"/></td></tr> | ||
16 | </tbody> | 15 | </tbody> |
17 | </table> | 16 | </table> |
17 | + <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px; margin-bottom:20px;" value="Se connecter"/> | ||
18 | + <br/> | ||
18 | </form> | 19 | </form> |
19 | </div> | 20 | </div> |
20 | -</div> | ||
21 | \ No newline at end of file | 21 | \ No newline at end of file |
22 | +</div> |
@@ -0,0 +1,52 @@ | @@ -0,0 +1,52 @@ | ||
1 | +<?php | ||
2 | +$min = date_min(); | ||
3 | +$mins = explode(" ", $min['min']); | ||
4 | +$date_min = $mins[0]; | ||
5 | + | ||
6 | +$max = date_max(); | ||
7 | +$maxs = explode(" ", $max['max']); | ||
8 | +$date_max = $maxs[0]; | ||
9 | +?> | ||
10 | +<div class="row"> | ||
11 | + <div class="col-6 col-md-6 offset-md-3 offset-3"> | ||
12 | + <br/> | ||
13 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-chart-line"></i> Affichage d'un graphe</h1> | ||
14 | + <form action="graphique.php" method="post"> | ||
15 | + <table class="table table-striped table-bordered"> | ||
16 | + <tbody> | ||
17 | + <tr> | ||
18 | + <td><label for="names">Nom du capteur : </label></td> | ||
19 | + <td> | ||
20 | + <div class="form-group my-1 mr-sm-2"> | ||
21 | + <select class="custom-select my-1 mr-sm-2" id="names" name="nom"> | ||
22 | + <?php | ||
23 | + $names = get(nom); | ||
24 | + foreach($names as $name) | ||
25 | + { ?> | ||
26 | + <option><?php echo $name['nom'];?></option> | ||
27 | + <?php }?> | ||
28 | + </select> | ||
29 | + </div> | ||
30 | + </td> | ||
31 | + </tr> | ||
32 | + | ||
33 | + <tr> | ||
34 | + <td><label for="start">Date de début :</label></td> | ||
35 | + <td><input type="date" id="start" name="start-date" min="<?php echo $date_min; ?>" max="<?php echo $date_max; ?>" /></td> | ||
36 | + </tr> | ||
37 | + | ||
38 | + <tr> | ||
39 | + <td><label for="end">Date de fin :</label></td> | ||
40 | + <td><input type="date" id="end" name="end-date" min="<?php echo $date_min; ?>" max="<?php echo $date_max; ?>" /></td> | ||
41 | + </tr> | ||
42 | + | ||
43 | + <tr> | ||
44 | + <td><label for"nombre">Nombre de points :</label></td> | ||
45 | + <td><input type="text" id="nombre" name="nombre" min="2" max="25" value="10" /></td> | ||
46 | + </tr> | ||
47 | + </tbody> | ||
48 | + </table> | ||
49 | + <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px; margin-bottom:20px;" value="Afficher le graphe"/> | ||
50 | + </form> | ||
51 | + </div> | ||
52 | +</div> |
site/formInscription.php
1 | <div class="row"> | 1 | <div class="row"> |
2 | <div class="col-4 col-md-4 offset-md-4 offset-4"> | 2 | <div class="col-4 col-md-4 offset-md-4 offset-4"> |
3 | <br/> | 3 | <br/> |
4 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-user-circle"></i> Inscription</h1> | 4 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-user-circle"></i> Inscription</h1> |
5 | <form action="inscription.php" method="post"> | 5 | <form action="inscription.php" method="post"> |
6 | <table class="table table-striped table-bordered"> | 6 | <table class="table table-striped table-bordered"> |
7 | <tbody> | 7 | <tbody> |
@@ -28,13 +28,10 @@ | @@ -28,13 +28,10 @@ | ||
28 | <td>Confirmer mot de passe :</td> | 28 | <td>Confirmer mot de passe :</td> |
29 | <td><input type="password" name="pass2" placeholder="Entrez votre mot de passe" required="true" /></td> | 29 | <td><input type="password" name="pass2" placeholder="Entrez votre mot de passe" required="true" /></td> |
30 | </tr> | 30 | </tr> |
31 | - | ||
32 | - <tr> | ||
33 | - <td></td> | ||
34 | - <td><input type="submit" class="btn btn-dark" value="S'inscrire"/></td> | ||
35 | - </tr> | ||
36 | </tbody> | 31 | </tbody> |
37 | </table> | 32 | </table> |
33 | + <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px; margin-bottom:20px;" value="S'inscrire"/> | ||
34 | + <br/> | ||
38 | </form> | 35 | </form> |
39 | </div> | 36 | </div> |
40 | </div> | 37 | </div> |
@@ -0,0 +1,69 @@ | @@ -0,0 +1,69 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | +require_once('accesBase.php'); | ||
5 | + | ||
6 | +$legend = getLegend($_REQUEST['nom']); | ||
7 | +$history = getHistory($_REQUEST['nom'], '', '', $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['nombre']); | ||
8 | +$y = makeArray($history, "value"); | ||
9 | +$x = makeArray($history, "date"); | ||
10 | + | ||
11 | +$datay = array_reverse($y); | ||
12 | +$datax = array_reverse($x); | ||
13 | + | ||
14 | +// Setup the graph | ||
15 | +$graph = new Graph(1100,400); | ||
16 | +$graph->SetScale("textlin"); | ||
17 | + | ||
18 | +$theme_class=new UniversalTheme; | ||
19 | + | ||
20 | +$graph->SetTheme($theme_class); | ||
21 | +$graph->img->SetAntiAliasing(false); | ||
22 | +$graph->title->Set('Capteur '.$_REQUEST['nom'].' : '.$legend['type'].' ('.$legend['unite'].')'); | ||
23 | +$graph->SetBox(false); | ||
24 | + | ||
25 | +$graph->SetMargin(40,30,15,150); | ||
26 | + | ||
27 | +$graph->img->SetAntiAliasing(); | ||
28 | + | ||
29 | +$graph->yaxis->HideZeroLabel(); | ||
30 | +$graph->yaxis->HideLine(false); | ||
31 | +$graph->yaxis->HideTicks(false,false); | ||
32 | +//$graph->yaxis->title->Set($legend['type']."(".$legend['unite'].")"); | ||
33 | + | ||
34 | +$graph->xgrid->Show(); | ||
35 | +$graph->xgrid->SetLineStyle("solid"); | ||
36 | +$graph->xaxis->SetTickLabels($datax); | ||
37 | +$graph->xaxis->SetLabelAngle(90); | ||
38 | +$graph->xgrid->SetColor('#E3E3E3'); | ||
39 | + | ||
40 | +// Create the line | ||
41 | +$p = new LinePlot($datay); | ||
42 | +$graph->Add($p); | ||
43 | +$p->SetColor('#eb3d34');//('#5c0f10'); | ||
44 | + | ||
45 | +if($_REQUEST['nombre'] <= 40) | ||
46 | +{ | ||
47 | + // Afficher les valeurs pour chaque point | ||
48 | + $p->value->Show(); | ||
49 | + | ||
50 | + // Valeurs: Apparence de la police | ||
51 | + $p->value->SetFormat('%.1f'); | ||
52 | + $p->value->SetColor('#0c0f52'); | ||
53 | +} | ||
54 | + | ||
55 | +// Chaque point de la courbe | ||
56 | +// Type de point | ||
57 | +$p->mark->SetType(MARK_FILLEDCIRCLE); | ||
58 | +// Couleur de remplissage | ||
59 | +$p->mark->SetFillColor('#0D0D0D'); | ||
60 | +// Taille | ||
61 | +$p->mark->SetWidth(2); | ||
62 | + | ||
63 | + | ||
64 | +// Output line | ||
65 | +$graph->Stroke(); | ||
66 | + | ||
67 | +?> | ||
68 | + | ||
69 | + |
@@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
1 | +<?php | ||
2 | +session_start(); | ||
3 | +require_once("accesBase.php"); | ||
4 | +$nom = $_POST['nom']; | ||
5 | +$nombre = $_POST['nombre']; | ||
6 | +$start = $_POST['start-date']; | ||
7 | +$end = $_POST['end-date']; | ||
8 | +if(($end == NULL) || ($end < $start)) {$e = date_max(); $end = $e['max'];} | ||
9 | +else $end = $end." 23:59:59"; | ||
10 | +if($start == NULL) {$s = date_min(); $start = $s['min'];} | ||
11 | +else $start = $start." 00:00:00"; | ||
12 | +?> | ||
13 | +<!DOCTYPE html> | ||
14 | + | ||
15 | +<html> | ||
16 | + <head> | ||
17 | + <?php include("head.php"); ?> | ||
18 | + </head> | ||
19 | + | ||
20 | + <!-- Contenu du site --> | ||
21 | + <body> | ||
22 | + <?php | ||
23 | + include("header.php"); | ||
24 | + if(isset($_SESSION['Login'], $_SESSION['Password'])) | ||
25 | + { | ||
26 | + ?> | ||
27 | + <div class="row"> | ||
28 | + <div class="col-10 col-md-10 offset-md-1 offset-1"> | ||
29 | + <br/> | ||
30 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-chart-line"></i> Graphe du capteur</h1> | ||
31 | + <?php | ||
32 | + if(historyExist($nom)) | ||
33 | + { | ||
34 | + echo "<img src='graphe.php?nom=$nom&nombre=$nombre&start=$start&end=$end' alt='graphe'>"; | ||
35 | + } | ||
36 | + else | ||
37 | + { | ||
38 | + ?> | ||
39 | + <div class="alert alert-danger" role="alert"> | ||
40 | + Il n'y a pas assez de valeurs pour ce capteur ! | ||
41 | + </div> | ||
42 | + <meta http-equiv="Refresh" content="5;url=rechercheGraphe.php" /> | ||
43 | + <?php | ||
44 | + } | ||
45 | + ?> | ||
46 | + </div> | ||
47 | + </div> | ||
48 | + <?php | ||
49 | + } | ||
50 | + else | ||
51 | + { | ||
52 | + include("formConnexion.php"); | ||
53 | + } | ||
54 | + ?> | ||
55 | + </body> | ||
56 | +</html> | ||
57 | + |
site/header.php
1 | + | ||
1 | <!-- header --> | 2 | <!-- header --> |
2 | -<header class="container-fluid header"> | 3 | +<header class="container-fluid header" style="position: fixed; z-index:289;"> |
3 | <div class="container"> | 4 | <div class="container"> |
4 | <a href ="accueil.php" class="logo"><i class="fa fa-home"></i> Accueil</a> | 5 | <a href ="accueil.php" class="logo"><i class="fa fa-home"></i> Accueil</a> |
5 | <div class="menu"> | 6 | <div class="menu"> |
6 | <?php | 7 | <?php |
7 | if(isset($_SESSION['Login'], $_SESSION['Password'])) | 8 | if(isset($_SESSION['Login'], $_SESSION['Password'])) |
8 | { | 9 | { |
9 | - require("accesBase.php") ; | 10 | + require_once("accesBase.php") ; |
10 | $membre = getMembreByIdPwd($_SESSION['Login'], $_SESSION['Password']); | 11 | $membre = getMembreByIdPwd($_SESSION['Login'], $_SESSION['Password']); |
11 | ?> | 12 | ?> |
12 | - <!-- <a href="settings.php"><i class="fa fa-cog"></i> <?php echo $membre['prenom']; echo ' '; echo $membre['nom'];?></a> --> | ||
13 | - <a href="ajoutCapteur.php"><i class="far fa-plus-square"></i> Ajouter un capteur</a> | 13 | + <a href="ajoutRaspberry.php"><i class="far fa-plus-square"></i> Raspberry</a> |
14 | + <a href="ajoutCapteur.php"><i class="far fa-plus-square"></i> Capteur</a> | ||
14 | <a href="send.php"><i class="fa fa-file-upload"></i> Envoyer un code</a> | 15 | <a href="send.php"><i class="fa fa-file-upload"></i> Envoyer un code</a> |
15 | <a href="history.php"><i class="fas fa-history"></i> Historique</a> | 16 | <a href="history.php"><i class="fas fa-history"></i> Historique</a> |
16 | - <a href="data.php"><i class="fas fa-database"></i> Valeurs des capteurs</a> | 17 | + <a href="rechercheGraphe.php"><i class="fas fa-chart-line"></i> Graphiques</a> |
18 | + <a href="data.php"><i class="fas fa-database"></i> Valeurs</a> | ||
17 | <a href="deconnecter.php"><i class="fa fa-power-off"></i> Deconnexion</a> | 19 | <a href="deconnecter.php"><i class="fa fa-power-off"></i> Deconnexion</a> |
18 | <?php | 20 | <?php |
19 | } | 21 | } |
20 | - else | ||
21 | - { | ||
22 | - ?> | ||
23 | - <a href="inscrire.php"><i class="fa fa-user-circle"></i> Inscription</a> | ||
24 | - <?php | ||
25 | - } | ||
26 | ?> | 22 | ?> |
27 | </div> | 23 | </div> |
28 | </div> | 24 | </div> |
site/hist.php
@@ -12,7 +12,7 @@ $date_max = $maxs[0]; | @@ -12,7 +12,7 @@ $date_max = $maxs[0]; | ||
12 | <div class="row"> | 12 | <div class="row"> |
13 | <div class="col-4 col-md-4 offset-md-4 offset-4"> | 13 | <div class="col-4 col-md-4 offset-md-4 offset-4"> |
14 | <br/> | 14 | <br/> |
15 | - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-search"></i> Recherche</h1> | 15 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-search"></i> Recherche</h1> |
16 | <form action="recherche.php" method="post"> | 16 | <form action="recherche.php" method="post"> |
17 | <table class="table table-striped table-bordered"> | 17 | <table class="table table-striped table-bordered"> |
18 | <tbody> | 18 | <tbody> |
@@ -80,13 +80,9 @@ $date_max = $maxs[0]; | @@ -80,13 +80,9 @@ $date_max = $maxs[0]; | ||
80 | <td><label for"nombre">Nombre de résultats (entre 1 et 100) :</label></td> | 80 | <td><label for"nombre">Nombre de résultats (entre 1 et 100) :</label></td> |
81 | <td><input type="text" id="nombre" name="nombre" min="1" max="100" value="10" /></td> | 81 | <td><input type="text" id="nombre" name="nombre" min="1" max="100" value="10" /></td> |
82 | </tr> | 82 | </tr> |
83 | - | ||
84 | - <tr> | ||
85 | - <td></td> | ||
86 | - <td><input type="submit" class="btn btn-dark" value="Lancer la recherche"/></td> | ||
87 | - </tr> | ||
88 | </tbody> | 83 | </tbody> |
89 | </table> | 84 | </table> |
85 | + <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px; margin-bottom:20px;" value="Lancer la recherche"/> | ||
90 | </form> | 86 | </form> |
91 | </div> | 87 | </div> |
92 | </div> | 88 | </div> |
@@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +$data1y=array(-8,8,9,3,5,6); | ||
7 | +$data2y=array(18,2,1,7,5,4); | ||
8 | + | ||
9 | +// Create the graph. These two calls are always required | ||
10 | +$graph = new Graph(500,400); | ||
11 | +$graph->cleartheme(); | ||
12 | +$graph->SetScale("textlin"); | ||
13 | + | ||
14 | +$graph->SetShadow(); | ||
15 | +$graph->img->SetMargin(40,30,20,40); | ||
16 | + | ||
17 | +// Create the bar plots | ||
18 | +$b1plot = new BarPlot($data1y); | ||
19 | +$b1plot->SetFillColor("orange"); | ||
20 | +$b1plot->value->Show(); | ||
21 | +$b2plot = new BarPlot($data2y); | ||
22 | +$b2plot->SetFillColor("blue"); | ||
23 | +$b2plot->value->Show(); | ||
24 | + | ||
25 | +// Create the grouped bar plot | ||
26 | +$gbplot = new AccBarPlot(array($b1plot,$b2plot)); | ||
27 | + | ||
28 | +// ...and add it to the graPH | ||
29 | +$graph->Add($gbplot); | ||
30 | + | ||
31 | +$graph->title->Set("Accumulated bar plots"); | ||
32 | +$graph->xaxis->title->Set("X-title"); | ||
33 | +$graph->yaxis->title->Set("Y-title"); | ||
34 | + | ||
35 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
36 | +$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
37 | +$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
38 | + | ||
39 | +// Display the graph | ||
40 | +$graph->Stroke(); | ||
41 | +?> |
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +$datay1=array(13,8,19,7,17,6); | ||
6 | +$datay2=array(4,5,2,7,5,25); | ||
7 | + | ||
8 | +// Create the graph. | ||
9 | +$graph = new Graph(350,250); | ||
10 | +$graph->SetScale('textlin'); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | + | ||
13 | +// Setup title | ||
14 | +$graph->title->Set('Acc bar with gradient'); | ||
15 | + | ||
16 | +// Create the first bar | ||
17 | +$bplot = new BarPlot($datay1); | ||
18 | +$bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT); | ||
19 | +$bplot->SetColor('darkred'); | ||
20 | + | ||
21 | +// Create the second bar | ||
22 | +$bplot2 = new BarPlot($datay2); | ||
23 | +$bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT); | ||
24 | +$bplot2->SetColor('darkgreen'); | ||
25 | + | ||
26 | +// And join them in an accumulated bar | ||
27 | +$accbplot = new AccBarPlot(array($bplot,$bplot2)); | ||
28 | +$graph->Add($accbplot); | ||
29 | + | ||
30 | +$graph->Stroke(); | ||
31 | +?> |
@@ -0,0 +1,33 @@ | @@ -0,0 +1,33 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +$datay1=array(13,8,19,7,17,6); | ||
6 | +$datay2=array(4,5,2,7,5,25); | ||
7 | + | ||
8 | +// Create the graph. | ||
9 | +$graph = new Graph(350,250); | ||
10 | +$graph->SetScale('textlin'); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | + | ||
13 | +// Setup title | ||
14 | +$graph->title->Set('Acc bar with gradient'); | ||
15 | + | ||
16 | +// Create the first bar | ||
17 | +$bplot = new BarPlot($datay1); | ||
18 | +$bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT); | ||
19 | +$bplot->SetColor('darkred'); | ||
20 | + | ||
21 | +// Create the second bar | ||
22 | +$bplot2 = new BarPlot($datay2); | ||
23 | +$bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT); | ||
24 | +$bplot2->SetColor('darkgreen'); | ||
25 | + | ||
26 | +// And join them in an accumulated bar | ||
27 | +$accbplot = new AccBarPlot(array($bplot,$bplot2)); | ||
28 | +$accbplot->SetColor('red'); | ||
29 | +$accbplot->SetWeight(1); | ||
30 | +$graph->Add($accbplot); | ||
31 | + | ||
32 | +$graph->Stroke(); | ||
33 | +?> |
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +$datay1=array(13,8,19,7,17,6); | ||
6 | +$datay2=array(4,5,2,7,5,25); | ||
7 | + | ||
8 | +// Create the graph. | ||
9 | +$graph = new Graph(350,250); | ||
10 | +$graph->SetScale('textlin'); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | + | ||
13 | +// Setup title | ||
14 | +$graph->title->Set('Acc bar with gradient'); | ||
15 | + | ||
16 | +// Create the first bar | ||
17 | +$bplot = new BarPlot($datay1); | ||
18 | +$bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT); | ||
19 | +$bplot->SetColor('darkred'); | ||
20 | +$bplot->SetWeight(0); | ||
21 | + | ||
22 | +// Create the second bar | ||
23 | +$bplot2 = new BarPlot($datay2); | ||
24 | +$bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT); | ||
25 | +$bplot2->SetColor('darkgreen'); | ||
26 | +$bplot2->SetWeight(0); | ||
27 | + | ||
28 | +// And join them in an accumulated bar | ||
29 | +$accbplot = new AccBarPlot(array($bplot,$bplot2)); | ||
30 | +$accbplot->SetColor('darkgray'); | ||
31 | +$accbplot->SetWeight(1); | ||
32 | +$graph->Add($accbplot); | ||
33 | + | ||
34 | +$graph->Stroke(); | ||
35 | +?> |
@@ -0,0 +1,75 @@ | @@ -0,0 +1,75 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// Some data | ||
7 | +$datay1=array(140,110,50,60); | ||
8 | +$datay2=array(35,90,190,190); | ||
9 | +$datay3=array(20,60,70,140); | ||
10 | + | ||
11 | +// Create the basic graph | ||
12 | +$graph = new Graph(450,250,'auto'); | ||
13 | +$graph->clearTheme(); | ||
14 | +$graph->SetScale("textlin"); | ||
15 | +$graph->img->SetMargin(40,80,30,40); | ||
16 | + | ||
17 | +// Adjust the position of the legend box | ||
18 | +$graph->legend->Pos(0.02,0.15); | ||
19 | + | ||
20 | +// Adjust the color for theshadow of the legend | ||
21 | +$graph->legend->SetShadow('darkgray@0.5'); | ||
22 | +$graph->legend->SetFillColor('lightblue@0.3'); | ||
23 | + | ||
24 | +// Get localised version of the month names | ||
25 | +$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth()); | ||
26 | + | ||
27 | +// Set a nice summer (in Stockholm) image | ||
28 | +$graph->SetBackgroundImage('stship.jpg',BGIMG_COPY); | ||
29 | + | ||
30 | +// Set axis titles and fonts | ||
31 | +$graph->xaxis->title->Set('Year 2002'); | ||
32 | +$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
33 | +$graph->xaxis->title->SetColor('white'); | ||
34 | + | ||
35 | +$graph->xaxis->SetFont(FF_FONT1,FS_BOLD); | ||
36 | +$graph->xaxis->SetColor('white'); | ||
37 | + | ||
38 | +$graph->yaxis->SetFont(FF_FONT1,FS_BOLD); | ||
39 | +$graph->yaxis->SetColor('white'); | ||
40 | + | ||
41 | +//$graph->ygrid->Show(false); | ||
42 | +$graph->ygrid->SetColor('white@0.5'); | ||
43 | + | ||
44 | +// Setup graph title | ||
45 | +$graph->title->Set('Using alpha blending with a background'); | ||
46 | +// Some extra margin (from the top) | ||
47 | +$graph->title->SetMargin(3); | ||
48 | +$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12); | ||
49 | + | ||
50 | +// Create the three var series we will combine | ||
51 | +$bplot1 = new BarPlot($datay1); | ||
52 | +$bplot2 = new BarPlot($datay2); | ||
53 | +$bplot3 = new BarPlot($datay3); | ||
54 | + | ||
55 | +// Setup the colors with 40% transparency (alpha channel) | ||
56 | +$bplot1->SetFillColor('orange@0.4'); | ||
57 | +$bplot2->SetFillColor('brown@0.4'); | ||
58 | +$bplot3->SetFillColor('darkgreen@0.4'); | ||
59 | + | ||
60 | +// Setup legends | ||
61 | +$bplot1->SetLegend('Label 1'); | ||
62 | +$bplot2->SetLegend('Label 2'); | ||
63 | +$bplot3->SetLegend('Label 3'); | ||
64 | + | ||
65 | +// Setup each bar with a shadow of 50% transparency | ||
66 | +$bplot1->SetShadow('black@0.4'); | ||
67 | +$bplot2->SetShadow('black@0.4'); | ||
68 | +$bplot3->SetShadow('black@0.4'); | ||
69 | + | ||
70 | +$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3)); | ||
71 | +$gbarplot->SetWidth(0.6); | ||
72 | +$graph->Add($gbarplot); | ||
73 | + | ||
74 | +$graph->Stroke(); | ||
75 | +?> |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Antispam example using a random string | ||
3 | +require_once "jpgraph/jpgraph_antispam.php"; | ||
4 | + | ||
5 | +// Create new anti-spam challenge creator | ||
6 | +// Note: Neither '0' (digit) or 'O' (letter) can be used to avoid confusion | ||
7 | +$spam = new AntiSpam(); | ||
8 | + | ||
9 | +// Create a random 5 char challenge and return the string generated | ||
10 | +$chars = $spam->Rand(5); | ||
11 | + | ||
12 | +// Stroke random cahllenge | ||
13 | +if( $spam->Stroke() === false ) { | ||
14 | + die('Illegal or no data to plot'); | ||
15 | +} | ||
16 | + | ||
17 | +?> | ||
18 | + |
@@ -0,0 +1,58 @@ | @@ -0,0 +1,58 @@ | ||
1 | +<?php | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | +require_once ('jpgraph/jpgraph_line.php'); | ||
5 | + | ||
6 | +$theme = isset($_GET['theme']) ? $_GET['theme'] : null; | ||
7 | + | ||
8 | +$data = array ( | ||
9 | + 0 => array (0 => 79, 1 => -25, 2 => -7, 3 => 85, 4 => -26, 5 => -32, ), | ||
10 | + 1 => array (0 => 76, 1 => 51, 2 => 86, 3 => 12, 4 => -7, 5 => 94, ), | ||
11 | + 2 => array (0 => 49, 1 => 38, 2 => 7, 3 => -40, 4 => 9, 5 => -7, ), | ||
12 | + 3 => array ( 0 => 69, 1 => 96, 2 => 49, 3 => 7, 4 => 92, 5 => -38, ), | ||
13 | + 4 => array ( 0 => 68, 1 => 16, 2 => 82, 3 => -49, 4 => 50, 5 => 7, ), | ||
14 | + 5 => array ( 0 => -37, 1 => 28, 2 => 32, 3 => 6, 4 => 13, 5 => 57, ), | ||
15 | + 6 => array ( 0 => 24, 1 => -11, 2 => 7, 3 => 10, 4 => 51, 5 => 51, ), | ||
16 | + 7 => array ( 0 => 3, 1 => -1, 2 => -12, 3 => 61, 4 => 10, 5 => 47, ), | ||
17 | + 8 => array ( 0 => -47, 1 => -21, 2 => 43, 3 => 53, 4 => 36, 5 => 34, ), | ||
18 | +); | ||
19 | + | ||
20 | + | ||
21 | +// Create the graph. These two calls are always required | ||
22 | +$graph = new Graph(400,300); | ||
23 | + | ||
24 | +$graph->SetScale("textlin"); | ||
25 | +if ($theme) { | ||
26 | + $graph->SetTheme(new $theme()); | ||
27 | +} | ||
28 | +$theme_class = new AquaTheme; | ||
29 | +$graph->SetTheme($theme_class); | ||
30 | + | ||
31 | +$plot = array(); | ||
32 | +// Create the bar plots | ||
33 | +for ($i = 0; $i < 4; $i++) { | ||
34 | + $plot[$i] = new BarPlot($data[$i]); | ||
35 | + $plot[$i]->SetLegend('plot'.($i+1)); | ||
36 | +} | ||
37 | +//$acc1 = new AccBarPlot(array($plot[0], $plot[1])); | ||
38 | +//$acc1->value->Show(); | ||
39 | +$gbplot = new GroupBarPlot(array($plot[2], $plot[1] )); | ||
40 | + | ||
41 | +for ($i = 4; $i < 8; $i++) { | ||
42 | + $plot[$i] = new LinePlot($data[$i]); | ||
43 | + $plot[$i]->SetLegend('plot'.$i); | ||
44 | + $plot[$i]->value->Show(); | ||
45 | +} | ||
46 | + | ||
47 | +$graph->Add($gbplot); | ||
48 | +$graph->Add($plot[4]); | ||
49 | + | ||
50 | +$title = "AquaTheme Example"; | ||
51 | +$title = mb_convert_encoding($title,'UTF-8'); | ||
52 | +$graph->title->Set($title); | ||
53 | +$graph->xaxis->title->Set("X-title"); | ||
54 | +$graph->yaxis->title->Set("Y-title"); | ||
55 | + | ||
56 | +// Display the graph | ||
57 | +$graph->Stroke(); | ||
58 | +?> |
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +$ydata = array(12,19,3,9,15,10); | ||
6 | + | ||
7 | +// The code to setup a very basic graph | ||
8 | +$graph = new Graph(200,150); | ||
9 | +$graph->SetScale('intlin'); | ||
10 | +$graph->SetMargin(30,15,40,30); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | +$graph->SetFrame(true,'blue',3); | ||
13 | + | ||
14 | +$graph->title->Set('Label background'); | ||
15 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
16 | + | ||
17 | +$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10); | ||
18 | +$graph->subtitle->SetColor('darkred'); | ||
19 | +$graph->subtitle->Set('"LABELBKG_NONE"'); | ||
20 | + | ||
21 | +$graph->SetAxisLabelBackground(LABELBKG_NONE,'orange','red','lightblue','red'); | ||
22 | + | ||
23 | +// Use Ariel font | ||
24 | +$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
25 | +$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
26 | +$graph->xgrid->Show(); | ||
27 | + | ||
28 | +// Create the plot line | ||
29 | +$p1 = new LinePlot($ydata); | ||
30 | +$graph->Add($p1); | ||
31 | + | ||
32 | +// Output graph | ||
33 | +$graph->Stroke(); | ||
34 | + | ||
35 | +?> |
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +$ydata = array(12,19,3,9,15,10); | ||
6 | + | ||
7 | +// The code to setup a very basic graph | ||
8 | +$graph = new Graph(200,150); | ||
9 | +$graph->SetScale('intlin'); | ||
10 | +$graph->SetMargin(30,15,40,30); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | +$graph->SetFrame(true,'blue',3); | ||
13 | + | ||
14 | +$graph->title->Set('Label background'); | ||
15 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
16 | + | ||
17 | +$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10); | ||
18 | +$graph->subtitle->SetColor('darkred'); | ||
19 | +$graph->subtitle->Set('"LABELBKG_XAXIS"'); | ||
20 | + | ||
21 | +$graph->SetAxisLabelBackground(LABELBKG_XAXIS,'orange','red','lightblue','red'); | ||
22 | + | ||
23 | +// Use Ariel font | ||
24 | +$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
25 | +$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
26 | +$graph->xgrid->Show(); | ||
27 | + | ||
28 | +// Create the plot line | ||
29 | +$p1 = new LinePlot($ydata); | ||
30 | +$graph->Add($p1); | ||
31 | + | ||
32 | +// Output graph | ||
33 | +$graph->Stroke(); | ||
34 | + | ||
35 | +?> | ||
36 | + | ||
37 | + |
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +$ydata = array(12,19,3,9,15,10); | ||
6 | + | ||
7 | +// The code to setup a very basic graph | ||
8 | +$graph = new Graph(200,150); | ||
9 | +$graph->SetScale('intlin'); | ||
10 | +$graph->SetMargin(30,15,40,30); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | +$graph->SetFrame(true,'blue',3); | ||
13 | + | ||
14 | +$graph->title->Set('Label background'); | ||
15 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
16 | + | ||
17 | +$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10); | ||
18 | +$graph->subtitle->SetColor('darkred'); | ||
19 | +$graph->subtitle->Set('"LABELBKG_YAXIS"'); | ||
20 | + | ||
21 | +$graph->SetAxisLabelBackground(LABELBKG_YAXIS,'orange','red','lightblue','red'); | ||
22 | + | ||
23 | +// Use Ariel font | ||
24 | +$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
25 | +$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
26 | +$graph->xgrid->Show(); | ||
27 | + | ||
28 | +// Create the plot line | ||
29 | +$p1 = new LinePlot($ydata); | ||
30 | +$graph->Add($p1); | ||
31 | + | ||
32 | +// Output graph | ||
33 | +$graph->Stroke(); | ||
34 | + | ||
35 | +?> | ||
36 | + | ||
37 | + |
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +$ydata = array(12,19,3,9,15,10); | ||
6 | + | ||
7 | +// The code to setup a very basic graph | ||
8 | +$graph = new Graph(200,150); | ||
9 | +$graph->SetScale('intlin'); | ||
10 | +$graph->SetMargin(30,15,40,30); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | +$graph->SetFrame(true,'blue',3); | ||
13 | + | ||
14 | +$graph->title->Set('Label background'); | ||
15 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
16 | + | ||
17 | +$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10); | ||
18 | +$graph->subtitle->SetColor('darkred'); | ||
19 | +$graph->subtitle->Set('"LABELBKG_YAXISFULL"'); | ||
20 | + | ||
21 | +$graph->SetAxisLabelBackground(LABELBKG_YAXISFULL,'orange','red','lightblue','red'); | ||
22 | + | ||
23 | +// Use Ariel font | ||
24 | +$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
25 | +$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
26 | +$graph->xgrid->Show(); | ||
27 | + | ||
28 | +// Create the plot line | ||
29 | +$p1 = new LinePlot($ydata); | ||
30 | +$graph->Add($p1); | ||
31 | + | ||
32 | +// Output graph | ||
33 | +$graph->Stroke(); | ||
34 | + | ||
35 | +?> | ||
36 | + | ||
37 | + |
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +$ydata = array(12,19,3,9,15,10); | ||
6 | + | ||
7 | +// The code to setup a very basic graph | ||
8 | +$graph = new Graph(200,150); | ||
9 | +$graph->SetScale('intlin'); | ||
10 | +$graph->SetMargin(30,15,40,30); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | +$graph->SetFrame(true,'blue',3); | ||
13 | + | ||
14 | +$graph->title->Set('Label background'); | ||
15 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
16 | + | ||
17 | +$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10); | ||
18 | +$graph->subtitle->SetColor('darkred'); | ||
19 | +$graph->subtitle->Set('"LABELBKG_XAXISFULL"'); | ||
20 | + | ||
21 | +$graph->SetAxisLabelBackground(LABELBKG_XAXISFULL,'orange','red','lightblue','red'); | ||
22 | + | ||
23 | +// Use Ariel font | ||
24 | +$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
25 | +$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
26 | +$graph->xgrid->Show(); | ||
27 | + | ||
28 | +// Create the plot line | ||
29 | +$p1 = new LinePlot($ydata); | ||
30 | +$graph->Add($p1); | ||
31 | + | ||
32 | +// Output graph | ||
33 | +$graph->Stroke(); | ||
34 | + | ||
35 | +?> | ||
36 | + | ||
37 | + |
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +$ydata = array(12,19,3,9,15,10); | ||
6 | + | ||
7 | +// The code to setup a very basic graph | ||
8 | +$graph = new Graph(200,150); | ||
9 | +$graph->SetScale('intlin'); | ||
10 | +$graph->SetMargin(30,15,40,30); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | +$graph->SetFrame(true,'blue',3); | ||
13 | + | ||
14 | +$graph->title->Set('Label background'); | ||
15 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
16 | + | ||
17 | +$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10); | ||
18 | +$graph->subtitle->SetColor('darkred'); | ||
19 | +$graph->subtitle->Set('"LABELBKG_XYFULL"'); | ||
20 | + | ||
21 | +$graph->SetAxisLabelBackground(LABELBKG_XYFULL,'orange','red','lightblue','red'); | ||
22 | + | ||
23 | +// Use Ariel font | ||
24 | +$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
25 | +$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
26 | +$graph->xgrid->Show(); | ||
27 | + | ||
28 | +// Create the plot line | ||
29 | +$p1 = new LinePlot($ydata); | ||
30 | +$graph->Add($p1); | ||
31 | + | ||
32 | +// Output graph | ||
33 | +$graph->Stroke(); | ||
34 | + | ||
35 | +?> | ||
36 | + | ||
37 | + |
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +$ydata = array(12,19,3,9,15,10); | ||
6 | + | ||
7 | +// The code to setup a very basic graph | ||
8 | +$graph = new Graph(200,150); | ||
9 | +$graph->SetScale('intlin'); | ||
10 | +$graph->SetMargin(30,15,40,30); | ||
11 | +$graph->SetMarginColor('white'); | ||
12 | +$graph->SetFrame(true,'blue',3); | ||
13 | + | ||
14 | +$graph->title->Set('Label background'); | ||
15 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
16 | + | ||
17 | +$graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,10); | ||
18 | +$graph->subtitle->SetColor('darkred'); | ||
19 | +$graph->subtitle->Set('"LABELBKG_XY"'); | ||
20 | + | ||
21 | +$graph->SetAxisLabelBackground(LABELBKG_XY,'orange','red','lightblue','red'); | ||
22 | + | ||
23 | +// Use Ariel font | ||
24 | +$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
25 | +$graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
26 | +$graph->xgrid->Show(); | ||
27 | + | ||
28 | +// Create the plot line | ||
29 | +$p1 = new LinePlot($ydata); | ||
30 | +$graph->Add($p1); | ||
31 | + | ||
32 | +// Output graph | ||
33 | +$graph->Stroke(); | ||
34 | + | ||
35 | +?> | ||
36 | + | ||
37 | + |
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$ydata = array(11,3,8,12,5,1,9,13,5,7); | ||
7 | + | ||
8 | +// Create the graph. These two calls are always required | ||
9 | +$graph = new Graph(350,250); | ||
10 | +$graph->clearTheme(); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->SetMargin(40,40,50,50); | ||
13 | + | ||
14 | +// Setup the grid and plotarea box | ||
15 | +$graph->ygrid->SetLineStyle('dashed'); | ||
16 | +$graph->ygrid->setColor('darkgray'); | ||
17 | +$graph->SetBox(true); | ||
18 | + | ||
19 | +// Steup graph titles | ||
20 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
21 | +$graph->title->Set('Using background image'); | ||
22 | +$graph->subtitle->SetFont(FF_COURIER,FS_BOLD,11); | ||
23 | +$graph->subtitle->Set('"BGIMG_COPY"'); | ||
24 | +$graph->subtitle->SetColor('darkred'); | ||
25 | + | ||
26 | +// Add background with 25% mix | ||
27 | +$graph->SetBackgroundImage('heat1.jpg',BGIMG_COPY); | ||
28 | +$graph->SetBackgroundImageMix(25); | ||
29 | + | ||
30 | +// Create the linear plot | ||
31 | +$lineplot=new LinePlot($ydata); | ||
32 | +$lineplot->SetColor("blue"); | ||
33 | + | ||
34 | +// Add the plot to the graph | ||
35 | +$graph->Add($lineplot); | ||
36 | + | ||
37 | +// Display the graph | ||
38 | +$graph->Stroke(); | ||
39 | +?> |
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$ydata = array(11,3,8,12,5,1,9,13,5,7); | ||
7 | + | ||
8 | +// Create the graph. These two calls are always required | ||
9 | +$graph = new Graph(350,250); | ||
10 | +$graph->clearTheme(); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->SetMargin(40,40,50,50); | ||
13 | + | ||
14 | +// Setup the grid and plotarea box | ||
15 | +$graph->ygrid->SetLineStyle('dashed'); | ||
16 | +$graph->ygrid->setColor('darkgray'); | ||
17 | +$graph->SetBox(true); | ||
18 | + | ||
19 | +// Steup graph titles | ||
20 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
21 | +$graph->title->Set('Using background image'); | ||
22 | +$graph->subtitle->SetFont(FF_COURIER,FS_BOLD,11); | ||
23 | +$graph->subtitle->Set('"BGIMG_CENTER"'); | ||
24 | +$graph->subtitle->SetColor('darkred'); | ||
25 | + | ||
26 | +// Add background with 25% mix | ||
27 | +$graph->SetBackgroundImage('heat1.jpg',BGIMG_CENTER); | ||
28 | +$graph->SetBackgroundImageMix(25); | ||
29 | + | ||
30 | +// Create the linear plot | ||
31 | +$lineplot=new LinePlot($ydata); | ||
32 | +$lineplot->SetColor("blue"); | ||
33 | + | ||
34 | +// Add the plot to the graph | ||
35 | +$graph->Add($lineplot); | ||
36 | + | ||
37 | +// Display the graph | ||
38 | +$graph->Stroke(); | ||
39 | +?> |
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$ydata = array(11,3,8,12,5,1,9,13,5,7); | ||
7 | + | ||
8 | +// Create the graph. These two calls are always required | ||
9 | +$graph = new Graph(350,250); | ||
10 | +$graph->clearTheme(); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->SetMargin(40,40,50,50); | ||
13 | + | ||
14 | +// Setup the grid and plotarea box | ||
15 | +$graph->ygrid->SetLineStyle('dashed'); | ||
16 | +$graph->ygrid->setColor('darkgray'); | ||
17 | +$graph->SetBox(true); | ||
18 | + | ||
19 | +// Steup graph titles | ||
20 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
21 | +$graph->title->Set('Using background image'); | ||
22 | +$graph->subtitle->SetFont(FF_COURIER,FS_BOLD,11); | ||
23 | +$graph->subtitle->Set('"BGIMG_FREE"'); | ||
24 | +$graph->subtitle->SetColor('darkred'); | ||
25 | + | ||
26 | +// Add background with 25% mix | ||
27 | +$graph->SetBackgroundImage('heat1.jpg',BGIMG_FREE); | ||
28 | +$graph->SetBackgroundImageMix(25); | ||
29 | + | ||
30 | +// Create the linear plot | ||
31 | +$lineplot=new LinePlot($ydata); | ||
32 | +$lineplot->SetColor("blue"); | ||
33 | + | ||
34 | +// Add the plot to the graph | ||
35 | +$graph->Add($lineplot); | ||
36 | + | ||
37 | +// Display the graph | ||
38 | +$graph->Stroke(); | ||
39 | +?> |
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$ydata = array(11,3,8,12,5,1,9,13,5,7); | ||
7 | + | ||
8 | +// Create the graph. These two calls are always required | ||
9 | +$graph = new Graph(350,250); | ||
10 | +$graph->clearTheme(); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->SetMargin(40,40,50,50); | ||
13 | + | ||
14 | +// Setup the grid and plotarea box | ||
15 | +$graph->ygrid->SetLineStyle('dashed'); | ||
16 | +$graph->ygrid->setColor('darkgray'); | ||
17 | +$graph->SetBox(true); | ||
18 | + | ||
19 | +// Steup graph titles | ||
20 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
21 | +$graph->title->Set('Using background image'); | ||
22 | +$graph->subtitle->SetFont(FF_COURIER,FS_BOLD,11); | ||
23 | +$graph->subtitle->Set('"BGIMG_FILLPLOT"'); | ||
24 | +$graph->subtitle->SetColor('darkred'); | ||
25 | + | ||
26 | +// Add background with 25% mix | ||
27 | +$graph->SetBackgroundImage('heat1.jpg',BGIMG_FILLPLOT); | ||
28 | +$graph->SetBackgroundImageMix(25); | ||
29 | + | ||
30 | +// Create the linear plot | ||
31 | +$lineplot=new LinePlot($ydata); | ||
32 | +$lineplot->SetColor("blue"); | ||
33 | + | ||
34 | +// Add the plot to the graph | ||
35 | +$graph->Add($lineplot); | ||
36 | + | ||
37 | +// Display the graph | ||
38 | +$graph->Stroke(); | ||
39 | +?> |
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$ydata = array(11,3,8,12,5,1,9,13,5,7); | ||
7 | + | ||
8 | +// Create the graph. These two calls are always required | ||
9 | +$graph = new Graph(350,250); | ||
10 | +$graph->clearTheme(); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->SetMargin(40,40,50,50); | ||
13 | + | ||
14 | +// Setup the grid and plotarea box | ||
15 | +$graph->ygrid->SetLineStyle('dashed'); | ||
16 | +$graph->ygrid->setColor('darkgray'); | ||
17 | +$graph->SetBox(true); | ||
18 | + | ||
19 | +// Steup graph titles | ||
20 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
21 | +$graph->title->Set('Using background image'); | ||
22 | +$graph->subtitle->SetFont(FF_COURIER,FS_BOLD,11); | ||
23 | +$graph->subtitle->Set('"BGIMG_FILLFRAME"'); | ||
24 | +$graph->subtitle->SetColor('darkred'); | ||
25 | + | ||
26 | +// Add background with 25% mix | ||
27 | +$graph->SetBackgroundImage('heat1.jpg',BGIMG_FILLFRAME); | ||
28 | +$graph->SetBackgroundImageMix(25); | ||
29 | + | ||
30 | +// Create the linear plot | ||
31 | +$lineplot=new LinePlot($ydata); | ||
32 | +$lineplot->SetColor("blue"); | ||
33 | + | ||
34 | +// Add the plot to the graph | ||
35 | +$graph->Add($lineplot); | ||
36 | + | ||
37 | +// Display the graph | ||
38 | +$graph->Stroke(); | ||
39 | +?> |
@@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$datay = array(28,19,18,23,12,11); | ||
7 | +$data2y = array(14,18,33,29,39,55); | ||
8 | + | ||
9 | +// A nice graph with anti-aliasing | ||
10 | +$graph = new Graph(400,200); | ||
11 | +$graph->clearTheme(); | ||
12 | +$graph->img->SetMargin(40,180,40,40); | ||
13 | +$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLPLOT); | ||
14 | + | ||
15 | +$graph->img->SetAntiAliasing("white"); | ||
16 | +$graph->SetScale("textlin"); | ||
17 | +$graph->SetShadow(); | ||
18 | +$graph->title->Set("Background image"); | ||
19 | + | ||
20 | +// Use built in font | ||
21 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
22 | + | ||
23 | +// Slightly adjust the legend from it's default position in the | ||
24 | +// top right corner. | ||
25 | +$graph->legend->Pos(0.05,0.5,"right","center"); | ||
26 | + | ||
27 | +// Create the first line | ||
28 | +$p1 = new LinePlot($datay); | ||
29 | +$p1->mark->SetType(MARK_FILLEDCIRCLE); | ||
30 | +$p1->mark->SetFillColor("red"); | ||
31 | +$p1->mark->SetWidth(4); | ||
32 | +$p1->SetColor("blue"); | ||
33 | +$p1->SetCenter(); | ||
34 | +$p1->SetLegend("Triumph Tiger -98"); | ||
35 | +$graph->Add($p1); | ||
36 | + | ||
37 | +// ... and the second | ||
38 | +$p2 = new LinePlot($data2y); | ||
39 | +$p2->mark->SetType(MARK_STAR); | ||
40 | +$p2->mark->SetFillColor("red"); | ||
41 | +$p2->mark->SetWidth(4); | ||
42 | +$p2->SetColor("red"); | ||
43 | +$p2->SetCenter(); | ||
44 | +$p2->SetLegend("New tiger -99"); | ||
45 | +$graph->Add($p2); | ||
46 | + | ||
47 | +// Output line | ||
48 | +$graph->Stroke(); | ||
49 | + | ||
50 | +?> |
@@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$datay = array(28,19,18,23,12,11); | ||
7 | +$data2y = array(14,18,33,29,39,55); | ||
8 | + | ||
9 | +// A nice graph with anti-aliasing | ||
10 | +$graph = new Graph(400,200); | ||
11 | +$graph->clearTheme(); | ||
12 | +$graph->img->SetMargin(40,180,40,40); | ||
13 | +$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME); | ||
14 | + | ||
15 | +$graph->img->SetAntiAliasing(); | ||
16 | +$graph->SetScale("textlin"); | ||
17 | +$graph->SetShadow(); | ||
18 | +$graph->title->Set("Background image"); | ||
19 | + | ||
20 | +// Use built in font | ||
21 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
22 | + | ||
23 | +// Slightly adjust the legend from it's default position in the | ||
24 | +// top right corner. | ||
25 | +$graph->legend->Pos(0.05,0.5,"right","center"); | ||
26 | + | ||
27 | +// Create the first line | ||
28 | +$p1 = new LinePlot($datay); | ||
29 | +$p1->mark->SetType(MARK_FILLEDCIRCLE); | ||
30 | +$p1->mark->SetFillColor("red"); | ||
31 | +$p1->mark->SetWidth(4); | ||
32 | +$p1->SetColor("blue"); | ||
33 | +$p1->SetCenter(); | ||
34 | +$p1->SetLegend("Triumph Tiger -98"); | ||
35 | +$graph->Add($p1); | ||
36 | + | ||
37 | +// ... and the second | ||
38 | +$p2 = new LinePlot($data2y); | ||
39 | +$p2->mark->SetType(MARK_STAR); | ||
40 | +$p2->mark->SetFillColor("red"); | ||
41 | +$p2->mark->SetWidth(4); | ||
42 | +$p2->SetColor("red"); | ||
43 | +$p2->SetCenter(); | ||
44 | +$p2->SetLegend("New tiger -99"); | ||
45 | +$graph->Add($p2); | ||
46 | + | ||
47 | +// Output line | ||
48 | +$graph->Stroke(); | ||
49 | + | ||
50 | +?> |
@@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$datay = array(28,19,18,23,12,11); | ||
7 | +$data2y = array(14,18,33,29,39,55); | ||
8 | + | ||
9 | +// A nice graph with anti-aliasing | ||
10 | +$graph = new Graph(400,200); | ||
11 | +$graph->clearTheme(); | ||
12 | +$graph->img->SetMargin(40,180,40,40); | ||
13 | +$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_COPY); | ||
14 | + | ||
15 | +$graph->img->SetAntiAliasing("white"); | ||
16 | +$graph->SetScale("textlin"); | ||
17 | +$graph->SetShadow(); | ||
18 | +$graph->title->Set("Background image"); | ||
19 | + | ||
20 | +// Use built in font | ||
21 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
22 | + | ||
23 | +// Slightly adjust the legend from it's default position in the | ||
24 | +// top right corner. | ||
25 | +$graph->legend->Pos(0.05,0.5,"right","center"); | ||
26 | + | ||
27 | +// Create the first line | ||
28 | +$p1 = new LinePlot($datay); | ||
29 | +$p1->mark->SetType(MARK_FILLEDCIRCLE); | ||
30 | +$p1->mark->SetFillColor("red"); | ||
31 | +$p1->mark->SetWidth(4); | ||
32 | +$p1->SetColor("blue"); | ||
33 | +$p1->SetCenter(); | ||
34 | +$p1->SetLegend("Triumph Tiger -98"); | ||
35 | +$graph->Add($p1); | ||
36 | + | ||
37 | +// ... and the second | ||
38 | +$p2 = new LinePlot($data2y); | ||
39 | +$p2->mark->SetType(MARK_STAR); | ||
40 | +$p2->mark->SetFillColor("red"); | ||
41 | +$p2->mark->SetWidth(4); | ||
42 | +$p2->SetColor("red"); | ||
43 | +$p2->SetCenter(); | ||
44 | +$p2->SetLegend("New tiger -99"); | ||
45 | +$graph->Add($p2); | ||
46 | + | ||
47 | +// Output line | ||
48 | +$graph->Stroke(); | ||
49 | + | ||
50 | +?> |
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// $Id: balloonex1.php,v 1.5 2002/12/15 16:08:51 aditus Exp $ | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_scatter.php'); | ||
5 | + | ||
6 | +// Some data | ||
7 | +$datax = array(1,2,3,4,5,6,7,8); | ||
8 | +$datay = array(12,23,95,18,65,28,86,44); | ||
9 | +// Callback for markers | ||
10 | +// Must return array(width,color,fill_color) | ||
11 | +// If any of the returned values are "" then the | ||
12 | +// default value for that parameter will be used. | ||
13 | +function FCallback($aVal) { | ||
14 | + // This callback will adjust the fill color and size of | ||
15 | + // the datapoint according to the data value according to | ||
16 | + if( $aVal < 30 ) $c = "blue"; | ||
17 | + elseif( $aVal < 70 ) $c = "green"; | ||
18 | + else $c="red"; | ||
19 | + return array(floor($aVal/3),"",$c); | ||
20 | +} | ||
21 | + | ||
22 | +// Setup a basic graph | ||
23 | +$graph = new Graph(400,300,'auto'); | ||
24 | +$graph->clearTheme(); | ||
25 | +$graph->SetScale("linlin"); | ||
26 | +$graph->img->SetMargin(40,100,40,40); | ||
27 | +$graph->SetShadow(); | ||
28 | +$graph->title->Set("Example of ballon scatter plot"); | ||
29 | +// Use a lot of grace to get large scales | ||
30 | +$graph->yaxis->scale->SetGrace(50,10); | ||
31 | + | ||
32 | +// Make sure X-axis as at the bottom of the graph | ||
33 | +$graph->xaxis->SetPos('min'); | ||
34 | + | ||
35 | +// Create the scatter plot | ||
36 | +$sp1 = new ScatterPlot($datay,$datax); | ||
37 | +$sp1->mark->SetType(MARK_FILLEDCIRCLE); | ||
38 | + | ||
39 | +// Uncomment the following two lines to display the values | ||
40 | +$sp1->value->Show(); | ||
41 | +$sp1->value->SetFont(FF_FONT1,FS_BOLD); | ||
42 | + | ||
43 | +// Specify the callback | ||
44 | +$sp1->mark->SetCallback("FCallback"); | ||
45 | + | ||
46 | +// Setup the legend for plot | ||
47 | +$sp1->SetLegend('Year 2002'); | ||
48 | + | ||
49 | +// Add the scatter plot to the graph | ||
50 | +$graph->Add($sp1); | ||
51 | + | ||
52 | +// ... and send to browser | ||
53 | +$graph->Stroke(); | ||
54 | + | ||
55 | +?> |
@@ -0,0 +1,80 @@ | @@ -0,0 +1,80 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_scatter.php'); | ||
4 | + | ||
5 | +// Each ballon is specificed by four values. | ||
6 | +// (X,Y,Size,Color) | ||
7 | +$data = array( | ||
8 | + array(1,12,10,'orange'), | ||
9 | + array(3,41,15,'red'), | ||
10 | + array(4,5,19,'lightblue'), | ||
11 | + array(5,70,22,'yellow') | ||
12 | +); | ||
13 | + | ||
14 | + | ||
15 | + | ||
16 | +// We need to create X,Y data vectors suitable for the | ||
17 | +// library from the above raw data. | ||
18 | +$n = count($data); | ||
19 | +for( $i=0; $i < $n; ++$i ) { | ||
20 | + | ||
21 | + $datax[$i] = $data[$i][0]; | ||
22 | + $datay[$i] = $data[$i][1]; | ||
23 | + | ||
24 | + // Create a faster lookup array so we don't have to search | ||
25 | + // for the correct values in the callback function | ||
26 | + $format[strval($datax[$i])][strval($datay[$i])] = array($data[$i][2],$data[$i][3]); | ||
27 | + | ||
28 | +} | ||
29 | + | ||
30 | + | ||
31 | +// Callback for markers | ||
32 | +// Must return array(width,border_color,fill_color,filename,imgscale) | ||
33 | +// If any of the returned values are '' then the | ||
34 | +// default value for that parameter will be used (possible empty) | ||
35 | +function FCallback($aYVal,$aXVal) { | ||
36 | + global $format; | ||
37 | + return array($format[strval($aXVal)][strval($aYVal)][0],'', | ||
38 | + $format[strval($aXVal)][strval($aYVal)][1],'',''); | ||
39 | +} | ||
40 | + | ||
41 | +// Setup a basic graph | ||
42 | +$graph = new Graph(450,300,'auto'); | ||
43 | +$graph->clearTheme(); | ||
44 | +$graph->SetScale("intlin"); | ||
45 | +$graph->SetMargin(40,40,40,40); | ||
46 | +$graph->SetMarginColor('wheat'); | ||
47 | + | ||
48 | +$graph->title->Set("Example of ballon scatter plot with X,Y callback"); | ||
49 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
50 | +$graph->title->SetMargin(10); | ||
51 | + | ||
52 | +// Use a lot of grace to get large scales since the ballon have | ||
53 | +// size and we don't want them to collide with the X-axis | ||
54 | +$graph->yaxis->scale->SetGrace(50,10); | ||
55 | +$graph->xaxis->scale->SetGrace(50,10); | ||
56 | + | ||
57 | +// Make sure X-axis as at the bottom of the graph and not at the default Y=0 | ||
58 | +$graph->xaxis->SetPos('min'); | ||
59 | + | ||
60 | +// Set X-scale to start at 0 | ||
61 | +$graph->xscale->SetAutoMin(0); | ||
62 | + | ||
63 | +// Create the scatter plot | ||
64 | +$sp1 = new ScatterPlot($datay,$datax); | ||
65 | +$sp1->mark->SetType(MARK_FILLEDCIRCLE); | ||
66 | + | ||
67 | +// Uncomment the following two lines to display the values | ||
68 | +$sp1->value->Show(); | ||
69 | +$sp1->value->SetFont(FF_FONT1,FS_BOLD); | ||
70 | + | ||
71 | +// Specify the callback | ||
72 | +$sp1->mark->SetCallbackYX("FCallback"); | ||
73 | + | ||
74 | +// Add the scatter plot to the graph | ||
75 | +$graph->Add($sp1); | ||
76 | + | ||
77 | +// ... and send to browser | ||
78 | +$graph->Stroke(); | ||
79 | + | ||
80 | +?> |
@@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +$datay=array(20,30,50,80); | ||
6 | +$datay2=array(430,645,223,690); | ||
7 | +$datazero=array(0,0,0,0); | ||
8 | + | ||
9 | +// Create the graph. | ||
10 | +$graph = new Graph(450,200); | ||
11 | +$graph->clearTheme(); | ||
12 | +$graph->title->Set('Example with 2 scale bars'); | ||
13 | + | ||
14 | +// Setup Y and Y2 scales with some "grace" | ||
15 | +$graph->SetScale("textlin"); | ||
16 | +$graph->SetY2Scale("lin"); | ||
17 | +$graph->yaxis->scale->SetGrace(30); | ||
18 | +$graph->y2axis->scale->SetGrace(30); | ||
19 | + | ||
20 | +//$graph->ygrid->Show(true,true); | ||
21 | +$graph->ygrid->SetColor('gray','lightgray@0.5'); | ||
22 | + | ||
23 | +// Setup graph colors | ||
24 | +$graph->SetMarginColor('white'); | ||
25 | +$graph->y2axis->SetColor('darkred'); | ||
26 | + | ||
27 | + | ||
28 | +// Create the "dummy" 0 bplot | ||
29 | +$bplotzero = new BarPlot($datazero); | ||
30 | + | ||
31 | +// Create the "Y" axis group | ||
32 | +$ybplot1 = new BarPlot($datay); | ||
33 | +$ybplot1->value->Show(); | ||
34 | +$ybplot = new GroupBarPlot(array($ybplot1,$bplotzero)); | ||
35 | + | ||
36 | +// Create the "Y2" axis group | ||
37 | +$ybplot2 = new BarPlot($datay2); | ||
38 | +$ybplot2->value->Show(); | ||
39 | +$ybplot2->value->SetColor('darkred'); | ||
40 | +$ybplot2->SetFillColor('darkred'); | ||
41 | +$y2bplot = new GroupBarPlot(array($bplotzero,$ybplot2)); | ||
42 | + | ||
43 | +// Add the grouped bar plots to the graph | ||
44 | +$graph->Add($ybplot); | ||
45 | +$graph->AddY2($y2bplot); | ||
46 | + | ||
47 | +// .. and finally stroke the image back to browser | ||
48 | +$graph->Stroke(); | ||
49 | +?> |
@@ -0,0 +1,52 @@ | @@ -0,0 +1,52 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +$datay=array(12,26,9,17,31); | ||
6 | + | ||
7 | +// Create the graph. | ||
8 | +// One minute timeout for the cached image | ||
9 | +// INLINE_NO means don't stream it back to the browser. | ||
10 | +$graph = new Graph(310,250,'auto'); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->img->SetMargin(60,30,20,40); | ||
13 | +$graph->yaxis->SetTitleMargin(45); | ||
14 | +$graph->yaxis->scale->SetGrace(30); | ||
15 | +$graph->SetShadow(); | ||
16 | + | ||
17 | +// Turn the tickmarks | ||
18 | +$graph->xaxis->SetTickSide(SIDE_DOWN); | ||
19 | +$graph->yaxis->SetTickSide(SIDE_LEFT); | ||
20 | + | ||
21 | +// Create a bar pot | ||
22 | +$bplot = new BarPlot($datay); | ||
23 | + | ||
24 | +// Create targets for the image maps. One for each column | ||
25 | +$targ=array("bar_clsmex1.php#1","bar_clsmex1.php#2","bar_clsmex1.php#3","bar_clsmex1.php#4","bar_clsmex1.php#5","bar_clsmex1.php#6"); | ||
26 | +$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d"); | ||
27 | +$bplot->SetCSIMTargets($targ,$alts); | ||
28 | +$bplot->SetFillColor("orange"); | ||
29 | + | ||
30 | +// Use a shadow on the bar graphs (just use the default settings) | ||
31 | +$bplot->SetShadow(); | ||
32 | +$bplot->value->SetFormat(" $ %2.1f",70); | ||
33 | +$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
34 | +$bplot->value->SetColor("blue"); | ||
35 | +$bplot->value->Show(); | ||
36 | + | ||
37 | +$graph->Add($bplot); | ||
38 | + | ||
39 | +$graph->title->Set("Image maps barex1"); | ||
40 | +$graph->xaxis->title->Set("X-title"); | ||
41 | +$graph->yaxis->title->Set("Y-title"); | ||
42 | + | ||
43 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
44 | +$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
45 | +$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
46 | + | ||
47 | +// Send back the HTML page which will call this script again | ||
48 | +// to retrieve the image. | ||
49 | +$graph->StrokeCSIM(); | ||
50 | + | ||
51 | + | ||
52 | +?> |
@@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +$data1y=array(12,8,19,3,10,5); | ||
6 | +$data2y=array(8,2,12,7,14,4); | ||
7 | + | ||
8 | +// Create the graph. These two calls are always required | ||
9 | +$graph = new Graph(310,200,'auto'); | ||
10 | +$graph->SetScale("textlin"); | ||
11 | +$graph->img->SetMargin(40,30,20,40); | ||
12 | +$graph->SetShadow(); | ||
13 | + | ||
14 | +// Create the bar plots | ||
15 | +$b1plot = new BarPlot($data1y); | ||
16 | +$b1plot->SetFillColor("orange"); | ||
17 | +$targ=array("bar_clsmex2.php#1","bar_clsmex2.php#2","bar_clsmex2.php#3", | ||
18 | +"bar_clsmex2.php#4","bar_clsmex2.php#5","bar_clsmex2.php#6"); | ||
19 | +$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d"); | ||
20 | +$b1plot->SetCSIMTargets($targ,$alts); | ||
21 | + | ||
22 | +$b2plot = new BarPlot($data2y); | ||
23 | +$b2plot->SetFillColor("blue"); | ||
24 | +$targ=array("bar_clsmex2.php#7","bar_clsmex2.php#8","bar_clsmex2.php#9", | ||
25 | +"bar_clsmex2.php#10","bar_clsmex2.php#11","bar_clsmex2.php#12"); | ||
26 | +$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d"); | ||
27 | +$b2plot->SetCSIMTargets($targ,$alts); | ||
28 | + | ||
29 | +// Create the grouped bar plot | ||
30 | +$abplot = new AccBarPlot(array($b1plot,$b2plot)); | ||
31 | + | ||
32 | +$abplot->SetShadow(); | ||
33 | +$abplot->value->Show(); | ||
34 | + | ||
35 | +// ...and add it to the graPH | ||
36 | +$graph->Add($abplot); | ||
37 | + | ||
38 | +$graph->title->Set("Image map barex2"); | ||
39 | +$graph->xaxis->title->Set("X-title"); | ||
40 | +$graph->yaxis->title->Set("Y-title"); | ||
41 | + | ||
42 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
43 | +$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
44 | +$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
45 | + | ||
46 | + | ||
47 | +// Send back the HTML page which will call this script again | ||
48 | +// to retrieve the image. | ||
49 | +$graph->StrokeCSIM(); | ||
50 | + | ||
51 | +?> |
@@ -0,0 +1,88 @@ | @@ -0,0 +1,88 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// $Id: bar_csimex3.php,v 1.3 2002/08/31 20:03:46 aditus Exp $ | ||
3 | +// Horiontal bar graph with image maps | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
6 | + | ||
7 | +$data1y=array(5,8,19,3,10,5); | ||
8 | +$data2y=array(12,2,12,7,14,4); | ||
9 | + | ||
10 | +// Setup the basic parameters for the graph | ||
11 | +$graph = new Graph(400,700); | ||
12 | +$graph->SetAngle(90); | ||
13 | +$graph->SetScale("textlin"); | ||
14 | + | ||
15 | +// The negative margins are necessary since we | ||
16 | +// have rotated the image 90 degress and shifted the | ||
17 | +// meaning of width, and height. This means that the | ||
18 | +// left and right margins now becomes top and bottom | ||
19 | +// calculated with the image width and not the height. | ||
20 | +$graph->img->SetMargin(-80,-80,210,210); | ||
21 | + | ||
22 | +$graph->SetMarginColor('white'); | ||
23 | + | ||
24 | +// Setup title for graph | ||
25 | +$graph->title->Set('Horizontal bar graph'); | ||
26 | +$graph->title->SetFont(FF_FONT2,FS_BOLD); | ||
27 | +$graph->subtitle->Set("With image map\nNote: The URL just points back to this image"); | ||
28 | + | ||
29 | +// Setup X-axis. | ||
30 | +$graph->xaxis->SetTitle("X-title",'center'); | ||
31 | +$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
32 | +$graph->xaxis->title->SetAngle(90); | ||
33 | +$graph->xaxis->SetTitleMargin(30); | ||
34 | +$graph->xaxis->SetLabelMargin(15); | ||
35 | +$graph->xaxis->SetLabelAlign('right','center'); | ||
36 | + | ||
37 | +// Setup Y-axis | ||
38 | + | ||
39 | +// First we want it at the bottom, i.e. the 'max' value of the | ||
40 | +// x-axis | ||
41 | +$graph->yaxis->SetPos('max'); | ||
42 | + | ||
43 | +// Arrange the title | ||
44 | +$graph->yaxis->SetTitle("Turnaround (mkr)",'center'); | ||
45 | +$graph->yaxis->SetTitleSide(SIDE_RIGHT); | ||
46 | +$graph->yaxis->title->SetFont(FF_FONT2,FS_BOLD); | ||
47 | +$graph->yaxis->title->SetAngle(0); | ||
48 | +$graph->yaxis->title->Align('center','top'); | ||
49 | +$graph->yaxis->SetTitleMargin(30); | ||
50 | + | ||
51 | +// Arrange the labels | ||
52 | +$graph->yaxis->SetLabelSide(SIDE_RIGHT); | ||
53 | +$graph->yaxis->SetLabelAlign('center','top'); | ||
54 | + | ||
55 | +// Create the bar plots with image maps | ||
56 | +$b1plot = new BarPlot($data1y); | ||
57 | +$b1plot->SetFillColor("orange"); | ||
58 | +$targ=array("bar_clsmex2.php#1","bar_clsmex2.php#2","bar_clsmex2.php#3", | ||
59 | + "bar_clsmex2.php#4","bar_clsmex2.php#5","bar_clsmex2.php#6"); | ||
60 | +$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d"); | ||
61 | +$b1plot->SetCSIMTargets($targ,$alts); | ||
62 | + | ||
63 | +$b2plot = new BarPlot($data2y); | ||
64 | +$b2plot->SetFillColor("blue"); | ||
65 | +$targ=array("bar_clsmex2.php#7","bar_clsmex2.php#8","bar_clsmex2.php#9", | ||
66 | + "bar_clsmex2.php#10","bar_clsmex2.php#11","bar_clsmex2.php#12"); | ||
67 | +$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d"); | ||
68 | +$b2plot->SetCSIMTargets($targ,$alts); | ||
69 | + | ||
70 | +// Create the accumulated bar plot | ||
71 | +$abplot = new AccBarPlot(array($b1plot,$b2plot)); | ||
72 | +$abplot->SetShadow(); | ||
73 | + | ||
74 | +// We want to display the value of each bar at the top | ||
75 | +$abplot->value->Show(); | ||
76 | +$abplot->value->SetFont(FF_FONT1,FS_NORMAL); | ||
77 | +$abplot->value->SetAlign('left','center'); | ||
78 | +$abplot->value->SetColor("black","darkred"); | ||
79 | +$abplot->value->SetFormat('%.1f mkr'); | ||
80 | + | ||
81 | +// ...and add it to the graph | ||
82 | +$graph->Add($abplot); | ||
83 | + | ||
84 | +// Send back the HTML page which will call this script again | ||
85 | +// to retrieve the image. | ||
86 | +$graph->StrokeCSIM(); | ||
87 | + | ||
88 | +?> |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +<?php | ||
2 | +// ============================================== | ||
3 | +// Output Image using Code 39 using only default values | ||
4 | +// ============================================== | ||
5 | +require_once ('jpgraph/jpgraph_barcode.php'); | ||
6 | + | ||
7 | +try { | ||
8 | +$encoder = BarcodeFactory::Create(ENCODING_CODE39); | ||
9 | +$e = BackendFactory::Create(BACKEND_IMAGE,$encoder); | ||
10 | +$e->Stroke('abc123'); | ||
11 | +} catch( JpGraphException $e ) { | ||
12 | + //echo 'Error: ' . $e->getMessage()."\n"; | ||
13 | + JpGraphError::Raise($e->getMessage()); | ||
14 | +} | ||
15 | + | ||
16 | +?> |
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +<?php | ||
2 | +// ============================================== | ||
3 | +// Output Image using Code 39 using only default values | ||
4 | +// ============================================== | ||
5 | +require_once ('jpgraph/jpgraph_barcode.php'); | ||
6 | + | ||
7 | +$encoder = BarcodeFactory::Create(ENCODING_CODE39); | ||
8 | +$e = BackendFactory::Create(BACKEND_IMAGE,$encoder); | ||
9 | +$e->Stroke('ABC123'); | ||
10 | + | ||
11 | +?> |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<?php | ||
2 | +// ============================================== | ||
3 | +// Output Image using Code 128 | ||
4 | +// ============================================== | ||
5 | +require_once ('jpgraph/jpgraph_barcode.php'); | ||
6 | + | ||
7 | +$encoder = BarcodeFactory::Create(ENCODING_CODE128); | ||
8 | +$e = BackendFactory::Create(BACKEND_PS,$encoder); | ||
9 | +$e->SetModuleWidth(2); | ||
10 | +$e->SetHeight(20); | ||
11 | +echo nl2br($e->Stroke('3125134772')); | ||
12 | + | ||
13 | + | ||
14 | +?> |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<?php | ||
2 | +// ============================================== | ||
3 | +// Output Postscript of nterleaved 2 of 5 | ||
4 | +// ============================================== | ||
5 | +require_once ('jpgraph/jpgraph_barcode.php'); | ||
6 | + | ||
7 | +$encoder = BarcodeFactory::Create(ENCODING_CODEI25); | ||
8 | +$e = BackendFactory::Create(BACKEND_PS,$encoder); | ||
9 | +$e->SetModuleWidth(2); | ||
10 | +$e->SetHeight(70); | ||
11 | +$ps = $e->Stroke('3125134772'); | ||
12 | +echo nl2br(htmlspecialchars($ps)); | ||
13 | + | ||
14 | +?> |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<?php | ||
2 | +// ============================================== | ||
3 | +// Output Encapsulated Postscript of interleaved 2 of 5 | ||
4 | +// ============================================== | ||
5 | +require_once ('jpgraph/jpgraph_barcode.php'); | ||
6 | + | ||
7 | +echo "Start ...<br>"; | ||
8 | +$encoder = BarcodeFactory::Create(ENCODING_CODEI25); | ||
9 | +$e = BackendFactory::Create(BACKEND_PS,$encoder); | ||
10 | +$e->SetModuleWidth(2); | ||
11 | +$e->SetHeight(70); | ||
12 | +$e->SetEPS(); | ||
13 | +$ps = $e->Stroke('3125134772'); | ||
14 | +echo nl2br(htmlspecialchars($ps)); | ||
15 | + | ||
16 | + | ||
17 | +?> |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +<?php | ||
2 | +// ============================================== | ||
3 | +// Output Image using Code Interleaved 2 of 5 | ||
4 | +// ============================================== | ||
5 | +require_once ('jpgraph/jpgraph_barcode.php'); | ||
6 | + | ||
7 | +$encoder = BarcodeFactory::Create(ENCODING_CODEI25); | ||
8 | +$e = BackendFactory::Create(BACKEND_IMAGE,$encoder); | ||
9 | +$e->SetModuleWidth(2); | ||
10 | +$e->Stroke('1234'); | ||
11 | + | ||
12 | +?> |
@@ -0,0 +1,74 @@ | @@ -0,0 +1,74 @@ | ||
1 | +<?php | ||
2 | +// ======================================================= | ||
3 | +// Example of how to format US Postal shipping information | ||
4 | +// ======================================================= | ||
5 | +require_once ('jpgraph/jpgraph_barcode.php'); | ||
6 | + | ||
7 | +// The Full barcode standard is described in | ||
8 | +// http://www.usps.com/cpim/ftp/pubs/pub91/91c4.html#508hdr1 | ||
9 | +// | ||
10 | +// The data start with AI=420 which means | ||
11 | +// "Ship to/Deliver To Postal Code (within single authority) | ||
12 | +// | ||
13 | +class USPS_Confirmation { | ||
14 | + function __construct() { | ||
15 | + } | ||
16 | + | ||
17 | + // Private utility function | ||
18 | + function _USPS_chkd($aData) { | ||
19 | + $n = strlen($aData); | ||
20 | + | ||
21 | + // Add all even numbers starting from position 1 from the end | ||
22 | + $et = 0 ; | ||
23 | + for( $i=1; $i <= $n; $i+=2 ) { | ||
24 | + $d = intval(substr($aData,-$i,1)); | ||
25 | + $et += $d; | ||
26 | + } | ||
27 | + | ||
28 | + // Add all odd numbers starting from position 2 from the end | ||
29 | + $ot = 0 ; | ||
30 | + for( $i=2; $i <= $n; $i+=2 ) { | ||
31 | + $d = intval(substr($aData,-$i,1)); | ||
32 | + $ot += $d; | ||
33 | + } | ||
34 | + $tot = 3*$et + $ot; | ||
35 | + $chkdigit = (10 - ($tot % 10))%10;; | ||
36 | + return $chkdigit; | ||
37 | + } | ||
38 | + | ||
39 | + // Get type 1 of confirmation code (with ZIP) | ||
40 | + function GetPICwithZIP($aZIP,$aServiceType,$aDUNS,$aSeqNbr) { | ||
41 | + // Convert to USPS format with AI=420 and extension starting with AI=91 | ||
42 | + $data = '420'. $aZIP . '91' . $aServiceType . $aDUNS . $aSeqNbr; | ||
43 | + // Only calculate the checkdigit from the AI=91 and forward | ||
44 | + // and do not include the ~1 (FUNC1) in the calculation | ||
45 | + $cd = $this->_USPS_chkd(substr($data,8)); | ||
46 | + $data = '420'. $aZIP . '~191' . $aServiceType . $aDUNS . $aSeqNbr; | ||
47 | + return $data . $cd; | ||
48 | + } | ||
49 | + | ||
50 | + // Get type 2 of confirmation code (without ZIP) | ||
51 | + function GetPIC($aServiceType,$aDUNS,$aSeqNbr) { | ||
52 | + // Convert to USPS format with AI=91 | ||
53 | + $data = '91' . $aServiceType . $aDUNS . $aSeqNbr; | ||
54 | + $cd = $this->_USPS_chkd($data); | ||
55 | + return $data . $cd; | ||
56 | + } | ||
57 | + | ||
58 | +} | ||
59 | + | ||
60 | +$usps = new USPS_Confirmation(); | ||
61 | +$zip = '92663'; | ||
62 | +$service = '21'; | ||
63 | +$DUNS = '805213907'; | ||
64 | +$seqnr = '04508735'; | ||
65 | +$data = $usps->GetPICwithZIP($zip,$service,$DUNS,$seqnr); | ||
66 | +//$data = $usps->GetPIC('01','123456789','00000001'); | ||
67 | + | ||
68 | +$encoder = BarcodeFactory::Create(ENCODING_EAN128); | ||
69 | +$e = BackendFactory::Create(BACKEND_IMAGE,$encoder); | ||
70 | +$e->SetModuleWidth(2); | ||
71 | +$e->SetFont(FF_ARIAL,FS_NORMAL,14); | ||
72 | +$e->Stroke($data); | ||
73 | + | ||
74 | +?> |
@@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +// Some random data to plot | ||
6 | +$datay=array(12,26,9,17,31); | ||
7 | + | ||
8 | +// Create the graph. | ||
9 | +$graph = new Graph(400,250); | ||
10 | +$graph->SetScale("textlin"); | ||
11 | + | ||
12 | +// Create a bar pot | ||
13 | +$bplot = new BarPlot($datay); | ||
14 | + | ||
15 | +// Create targets for the image maps so that the details are opened in a separate window | ||
16 | +$fmtStr = "javascript:window.open('barcsim_details.php?id=%d','_new','width=500,height=300');void(0)"; | ||
17 | +$n = count($datay); | ||
18 | +$targ=array(); | ||
19 | +$alts=array(); | ||
20 | +for($i=0; $i < $n; ++$i) { | ||
21 | + $targ[$i] = sprintf($fmtStr,$i+1); | ||
22 | + $alts[$i] = 'val=%d'; | ||
23 | + // Note: The format placeholder val=%d will be replaced by the actual value in the ouput HTML by the | ||
24 | + // library so that when the user hoovers the mouse over the bar the actual numerical value of the bar | ||
25 | + // will be dísplayed | ||
26 | +} | ||
27 | +$bplot->SetCSIMTargets($targ,$alts); | ||
28 | + | ||
29 | +// Add plot to graph | ||
30 | +$graph->Add($bplot); | ||
31 | + | ||
32 | +// Setup the title, also wih a CSIM area | ||
33 | +$graph->title->Set("CSIM with popup windows"); | ||
34 | +$graph->title->SetFont(FF_FONT2,FS_BOLD); | ||
35 | +// Assume we can give more details on the graph | ||
36 | +$graph->title->SetCSIMTarget(sprintf($fmtStr,-1),'Title for Bar'); | ||
37 | + | ||
38 | +// Send back the HTML page which will call this script again to retrieve the image. | ||
39 | +$graph->StrokeCSIM(); | ||
40 | + | ||
41 | +?> |
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +$data = array(0.1235,0.4567,0.67,0.45,0.832); | ||
6 | + | ||
7 | +// Callback function | ||
8 | +// Get called with the actual value and should return the | ||
9 | +// value to be displayed as a string | ||
10 | +function cbFmtPercentage($aVal) { | ||
11 | + return sprintf("%.1f%%",100*$aVal); // Convert to string | ||
12 | +} | ||
13 | + | ||
14 | +// Create the graph. | ||
15 | +$graph = new Graph(400,300); | ||
16 | +$graph->SetScale("textlin"); | ||
17 | + | ||
18 | +// Create a bar plots | ||
19 | +$bar1 = new BarPlot($data); | ||
20 | + | ||
21 | +// Setup the callback function | ||
22 | +$bar1->value->SetFormatCallback("cbFmtPercentage"); | ||
23 | +$bar1->value->Show(); | ||
24 | + | ||
25 | +// Add the plot to the graph | ||
26 | +$graph->Add($bar1); | ||
27 | + | ||
28 | +// .. and send the graph back to the browser | ||
29 | +$graph->Stroke(); | ||
30 | +?> |
@@ -0,0 +1,48 @@ | @@ -0,0 +1,48 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Example for use of JpGraph, | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// We need some data | ||
7 | +$datay=array(0.13,0.25,0.21,0.35,0.31,0.06); | ||
8 | +$datax=array("January","February","March","April","May","June"); | ||
9 | + | ||
10 | +// Setup the graph. | ||
11 | +$graph = new Graph(400,240); | ||
12 | +$graph->clearTheme(); | ||
13 | +$graph->img->SetMargin(60,20,35,75); | ||
14 | +$graph->SetScale("textlin"); | ||
15 | +$graph->SetMarginColor("lightblue:1.1"); | ||
16 | +$graph->SetShadow(); | ||
17 | + | ||
18 | +// Set up the title for the graph | ||
19 | +$graph->title->Set("Bar gradient with left reflection"); | ||
20 | +$graph->title->SetMargin(8); | ||
21 | +$graph->title->SetFont(FF_VERDANA,FS_BOLD,12); | ||
22 | +$graph->title->SetColor("darkred"); | ||
23 | + | ||
24 | +// Setup font for axis | ||
25 | +$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
26 | +$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
27 | + | ||
28 | +// Show 0 label on Y-axis (default is not to show) | ||
29 | +$graph->yscale->ticks->SupressZeroLabel(false); | ||
30 | + | ||
31 | +// Setup X-axis labels | ||
32 | +$graph->xaxis->SetTickLabels($datax); | ||
33 | +$graph->xaxis->SetLabelAngle(50); | ||
34 | + | ||
35 | +// Create the bar pot | ||
36 | +$bplot = new BarPlot($datay); | ||
37 | +$bplot->SetWidth(0.6); | ||
38 | + | ||
39 | +// Setup color for gradient fill style | ||
40 | +$bplot->SetFillGradient("navy:0.9","navy:1.85",GRAD_LEFT_REFLECTION); | ||
41 | + | ||
42 | +// Set color for the frame of each bar | ||
43 | +$bplot->SetColor("white"); | ||
44 | +$graph->Add($bplot); | ||
45 | + | ||
46 | +// Finally send the graph to the browser | ||
47 | +$graph->Stroke(); | ||
48 | +?> |
@@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Example for use of JpGraph, | ||
3 | +// ljp, 01/03/01 20:32 | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
6 | + | ||
7 | +// We need some data | ||
8 | +$datay=array(-0.13,0.25,-0.21,0.35,0.31,0.04); | ||
9 | +$datax=array("Jan","Feb","Mar","Apr","May","June"); | ||
10 | + | ||
11 | +// Setup the graph. | ||
12 | +$graph = new Graph(400,200); | ||
13 | +$graph->clearTheme(); | ||
14 | +$graph->img->SetMargin(60,20,30,50); | ||
15 | +$graph->SetScale("textlin"); | ||
16 | +$graph->SetMarginColor("silver"); | ||
17 | +$graph->SetShadow(); | ||
18 | + | ||
19 | +// Set up the title for the graph | ||
20 | +$graph->title->Set("Example negative bars"); | ||
21 | +$graph->title->SetFont(FF_VERDANA,FS_NORMAL,18); | ||
22 | +$graph->title->SetColor("darkred"); | ||
23 | + | ||
24 | +// Setup font for axis | ||
25 | +$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,12); | ||
26 | +$graph->xaxis->SetColor("black","red"); | ||
27 | +$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,11); | ||
28 | + | ||
29 | +// Show 0 label on Y-axis (default is not to show) | ||
30 | +$graph->yscale->ticks->SupressZeroLabel(false); | ||
31 | + | ||
32 | +// Setup X-axis labels | ||
33 | +$graph->xaxis->SetTickLabels($datax); | ||
34 | +$graph->xaxis->SetLabelAngle(50); | ||
35 | + | ||
36 | +// Create the bar pot | ||
37 | +$bplot = new BarPlot($datay); | ||
38 | +$bplot->SetWidth(0.6); | ||
39 | + | ||
40 | +// Setup color for gradient fill style | ||
41 | +$bplot->SetFillGradient("navy","steelblue",GRAD_MIDVER); | ||
42 | + | ||
43 | +// Set color for the frame of each bar | ||
44 | +$bplot->SetColor("navy"); | ||
45 | +$graph->Add($bplot); | ||
46 | + | ||
47 | +// Finally send the graph to the browser | ||
48 | +$graph->Stroke(); | ||
49 | +?> |
@@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Example for use of JpGraph, | ||
3 | +// ljp, 01/03/01 20:32 | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
6 | + | ||
7 | +// We need some data | ||
8 | +$datay=array(-0.13,0.25,-0.21,0.35,0.31,0.04); | ||
9 | +$datax=array("Jan","Feb","Mar","Apr","May","June"); | ||
10 | + | ||
11 | +// Setup the graph. | ||
12 | +$graph = new Graph(400,200); | ||
13 | +$graph->clearTheme(); | ||
14 | +$graph->img->SetMargin(60,20,30,50); | ||
15 | +$graph->SetScale("textlin"); | ||
16 | +$graph->SetMarginColor("silver"); | ||
17 | +$graph->SetShadow(); | ||
18 | + | ||
19 | +// Set up the title for the graph | ||
20 | +$graph->title->Set("Example negative bars"); | ||
21 | +$graph->title->SetFont(FF_VERDANA,FS_NORMAL,16); | ||
22 | +$graph->title->SetColor("darkred"); | ||
23 | + | ||
24 | +// Setup font for axis | ||
25 | +$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
26 | +$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
27 | + | ||
28 | +// Show 0 label on Y-axis (default is not to show) | ||
29 | +$graph->yscale->ticks->SupressZeroLabel(false); | ||
30 | + | ||
31 | +// Setup X-axis labels | ||
32 | +$graph->xaxis->SetTickLabels($datax); | ||
33 | +$graph->xaxis->SetLabelAngle(50); | ||
34 | + | ||
35 | +// Set X-axis at the minimum value of Y-axis (default will be at 0) | ||
36 | +$graph->xaxis->SetPos("min"); // "min" will position the x-axis at the minimum value of the Y-axis | ||
37 | + | ||
38 | +// Create the bar pot | ||
39 | +$bplot = new BarPlot($datay); | ||
40 | +$bplot->SetWidth(0.6); | ||
41 | + | ||
42 | +// Setup color for gradient fill style | ||
43 | +$bplot->SetFillGradient("navy","steelblue",GRAD_MIDVER); | ||
44 | + | ||
45 | +// Set color for the frame of each bar | ||
46 | +$bplot->SetColor("navy"); | ||
47 | +$graph->Add($bplot); | ||
48 | + | ||
49 | +// Finally send the graph to the browser | ||
50 | +$graph->Stroke(); | ||
51 | +?> |
@@ -0,0 +1,48 @@ | @@ -0,0 +1,48 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Example for use of JpGraph, | ||
3 | +// ljp, 01/03/01 19:44 | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
6 | + | ||
7 | +// We need some data | ||
8 | +$datay=array(0.3031,0.3044,0.3049,0.3040,0.3024,0.3047); | ||
9 | + | ||
10 | +// Setup the graph. | ||
11 | +$graph = new Graph(400,200); | ||
12 | +$graph->clearTheme(); | ||
13 | +$graph->img->SetMargin(60,30,30,40); | ||
14 | +$graph->SetScale("textlin"); | ||
15 | +$graph->SetMarginColor("teal"); | ||
16 | +$graph->SetShadow(); | ||
17 | + | ||
18 | +// Set up the title for the graph | ||
19 | +$graph->title->Set("Bargraph with small variations"); | ||
20 | +$graph->title->SetColor("white"); | ||
21 | +$graph->title->SetFont(FF_VERDANA,FS_BOLD,12); | ||
22 | + | ||
23 | +// Setup color for axis and labels | ||
24 | +$graph->xaxis->SetColor("black","white"); | ||
25 | +$graph->yaxis->SetColor("black","white"); | ||
26 | + | ||
27 | +// Setup font for axis | ||
28 | +$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
29 | +$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
30 | + | ||
31 | +// Setup X-axis title (color & font) | ||
32 | +$graph->xaxis->title->Set("X-axis"); | ||
33 | +$graph->xaxis->title->SetColor("white"); | ||
34 | +$graph->xaxis->title->SetFont(FF_VERDANA,FS_BOLD,10); | ||
35 | + | ||
36 | +// Create the bar pot | ||
37 | +$bplot = new BarPlot($datay); | ||
38 | +$bplot->SetWidth(0.6); | ||
39 | + | ||
40 | +// Setup color for gradient fill style | ||
41 | +$tcol=array(100,100,255); | ||
42 | +$fcol=array(255,100,100); | ||
43 | +$bplot->SetFillGradient($fcol,$tcol,GRAD_HOR); | ||
44 | +$graph->Add($bplot); | ||
45 | + | ||
46 | +// Finally send the graph to the browser | ||
47 | +$graph->Stroke(); | ||
48 | +?> |
@@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Example for use of JpGraph, | ||
3 | +// ljp, 01/03/01 19:44 | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
6 | +require_once ('jpgraph/jpgraph_line.php'); | ||
7 | + | ||
8 | +// We need some data | ||
9 | +$datay=array(0.3031,0.3044,0.3049,0.3040,0.3024,0.3047); | ||
10 | + | ||
11 | +// Setup the graph. | ||
12 | +$graph = new Graph(400,200); | ||
13 | +$graph->clearTheme(); | ||
14 | +$graph->img->SetMargin(60,30,30,40); | ||
15 | +$graph->SetScale("textlin"); | ||
16 | +$graph->SetMarginColor("teal"); | ||
17 | +$graph->SetShadow(); | ||
18 | + | ||
19 | +// Create the bar pot | ||
20 | +$bplot = new BarPlot($datay); | ||
21 | +$bplot->SetWidth(0.6); | ||
22 | + | ||
23 | +// This is how you make the bar graph start from something other than 0 | ||
24 | +$bplot->SetYMin(0.302); | ||
25 | + | ||
26 | +// Setup color for gradient fill style | ||
27 | +$tcol=array(100,100,255); | ||
28 | +$fcol=array(255,100,100); | ||
29 | +$bplot->SetFillGradient($fcol,$tcol,GRAD_HOR); | ||
30 | +$bplot->SetFillColor("orange"); | ||
31 | +$graph->Add($bplot); | ||
32 | + | ||
33 | +// Set up the title for the graph | ||
34 | +$graph->title->Set("Bargraph which doesn't start from y=0"); | ||
35 | +$graph->title->SetColor("yellow"); | ||
36 | +$graph->title->SetFont(FF_VERDANA,FS_BOLD,12); | ||
37 | + | ||
38 | +// Setup color for axis and labels | ||
39 | +$graph->xaxis->SetColor("black","white"); | ||
40 | +$graph->yaxis->SetColor("black","white"); | ||
41 | + | ||
42 | +// Setup font for axis | ||
43 | +$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
44 | +$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
45 | + | ||
46 | +// Setup X-axis title (color & font) | ||
47 | +$graph->xaxis->title->Set("X-axis"); | ||
48 | +$graph->xaxis->title->SetColor("white"); | ||
49 | +$graph->xaxis->title->SetFont(FF_VERDANA,FS_BOLD,10); | ||
50 | + | ||
51 | +// Finally send the graph to the browser | ||
52 | +$graph->Stroke(); | ||
53 | +?> |
@@ -0,0 +1,52 @@ | @@ -0,0 +1,52 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Example for use of JpGraph, | ||
3 | +// ljp, 01/03/01 20:32 | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
6 | + | ||
7 | +// We need some data | ||
8 | +$datay=array(-0.13,0.25,-0.21,0.35,0.31,0.04); | ||
9 | +$datax=array("Jan","Feb","Mar","Apr","May","June"); | ||
10 | + | ||
11 | +// Setup the graph. | ||
12 | +$graph = new Graph(500,200); | ||
13 | +$graph->clearTheme(); | ||
14 | +$graph->img->SetMargin(60,150,30,50); | ||
15 | +$graph->SetScale("textlin"); | ||
16 | +$graph->SetMarginColor("silver"); | ||
17 | +$graph->SetShadow(); | ||
18 | + | ||
19 | +// Set up the title for the graph | ||
20 | +$graph->title->Set("Example negative bars"); | ||
21 | +$graph->title->SetFont(FF_VERDANA,FS_NORMAL,16); | ||
22 | +$graph->title->SetColor("darkred"); | ||
23 | + | ||
24 | +// Setup font for axis | ||
25 | +$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
26 | +$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10); | ||
27 | + | ||
28 | +// Show 0 label on Y-axis (default is not to show) | ||
29 | +$graph->yscale->ticks->SupressZeroLabel(false); | ||
30 | + | ||
31 | +// Setup X-axis labels | ||
32 | +$graph->xaxis->SetTickLabels($datax); | ||
33 | +$graph->xaxis->SetLabelAngle(50); | ||
34 | + | ||
35 | +// Set X-axis at the minimum value of Y-axis (default will be at 0) | ||
36 | +$graph->xaxis->SetPos("min"); // "min" will position the x-axis at the minimum value of the Y-axis | ||
37 | + | ||
38 | +// Create the bar pot | ||
39 | +$bplot = new BarPlot($datay); | ||
40 | +$bplot->SetWidth(0.6); | ||
41 | +$bplot->SetLegend("Result 1999","blue"); | ||
42 | + | ||
43 | +// Setup color for gradient fill style | ||
44 | +$bplot->SetFillGradient("navy","steelblue",GRAD_MIDVER); | ||
45 | + | ||
46 | +// Set color for the frame of each bar | ||
47 | +$bplot->SetColor("navy"); | ||
48 | +$graph->Add($bplot); | ||
49 | + | ||
50 | +// Finally send the graph to the browser | ||
51 | +$graph->Stroke(); | ||
52 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// We need some data | ||
7 | +$datay=array(4,8,6); | ||
8 | + | ||
9 | +// Setup the graph. | ||
10 | +$graph = new Graph(200,150); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->img->SetMargin(25,15,25,25); | ||
13 | + | ||
14 | +$graph->title->Set('"GRAD_MIDVER"'); | ||
15 | +$graph->title->SetColor('darkred'); | ||
16 | + | ||
17 | +// Setup font for axis | ||
18 | +$graph->xaxis->SetFont(FF_FONT1); | ||
19 | +$graph->yaxis->SetFont(FF_FONT1); | ||
20 | + | ||
21 | +// Create the bar pot | ||
22 | +$bplot = new BarPlot($datay); | ||
23 | +$bplot->SetWidth(0.6); | ||
24 | + | ||
25 | +// Setup color for gradient fill style | ||
26 | +$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDVER); | ||
27 | + | ||
28 | +// Set color for the frame of each bar | ||
29 | +$bplot->SetColor("navy"); | ||
30 | +$graph->Add($bplot); | ||
31 | + | ||
32 | +// Finally send the graph to the browser | ||
33 | +$graph->Stroke(); | ||
34 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// We need some data | ||
7 | +$datay=array(4,8,6); | ||
8 | + | ||
9 | +// Setup the graph. | ||
10 | +$graph = new Graph(200,150); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->img->SetMargin(25,15,25,25); | ||
13 | + | ||
14 | +$graph->title->Set('"GRAD_MIDHOR"'); | ||
15 | +$graph->title->SetColor('darkred'); | ||
16 | + | ||
17 | +// Setup font for axis | ||
18 | +$graph->xaxis->SetFont(FF_FONT1); | ||
19 | +$graph->yaxis->SetFont(FF_FONT1); | ||
20 | + | ||
21 | +// Create the bar pot | ||
22 | +$bplot = new BarPlot($datay); | ||
23 | +$bplot->SetWidth(0.6); | ||
24 | + | ||
25 | +// Setup color for gradient fill style | ||
26 | +$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDHOR); | ||
27 | + | ||
28 | +// Set color for the frame of each bar | ||
29 | +$bplot->SetColor("navy"); | ||
30 | +$graph->Add($bplot); | ||
31 | + | ||
32 | +// Finally send the graph to the browser | ||
33 | +$graph->Stroke(); | ||
34 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// We need some data | ||
7 | +$datay=array(4,8,6); | ||
8 | + | ||
9 | +// Setup the graph. | ||
10 | +$graph = new Graph(200,150); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->img->SetMargin(25,15,25,25); | ||
13 | + | ||
14 | +$graph->title->Set('"GRAD_HOR"'); | ||
15 | +$graph->title->SetColor('darkred'); | ||
16 | + | ||
17 | +// Setup font for axis | ||
18 | +$graph->xaxis->SetFont(FF_FONT1); | ||
19 | +$graph->yaxis->SetFont(FF_FONT1); | ||
20 | + | ||
21 | +// Create the bar pot | ||
22 | +$bplot = new BarPlot($datay); | ||
23 | +$bplot->SetWidth(0.6); | ||
24 | + | ||
25 | +// Setup color for gradient fill style | ||
26 | +$bplot->SetFillGradient("navy","lightsteelblue",GRAD_HOR); | ||
27 | + | ||
28 | +// Set color for the frame of each bar | ||
29 | +$bplot->SetColor("navy"); | ||
30 | +$graph->Add($bplot); | ||
31 | + | ||
32 | +// Finally send the graph to the browser | ||
33 | +$graph->Stroke(); | ||
34 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// We need some data | ||
7 | +$datay=array(4,8,6); | ||
8 | + | ||
9 | +// Setup the graph. | ||
10 | +$graph = new Graph(200,150); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->img->SetMargin(25,15,25,25); | ||
13 | + | ||
14 | +$graph->title->Set('"GRAD_VER"'); | ||
15 | +$graph->title->SetColor('darkred'); | ||
16 | + | ||
17 | +// Setup font for axis | ||
18 | +$graph->xaxis->SetFont(FF_FONT1); | ||
19 | +$graph->yaxis->SetFont(FF_FONT1); | ||
20 | + | ||
21 | +// Create the bar pot | ||
22 | +$bplot = new BarPlot($datay); | ||
23 | +$bplot->SetWidth(0.6); | ||
24 | + | ||
25 | +// Setup color for gradient fill style | ||
26 | +$bplot->SetFillGradient("navy","lightsteelblue",GRAD_VER); | ||
27 | + | ||
28 | +// Set color for the frame of each bar | ||
29 | +$bplot->SetColor("navy"); | ||
30 | +$graph->Add($bplot); | ||
31 | + | ||
32 | +// Finally send the graph to the browser | ||
33 | +$graph->Stroke(); | ||
34 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// We need some data | ||
7 | +$datay=array(4,8,6); | ||
8 | + | ||
9 | +// Setup the graph. | ||
10 | +$graph = new Graph(200,150); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->img->SetMargin(25,15,25,25); | ||
13 | + | ||
14 | +$graph->title->Set('"GRAD_WIDE_MIDVER"'); | ||
15 | +$graph->title->SetColor('darkred'); | ||
16 | + | ||
17 | +// Setup font for axis | ||
18 | +$graph->xaxis->SetFont(FF_FONT1); | ||
19 | +$graph->yaxis->SetFont(FF_FONT1); | ||
20 | + | ||
21 | +// Create the bar pot | ||
22 | +$bplot = new BarPlot($datay); | ||
23 | +$bplot->SetWidth(0.6); | ||
24 | + | ||
25 | +// Setup color for gradient fill style | ||
26 | +$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER); | ||
27 | + | ||
28 | +// Set color for the frame of each bar | ||
29 | +$bplot->SetColor("navy"); | ||
30 | +$graph->Add($bplot); | ||
31 | + | ||
32 | +// Finally send the graph to the browser | ||
33 | +$graph->Stroke(); | ||
34 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// We need some data | ||
7 | +$datay=array(4,8,6); | ||
8 | + | ||
9 | +// Setup the graph. | ||
10 | +$graph = new Graph(200,150); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->img->SetMargin(25,15,25,25); | ||
13 | + | ||
14 | +$graph->title->Set('"GRAD_WIDE_MIDHOR"'); | ||
15 | +$graph->title->SetColor('darkred'); | ||
16 | + | ||
17 | +// Setup font for axis | ||
18 | +$graph->xaxis->SetFont(FF_FONT1); | ||
19 | +$graph->yaxis->SetFont(FF_FONT1); | ||
20 | + | ||
21 | +// Create the bar pot | ||
22 | +$bplot = new BarPlot($datay); | ||
23 | +$bplot->SetWidth(0.6); | ||
24 | + | ||
25 | +// Setup color for gradient fill style | ||
26 | +$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDHOR); | ||
27 | + | ||
28 | +// Set color for the frame of each bar | ||
29 | +$bplot->SetColor("navy"); | ||
30 | +$graph->Add($bplot); | ||
31 | + | ||
32 | +// Finally send the graph to the browser | ||
33 | +$graph->Stroke(); | ||
34 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// We need some data | ||
7 | +$datay=array(4,8,6); | ||
8 | + | ||
9 | +// Setup the graph. | ||
10 | +$graph = new Graph(200,150); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->img->SetMargin(25,15,25,25); | ||
13 | + | ||
14 | +$graph->title->Set('"GRAD_CENTER"'); | ||
15 | +$graph->title->SetColor('darkred'); | ||
16 | + | ||
17 | +// Setup font for axis | ||
18 | +$graph->xaxis->SetFont(FF_FONT1); | ||
19 | +$graph->yaxis->SetFont(FF_FONT1); | ||
20 | + | ||
21 | +// Create the bar pot | ||
22 | +$bplot = new BarPlot($datay); | ||
23 | +$bplot->SetWidth(0.6); | ||
24 | + | ||
25 | +// Setup color for gradient fill style | ||
26 | +$bplot->SetFillGradient("navy","lightsteelblue",GRAD_CENTER); | ||
27 | + | ||
28 | +// Set color for the frame of each bar | ||
29 | +$bplot->SetColor("navy"); | ||
30 | +$graph->Add($bplot); | ||
31 | + | ||
32 | +// Finally send the graph to the browser | ||
33 | +$graph->Stroke(); | ||
34 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// We need some data | ||
7 | +$datay=array(4,8,6); | ||
8 | + | ||
9 | +// Setup the graph. | ||
10 | +$graph = new Graph(200,150); | ||
11 | +$graph->SetScale("textlin"); | ||
12 | +$graph->img->SetMargin(25,15,25,25); | ||
13 | + | ||
14 | +$graph->title->Set('"GRAD_RAISED_PANEL"'); | ||
15 | +$graph->title->SetColor('darkred'); | ||
16 | + | ||
17 | +// Setup font for axis | ||
18 | +$graph->xaxis->SetFont(FF_FONT1); | ||
19 | +$graph->yaxis->SetFont(FF_FONT1); | ||
20 | + | ||
21 | +// Create the bar pot | ||
22 | +$bplot = new BarPlot($datay); | ||
23 | +$bplot->SetWidth(0.6); | ||
24 | + | ||
25 | +// Setup color for gradient fill style | ||
26 | +$bplot->SetFillGradient('navy','orange',GRAD_RAISED_PANEL); | ||
27 | + | ||
28 | +// Set color for the frame of each bar | ||
29 | +$bplot->SetColor("navy"); | ||
30 | +$graph->Add($bplot); | ||
31 | + | ||
32 | +// Finally send the graph to the browser | ||
33 | +$graph->Stroke(); | ||
34 | +?> |
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | +require_once ('jpgraph/jpgraph_line.php'); | ||
5 | + | ||
6 | +$datay=array(5,3,11,6,3); | ||
7 | + | ||
8 | +$graph = new Graph(400,300,'auto'); | ||
9 | +$graph->clearTheme(); | ||
10 | +$graph->SetScale("textlin"); | ||
11 | + | ||
12 | +$graph->title->Set('Images on top of bars'); | ||
13 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,13); | ||
14 | + | ||
15 | +$graph->SetTitleBackground('lightblue:1.1',TITLEBKG_STYLE1,TITLEBKG_FRAME_BEVEL); | ||
16 | + | ||
17 | +$bplot = new BarPlot($datay); | ||
18 | +$bplot->SetFillColor("orange"); | ||
19 | +$bplot->SetWidth(0.5); | ||
20 | + | ||
21 | +$lplot = new LinePlot($datay); | ||
22 | +$lplot->SetColor('white@1'); | ||
23 | +$lplot->SetBarCenter(); | ||
24 | +$lplot->mark->SetType(MARK_IMG_LBALL,'red'); | ||
25 | + | ||
26 | +$graph->Add($bplot); | ||
27 | +$graph->Add($lplot); | ||
28 | + | ||
29 | +$graph->Stroke(); | ||
30 | +?> |
@@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// $Id: barintex1.php,v 1.3 2002/07/11 23:27:28 aditus Exp $ | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +// Some data | ||
7 | +$datay=array(1,1,0.5); | ||
8 | + | ||
9 | +// Create the graph and setup the basic parameters | ||
10 | +$graph = new Graph(460,200,'auto'); | ||
11 | +$graph->clearTheme(); | ||
12 | +$graph->img->SetMargin(40,30,30,40); | ||
13 | +$graph->SetScale("textint"); | ||
14 | +$graph->SetShadow(); | ||
15 | +$graph->SetFrame(false); // No border around the graph | ||
16 | + | ||
17 | +// Add some grace to the top so that the scale doesn't | ||
18 | +// end exactly at the max value. | ||
19 | +$graph->yaxis->scale->SetGrace(100); | ||
20 | + | ||
21 | +// Setup X-axis labels | ||
22 | +$a = $gDateLocale->GetShortMonth(); | ||
23 | +$graph->xaxis->SetTickLabels($a); | ||
24 | +$graph->xaxis->SetFont(FF_FONT2); | ||
25 | + | ||
26 | +// Setup graph title ands fonts | ||
27 | +$graph->title->Set("Example of integer Y-scale"); | ||
28 | +$graph->title->SetFont(FF_FONT2,FS_BOLD); | ||
29 | +$graph->xaxis->title->Set("Year 2002"); | ||
30 | +$graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD); | ||
31 | + | ||
32 | +// Create a bar pot | ||
33 | +$bplot = new BarPlot($datay); | ||
34 | +$bplot->SetFillColor("orange"); | ||
35 | +$bplot->SetWidth(0.5); | ||
36 | +$bplot->SetShadow(); | ||
37 | + | ||
38 | +// Setup the values that are displayed on top of each bar | ||
39 | +$bplot->value->Show(); | ||
40 | +// Must use TTF fonts if we want text at an arbitrary angle | ||
41 | +$bplot->value->SetFont(FF_ARIAL,FS_BOLD); | ||
42 | +$bplot->value->SetAngle(45); | ||
43 | +// Black color for positive values and darkred for negative values | ||
44 | +$bplot->value->SetColor("black","darkred"); | ||
45 | +$graph->Add($bplot); | ||
46 | + | ||
47 | +// Finally stroke the graph | ||
48 | +$graph->Stroke(); | ||
49 | +?> |
@@ -0,0 +1,58 @@ | @@ -0,0 +1,58 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$datay=array(3,7,19,11,4,20); | ||
7 | + | ||
8 | +// Create the graph and setup the basic parameters | ||
9 | +$graph = new Graph(350,200,'auto'); | ||
10 | +$graph->clearTheme(); | ||
11 | +$graph->img->SetMargin(40,30,40,40); | ||
12 | +$graph->SetScale("textint"); | ||
13 | +$graph->SetFrame(true,'blue',1); | ||
14 | +$graph->SetColor('lightblue'); | ||
15 | +$graph->SetMarginColor('lightblue'); | ||
16 | + | ||
17 | +// Add some grace to the top so that the scale doesn't | ||
18 | +// end exactly at the max value. | ||
19 | +//$graph->yaxis->scale->SetGrace(20); | ||
20 | + | ||
21 | +// Setup X-axis labels | ||
22 | +$a = $gDateLocale->GetShortMonth(); | ||
23 | +$graph->xaxis->SetTickLabels($a); | ||
24 | +$graph->xaxis->SetFont(FF_FONT1); | ||
25 | +$graph->xaxis->SetColor('darkblue','black'); | ||
26 | + | ||
27 | +// Stup "hidden" y-axis by given it the same color | ||
28 | +// as the background | ||
29 | +$graph->yaxis->SetColor('lightblue','darkblue'); | ||
30 | +$graph->ygrid->SetColor('white'); | ||
31 | + | ||
32 | +// Setup graph title ands fonts | ||
33 | +$graph->title->Set('Example of integer Y-scale'); | ||
34 | +$graph->subtitle->Set('(With "hidden" y-axis)'); | ||
35 | + | ||
36 | +$graph->title->SetFont(FF_FONT2,FS_BOLD); | ||
37 | +$graph->xaxis->title->Set("Year 2002"); | ||
38 | +$graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD); | ||
39 | + | ||
40 | +// Create a bar pot | ||
41 | +$bplot = new BarPlot($datay); | ||
42 | +$bplot->SetFillColor('darkblue'); | ||
43 | +$bplot->SetColor('darkblue'); | ||
44 | +$bplot->SetWidth(0.5); | ||
45 | +$bplot->SetShadow('darkgray'); | ||
46 | + | ||
47 | +// Setup the values that are displayed on top of each bar | ||
48 | +$bplot->value->Show(); | ||
49 | +// Must use TTF fonts if we want text at an arbitrary angle | ||
50 | +$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,8); | ||
51 | +$bplot->value->SetFormat('$%d'); | ||
52 | +// Black color for positive values and darkred for negative values | ||
53 | +$bplot->value->SetColor("black","darkred"); | ||
54 | +$graph->Add($bplot); | ||
55 | + | ||
56 | +// Finally stroke the graph | ||
57 | +$graph->Stroke(); | ||
58 | +?> |
@@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_line.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | + | ||
6 | +$ydata = array(2,3,4,5,6,7,8,9,10,11); | ||
7 | +$ydata2 = array(1,2,3,4,5,6,7,8,9,10); | ||
8 | +$targ = array("#1","#2","#3","#4","#5","#6","#7","#8","#9","#10"); | ||
9 | +$alt = array(1,2,3,4,5,6,7,8,9,10); | ||
10 | + | ||
11 | +// Create the graph. | ||
12 | +$graph = new Graph(300,200); | ||
13 | +$graph->SetScale("textlin"); | ||
14 | +$graph->img->SetMargin(40,20,30,40); | ||
15 | +$graph->title->Set("CSIM example with bar and line"); | ||
16 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
17 | + | ||
18 | +// Setup axis titles | ||
19 | +$graph->xaxis->title->Set("X-title"); | ||
20 | +$graph->yaxis->title->Set("Y-title"); | ||
21 | + | ||
22 | +// Create the linear plot | ||
23 | +$lineplot=new LinePlot($ydata); | ||
24 | +$lineplot->mark->SetType(MARK_FILLEDCIRCLE); | ||
25 | +$lineplot->mark->SetWidth(5); | ||
26 | +$lineplot->mark->SetColor('black'); | ||
27 | +$lineplot->mark->SetFillColor('red'); | ||
28 | +$lineplot->SetCSIMTargets($targ,$alt); | ||
29 | + | ||
30 | +// Create line plot | ||
31 | +$barplot=new barPlot($ydata2); | ||
32 | +$barplot->SetCSIMTargets($targ,$alt); | ||
33 | + | ||
34 | +// Add the plots to the graph | ||
35 | +$graph->Add($lineplot); | ||
36 | +$graph->Add($barplot); | ||
37 | + | ||
38 | +$graph->StrokeCSIM(); | ||
39 | + | ||
40 | +?> | ||
41 | + | ||
42 | + |
@@ -0,0 +1,74 @@ | @@ -0,0 +1,74 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | +require_once ('jpgraph/jpgraph_line.php'); | ||
5 | + | ||
6 | +// Some "random" data | ||
7 | +$ydata = array(10,120,80,190,260,170,60,40,20,230); | ||
8 | +$ydata2 = array(10,70,40,120,200,60,80,40,20,5); | ||
9 | + | ||
10 | +// Get a list of month using the current locale | ||
11 | +$months = $gDateLocale->GetShortMonth(); | ||
12 | + | ||
13 | +// Create the graph. | ||
14 | +$graph = new Graph(300,200); | ||
15 | +$graph->SetScale("textlin"); | ||
16 | +$graph->SetMarginColor('white'); | ||
17 | + | ||
18 | +// Adjust the margin slightly so that we use the | ||
19 | +// entire area (since we don't use a frame) | ||
20 | +$graph->SetMargin(30,1,20,5); | ||
21 | + | ||
22 | +// Box around plotarea | ||
23 | +$graph->SetBox(); | ||
24 | + | ||
25 | +// No frame around the image | ||
26 | +$graph->SetFrame(false); | ||
27 | + | ||
28 | +// Setup the tab title | ||
29 | +$graph->tabtitle->Set('Year 2003'); | ||
30 | +$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,10); | ||
31 | + | ||
32 | +// Setup the X and Y grid | ||
33 | +$graph->ygrid->SetFill(true,'#DDDDDD@0.5','#BBBBBB@0.5'); | ||
34 | +$graph->ygrid->SetLineStyle('dashed'); | ||
35 | +$graph->ygrid->SetColor('gray'); | ||
36 | +$graph->xgrid->Show(); | ||
37 | +$graph->xgrid->SetLineStyle('dashed'); | ||
38 | +$graph->xgrid->SetColor('gray'); | ||
39 | + | ||
40 | +// Setup month as labels on the X-axis | ||
41 | +$graph->xaxis->SetTickLabels($months); | ||
42 | +$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8); | ||
43 | +$graph->xaxis->SetLabelAngle(45); | ||
44 | + | ||
45 | +// Create a bar pot | ||
46 | +$bplot = new BarPlot($ydata); | ||
47 | +$bplot->SetWidth(0.6); | ||
48 | +$fcol='#440000'; | ||
49 | +$tcol='#FF9090'; | ||
50 | + | ||
51 | +$bplot->SetFillGradient($fcol,$tcol,GRAD_LEFT_REFLECTION); | ||
52 | + | ||
53 | +// Set line weigth to 0 so that there are no border | ||
54 | +// around each bar | ||
55 | +$bplot->SetWeight(0); | ||
56 | + | ||
57 | +$graph->Add($bplot); | ||
58 | + | ||
59 | +// Create filled line plot | ||
60 | +$lplot = new LinePlot($ydata2); | ||
61 | +$lplot->SetFillColor('skyblue@0.5'); | ||
62 | +$lplot->SetColor('navy@0.7'); | ||
63 | +$lplot->SetBarCenter(); | ||
64 | + | ||
65 | +$lplot->mark->SetType(MARK_SQUARE); | ||
66 | +$lplot->mark->SetColor('blue@0.5'); | ||
67 | +$lplot->mark->SetFillColor('lightblue'); | ||
68 | +$lplot->mark->SetSize(6); | ||
69 | + | ||
70 | +$graph->Add($lplot); | ||
71 | + | ||
72 | +// .. and finally send it back to the browser | ||
73 | +$graph->Stroke(); | ||
74 | +?> |
@@ -0,0 +1,100 @@ | @@ -0,0 +1,100 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// | ||
3 | +// Example of CSIM frequence bar that uses the cache | ||
4 | +// | ||
5 | +require_once ('jpgraph/jpgraph.php'); | ||
6 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
7 | +require_once ('jpgraph/jpgraph_line.php'); | ||
8 | + | ||
9 | + | ||
10 | +// Utility function to calculate the accumulated frequence | ||
11 | +// for a set of values and ocurrences | ||
12 | +function accfreq($data) { | ||
13 | + rsort($data); | ||
14 | + $s = array_sum($data); | ||
15 | + $as = array($data[0]); | ||
16 | + $asp = array(100*$as[0]/$s); | ||
17 | + $n = count($data); | ||
18 | + for( $i=1; $i < $n; ++$i ) { | ||
19 | + $as[$i] = $as[$i-1]+$data[$i]; | ||
20 | + $asp[$i] = 100.0*$as[$i]/$s; | ||
21 | + } | ||
22 | + return $asp; | ||
23 | +} | ||
24 | + | ||
25 | +// some data | ||
26 | +$data_freq = array(22,20,12,10,5,4,2); | ||
27 | +$data_accfreq = accfreq($data_freq); | ||
28 | + | ||
29 | +// Create the graph. | ||
30 | +$graph = new Graph(350,250); | ||
31 | + | ||
32 | +// We need to make this extra call for CSIM scripts | ||
33 | +// that make use of the cache. If the cache contains this | ||
34 | +// graph the HTML wrapper will be returned and then the | ||
35 | +// method will call exit() and hence NO LINES AFTER THIS | ||
36 | +// CALL WILL BE EXECUTED. | ||
37 | +// $graph->CheckCSIMCache('auto'); | ||
38 | + | ||
39 | +// Setup some basic graph parameters | ||
40 | +$graph->SetScale("textlin"); | ||
41 | +$graph->SetY2Scale('lin',0,100); | ||
42 | +$graph->img->SetMargin(50,70,30,40); | ||
43 | +$graph->yaxis->SetTitleMargin(30); | ||
44 | +$graph->SetMarginColor('#EEEEEE'); | ||
45 | + | ||
46 | +// Setup titles and fonts | ||
47 | +$graph->title->Set("Frequence plot"); | ||
48 | +$graph->xaxis->title->Set("X-title"); | ||
49 | +$graph->yaxis->title->Set("Y-title"); | ||
50 | + | ||
51 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
52 | +$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
53 | +$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
54 | + | ||
55 | +// Turn the tickmarks | ||
56 | +$graph->xaxis->SetTickSide(SIDE_DOWN); | ||
57 | +$graph->yaxis->SetTickSide(SIDE_LEFT); | ||
58 | + | ||
59 | +$graph->y2axis->SetTickSide(SIDE_RIGHT); | ||
60 | +$graph->y2axis->SetColor('black','blue'); | ||
61 | +$graph->y2axis->SetLabelFormat('%3d.0%%'); | ||
62 | + | ||
63 | +// Create a bar pot | ||
64 | +$bplot = new BarPlot($data_freq); | ||
65 | + | ||
66 | +// Create targets and alt texts for the image maps. One for each bar | ||
67 | +// (In this example this is just "dummy" targets) | ||
68 | +$targ=array("#1","#2","#3","#4","#5","#6","#7"); | ||
69 | +$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d","val=%d"); | ||
70 | +$bplot->SetCSIMTargets($targ,$alts); | ||
71 | + | ||
72 | + | ||
73 | +// Create accumulative graph | ||
74 | +$lplot = new LinePlot($data_accfreq); | ||
75 | + | ||
76 | +// We want the line plot data point in the middle of the bars | ||
77 | +$lplot->SetBarCenter(); | ||
78 | + | ||
79 | +// Use transperancy | ||
80 | +$lplot->SetFillColor('lightblue@0.6'); | ||
81 | +$lplot->SetColor('blue@0.6'); | ||
82 | +//$lplot->SetColor('blue'); | ||
83 | +$graph->AddY2($lplot); | ||
84 | + | ||
85 | + | ||
86 | +// Setup the bars | ||
87 | +$bplot->SetFillColor("orange@0.2"); | ||
88 | +$bplot->SetValuePos('center'); | ||
89 | +$bplot->value->SetFormat("%d"); | ||
90 | +$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
91 | +$bplot->value->Show(); | ||
92 | + | ||
93 | +// Add it to the graph | ||
94 | +$graph->Add($bplot); | ||
95 | + | ||
96 | +// Send back the HTML page which will call this script again | ||
97 | +// to retrieve the image. | ||
98 | +$graph->StrokeCSIM(); | ||
99 | + | ||
100 | +?> |
@@ -0,0 +1,84 @@ | @@ -0,0 +1,84 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// | ||
3 | +// Example of frequence bar | ||
4 | +// | ||
5 | +require_once ('jpgraph/jpgraph.php'); | ||
6 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
7 | +require_once ('jpgraph/jpgraph_line.php'); | ||
8 | + | ||
9 | +// Utility function to calculate the accumulated frequence | ||
10 | +// for a set of values and ocurrences | ||
11 | +function accfreq($data) { | ||
12 | + rsort($data); | ||
13 | + $s = array_sum($data); | ||
14 | + $as = array($data[0]); | ||
15 | + $asp = array(100*$as[0]/$s); | ||
16 | + $n = count($data); | ||
17 | + for( $i=1; $i < $n; ++$i ) { | ||
18 | + $as[$i] = $as[$i-1]+$data[$i]; | ||
19 | + $asp[$i] = 100.0*$as[$i]/$s; | ||
20 | + } | ||
21 | + return $asp; | ||
22 | +} | ||
23 | + | ||
24 | +// some data | ||
25 | +$data_freq = array(22,20,12,10,5,4,2); | ||
26 | +$data_accfreq = accfreq($data_freq); | ||
27 | + | ||
28 | +// Create the graph. | ||
29 | +$graph = new Graph(350,250); | ||
30 | +$graph->clearTheme(); | ||
31 | + | ||
32 | +// Setup some basic graph parameters | ||
33 | +$graph->SetScale("textlin"); | ||
34 | +$graph->SetY2Scale('lin',0,100); | ||
35 | +$graph->img->SetMargin(50,70,30,40); | ||
36 | +$graph->yaxis->SetTitleMargin(30); | ||
37 | +$graph->SetMarginColor('#EEEEEE'); | ||
38 | + | ||
39 | +// Setup titles and fonts | ||
40 | +$graph->title->Set("Frequence plot"); | ||
41 | +$graph->xaxis->title->Set("X-title"); | ||
42 | +$graph->yaxis->title->Set("Y-title"); | ||
43 | + | ||
44 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
45 | +$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
46 | +$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); | ||
47 | + | ||
48 | +// Turn the tickmarks | ||
49 | +$graph->xaxis->SetTickSide(SIDE_DOWN); | ||
50 | +$graph->yaxis->SetTickSide(SIDE_LEFT); | ||
51 | + | ||
52 | +$graph->y2axis->SetTickSide(SIDE_RIGHT); | ||
53 | +$graph->y2axis->SetColor('black','blue'); | ||
54 | +$graph->y2axis->SetLabelFormat('%3d.0%%'); | ||
55 | + | ||
56 | +// Create a bar pot | ||
57 | +$bplot = new BarPlot($data_freq); | ||
58 | + | ||
59 | +// Create accumulative graph | ||
60 | +$lplot = new LinePlot($data_accfreq); | ||
61 | + | ||
62 | +// We want the line plot data point in the middle of the bars | ||
63 | +$lplot->SetBarCenter(); | ||
64 | + | ||
65 | +// Use transperancy | ||
66 | +$lplot->SetFillColor('lightblue@0.6'); | ||
67 | +$lplot->SetColor('blue@0.6'); | ||
68 | +$graph->AddY2($lplot); | ||
69 | + | ||
70 | +// Setup the bars | ||
71 | +$bplot->SetFillColor("orange@0.2"); | ||
72 | +$bplot->SetValuePos('center'); | ||
73 | +$bplot->value->SetFormat("%d"); | ||
74 | +$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9); | ||
75 | +$bplot->value->Show(); | ||
76 | + | ||
77 | +// Add it to the graph | ||
78 | +$graph->Add($bplot); | ||
79 | + | ||
80 | +// Send back the HTML page which will call this script again | ||
81 | +// to retrieve the image. | ||
82 | +$graph->Stroke(); | ||
83 | + | ||
84 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | + | ||
3 | +require_once ('jpgraph/jpgraph.php'); | ||
4 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
5 | +require_once ('jpgraph/jpgraph_line.php'); | ||
6 | + | ||
7 | +$datay=array(2,3,5,8.5,11.5,6,3); | ||
8 | + | ||
9 | +// Create the graph. | ||
10 | +$graph = new Graph(350,300); | ||
11 | +$graph->clearTheme(); | ||
12 | + | ||
13 | +$graph->SetScale("textlin"); | ||
14 | + | ||
15 | +$graph->SetMarginColor('navy:1.9'); | ||
16 | +$graph->SetBox(); | ||
17 | + | ||
18 | +$graph->title->Set('Bar Pattern'); | ||
19 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,20); | ||
20 | + | ||
21 | +$graph->SetTitleBackground('lightblue:1.3',TITLEBKG_STYLE2,TITLEBKG_FRAME_BEVEL); | ||
22 | +$graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'lightblue','blue'); | ||
23 | + | ||
24 | +// Create a bar pot | ||
25 | +$bplot = new BarPlot($datay); | ||
26 | +$bplot->SetFillColor('darkorange'); | ||
27 | +$bplot->SetWidth(0.6); | ||
28 | + | ||
29 | +$bplot->SetPattern(PATTERN_CROSS1,'navy'); | ||
30 | + | ||
31 | +$graph->Add($bplot); | ||
32 | + | ||
33 | +$graph->Stroke(); | ||
34 | +?> |
@@ -0,0 +1,64 @@ | @@ -0,0 +1,64 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +// Callback function for Y-scale to get 1000 separator on labels | ||
6 | +function separator1000($aVal) { | ||
7 | + return number_format($aVal); | ||
8 | +} | ||
9 | + | ||
10 | +function separator1000_usd($aVal) { | ||
11 | + return '$'.number_format($aVal); | ||
12 | +} | ||
13 | + | ||
14 | +// Some data | ||
15 | +$datay=array(120567,134013,192000,87000); | ||
16 | + | ||
17 | +// Create the graph and setup the basic parameters | ||
18 | +$graph = new Graph(500,300,'auto'); | ||
19 | +$graph->clearTheme(); | ||
20 | +$graph->img->SetMargin(80,30,30,40); | ||
21 | +$graph->SetScale('textint'); | ||
22 | +$graph->SetShadow(); | ||
23 | +$graph->SetFrame(false); // No border around the graph | ||
24 | + | ||
25 | +// Add some grace to the top so that the scale doesn't | ||
26 | +// end exactly at the max value. | ||
27 | +// The grace value is the percetage of additional scale | ||
28 | +// value we add. Specifying 50 means that we add 50% of the | ||
29 | +// max value | ||
30 | +$graph->yaxis->scale->SetGrace(50); | ||
31 | +$graph->yaxis->SetLabelFormatCallback('separator1000'); | ||
32 | + | ||
33 | +// Setup X-axis labels | ||
34 | +$a = $gDateLocale->GetShortMonth(); | ||
35 | +$graph->xaxis->SetTickLabels($a); | ||
36 | +$graph->xaxis->SetFont(FF_FONT2); | ||
37 | + | ||
38 | +// Setup graph title ands fonts | ||
39 | +$graph->title->Set('Example of Y-scale callback formatting'); | ||
40 | +$graph->title->SetFont(FF_FONT2,FS_BOLD); | ||
41 | +$graph->xaxis->title->Set('Year 2002'); | ||
42 | +$graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD); | ||
43 | + | ||
44 | +// Create a bar pot | ||
45 | +$bplot = new BarPlot($datay); | ||
46 | +$bplot->SetFillColor('orange'); | ||
47 | +$bplot->SetWidth(0.5); | ||
48 | +$bplot->SetShadow(); | ||
49 | + | ||
50 | +// Setup the values that are displayed on top of each bar | ||
51 | +$bplot->value->Show(); | ||
52 | + | ||
53 | +// Must use TTF fonts if we want text at an arbitrary angle | ||
54 | +$bplot->value->SetFont(FF_ARIAL,FS_BOLD); | ||
55 | +$bplot->value->SetAngle(45); | ||
56 | +$bplot->value->SetFormatCallback('separator1000_usd'); | ||
57 | + | ||
58 | +// Black color for positive values and darkred for negative values | ||
59 | +$bplot->value->SetColor('black','darkred'); | ||
60 | +$graph->Add($bplot); | ||
61 | + | ||
62 | +// Finally stroke the graph | ||
63 | +$graph->Stroke(); | ||
64 | +?> |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$databary=array(12,7,16,5,7,14,9,3); | ||
7 | + | ||
8 | +// New graph with a drop shadow | ||
9 | +$graph = new Graph(300,200); | ||
10 | +$graph->clearTheme(); | ||
11 | +$graph->SetShadow(); | ||
12 | + | ||
13 | +// Use a "text" X-scale | ||
14 | +$graph->SetScale("textlin"); | ||
15 | + | ||
16 | +// Set title and subtitle | ||
17 | +$graph->title->Set("Elementary barplot with a text scale"); | ||
18 | + | ||
19 | +// Use built in font | ||
20 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
21 | + | ||
22 | +// Create the bar plot | ||
23 | +$b1 = new BarPlot($databary); | ||
24 | +$b1->SetLegend("Temperature"); | ||
25 | +//$b1->SetAbsWidth(6); | ||
26 | +//$b1->SetShadow(); | ||
27 | + | ||
28 | +// The order the plots are added determines who's ontop | ||
29 | +$graph->Add($b1); | ||
30 | + | ||
31 | +// Finally output the image | ||
32 | +$graph->Stroke(); | ||
33 | + | ||
34 | +?> |
@@ -0,0 +1,89 @@ | @@ -0,0 +1,89 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// A medium complex example of JpGraph | ||
3 | +// Note: You can create a graph in far fewwr lines of code if you are | ||
4 | +// willing to go with the defaults. This is an illustrative example of | ||
5 | +// some of the capabilities of JpGraph. | ||
6 | + | ||
7 | +require_once ('jpgraph/jpgraph.php'); | ||
8 | +require_once ('jpgraph/jpgraph_line.php'); | ||
9 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
10 | + | ||
11 | +$month=array( | ||
12 | +"Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec"); | ||
13 | + | ||
14 | +// Create some datapoints | ||
15 | +$steps=100; | ||
16 | +for($i=0; $i<$steps; ++$i) { | ||
17 | + $databarx[]=sprintf("198%d %s",floor($i/12),$month[$i%12]); | ||
18 | + $datay[$i]=log(pow($i,$i/10)+1)*sin($i/15)+35; | ||
19 | + if( $i % 6 == 0 && $i<$steps-6) { | ||
20 | + $databary[]=abs(25*sin($i)+5); | ||
21 | + } | ||
22 | + else { | ||
23 | + $databary[]=0; | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +// New graph with a background image and drop shadow | ||
28 | +$graph = new Graph(450,300); | ||
29 | +$graph->clearTheme(); | ||
30 | +$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME); | ||
31 | +$graph->SetShadow(); | ||
32 | + | ||
33 | +// Use text X-scale so we can text labels on the X-axis | ||
34 | +$graph->SetScale("textlin"); | ||
35 | + | ||
36 | +// Y2-axis is linear | ||
37 | +$graph->SetY2Scale("lin"); | ||
38 | + | ||
39 | +// Color the two Y-axis to make them easier to associate | ||
40 | +// to the corresponding plot (we keep the axis black though) | ||
41 | +$graph->yaxis->SetColor("black","red"); | ||
42 | +$graph->y2axis->SetColor("black","orange"); | ||
43 | + | ||
44 | +// Set title and subtitle | ||
45 | +$graph->title->Set("Combined bar and line plot"); | ||
46 | +$graph->subtitle->Set("100 data points, X-Scale: 'text'"); | ||
47 | + | ||
48 | +// Use built in font (don't need TTF support) | ||
49 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
50 | + | ||
51 | +// Make the margin around the plot a little bit bigger then default | ||
52 | +$graph->img->SetMargin(40,140,40,80); | ||
53 | + | ||
54 | +// Slightly adjust the legend from it's default position in the | ||
55 | +// top right corner to middle right side | ||
56 | +$graph->legend->Pos(0.03,0.5,"right","center"); | ||
57 | + | ||
58 | +// Display every 6:th tickmark | ||
59 | +$graph->xaxis->SetTextTickInterval(6); | ||
60 | + | ||
61 | +// Label every 2:nd tick mark | ||
62 | +$graph->xaxis->SetTextLabelInterval(2); | ||
63 | + | ||
64 | +// Setup the labels | ||
65 | +$graph->xaxis->SetTickLabels($databarx); | ||
66 | +$graph->xaxis->SetLabelAngle(90); | ||
67 | + | ||
68 | +// Create a red line plot | ||
69 | +$p1 = new LinePlot($datay); | ||
70 | +$p1->SetColor("red"); | ||
71 | +$p1->SetLegend("Pressure"); | ||
72 | + | ||
73 | +// Create the bar plot | ||
74 | +$b1 = new BarPlot($databary); | ||
75 | +$b1->SetLegend("Temperature"); | ||
76 | +$b1->SetFillColor("orange"); | ||
77 | +$b1->SetAbsWidth(8); | ||
78 | + | ||
79 | +// Drop shadow on bars adjust the default values a little bit | ||
80 | +$b1->SetShadow("steelblue",2,2); | ||
81 | + | ||
82 | +// The order the plots are added determines who's ontop | ||
83 | +$graph->Add($p1); | ||
84 | +$graph->AddY2($b1); | ||
85 | + | ||
86 | +// Finally output the image | ||
87 | +$graph->Stroke(); | ||
88 | + | ||
89 | +?> |
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$databary=array(12,7,16,6,7,14,9,3); | ||
7 | +$months=$gDateLocale->GetShortMonth(); | ||
8 | + | ||
9 | +// New graph with a drop shadow | ||
10 | +$graph = new Graph(300,200,'auto'); | ||
11 | +$graph->clearTheme(); | ||
12 | +$graph->SetShadow(); | ||
13 | + | ||
14 | +// Use a "text" X-scale | ||
15 | +$graph->SetScale("textlin"); | ||
16 | + | ||
17 | +// Specify X-labels | ||
18 | +$graph->xaxis->SetTickLabels($months); | ||
19 | + | ||
20 | +// Set title and subtitle | ||
21 | +$graph->title->Set("Textscale with specified labels"); | ||
22 | + | ||
23 | +// Use built in font | ||
24 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
25 | + | ||
26 | +// Create the bar plot | ||
27 | +$b1 = new BarPlot($databary); | ||
28 | +$b1->SetLegend("Temperature"); | ||
29 | + | ||
30 | +//$b1->SetAbsWidth(6); | ||
31 | +//$b1->SetShadow(); | ||
32 | + | ||
33 | +// The order the plots are added determines who's ontop | ||
34 | +$graph->Add($b1); | ||
35 | + | ||
36 | +// Finally output the image | ||
37 | +$graph->Stroke(); | ||
38 | + | ||
39 | +?> |
@@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$months=$gDateLocale->GetShortMonth(); | ||
7 | + | ||
8 | +srand ((double) microtime() * 1000000); | ||
9 | +for( $i=0; $i<25; ++$i) { | ||
10 | + $databary[]=rand(1,50); | ||
11 | + $databarx[]=$months[$i%12]; | ||
12 | +} | ||
13 | + | ||
14 | +// New graph with a drop shadow | ||
15 | +$graph = new Graph(300,200,'auto'); | ||
16 | +$graph->clearTheme(); | ||
17 | +$graph->SetShadow(); | ||
18 | + | ||
19 | +// Use a "text" X-scale | ||
20 | +$graph->SetScale("textlin"); | ||
21 | + | ||
22 | +// Specify X-labels | ||
23 | +$graph->xaxis->SetTickLabels($databarx); | ||
24 | + | ||
25 | +// Set title and subtitle | ||
26 | +$graph->title->Set("Bar tutorial example 3"); | ||
27 | + | ||
28 | +// Use built in font | ||
29 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
30 | + | ||
31 | +// Create the bar plot | ||
32 | +$b1 = new BarPlot($databary); | ||
33 | +$b1->SetLegend("Temperature"); | ||
34 | +//$b1->SetAbsWidth(6); | ||
35 | +//$b1->SetShadow(); | ||
36 | + | ||
37 | +// The order the plots are added determines who's ontop | ||
38 | +$graph->Add($b1); | ||
39 | + | ||
40 | +// Finally output the image | ||
41 | +$graph->Stroke(); | ||
42 | + | ||
43 | +?> |
@@ -0,0 +1,46 @@ | @@ -0,0 +1,46 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$months=$gDateLocale->GetShortMonth(); | ||
7 | + | ||
8 | +srand ((double) microtime() * 1000000); | ||
9 | +for( $i=0; $i<25; ++$i) { | ||
10 | + $databary[]=rand(1,50); | ||
11 | + $databarx[]=$months[$i%12]; | ||
12 | +} | ||
13 | + | ||
14 | +// New graph with a drop shadow | ||
15 | +$graph = new Graph(300,200,'auto'); | ||
16 | +$graph->clearTheme(); | ||
17 | +$graph->SetShadow(); | ||
18 | + | ||
19 | +// Use a "text" X-scale | ||
20 | +$graph->SetScale("textlin"); | ||
21 | + | ||
22 | +// Specify X-labels | ||
23 | +//$databarx = array('tXi','','','xxx','','','iXii','','','OOO','','','tOO'); | ||
24 | +$graph->xaxis->SetFont(FF_FONT1,FS_NORMAL); | ||
25 | +$graph->xaxis->SetTickLabels($databarx); | ||
26 | +$graph->xaxis->SetTextLabelInterval(3); | ||
27 | + | ||
28 | +// Set title and subtitle | ||
29 | +$graph->title->Set("Displaying only every third label"); | ||
30 | + | ||
31 | +// Use built in font | ||
32 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
33 | + | ||
34 | +// Create the bar plot | ||
35 | +$b1 = new BarPlot($databary); | ||
36 | +$b1->SetLegend("Temperature"); | ||
37 | +//$b1->SetAbsWidth(6); | ||
38 | +//$b1->SetShadow(); | ||
39 | + | ||
40 | +// The order the plots are added determines who's ontop | ||
41 | +$graph->Add($b1); | ||
42 | + | ||
43 | +// Finally output the image | ||
44 | +$graph->Stroke(); | ||
45 | + | ||
46 | +?> |
@@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$months=$gDateLocale->GetShortMonth(); | ||
7 | + | ||
8 | +srand ((double) microtime() * 1000000); | ||
9 | +for( $i=0; $i<25; ++$i) { | ||
10 | + $databary[]=rand(1,50); | ||
11 | + $databarx[]=$months[$i%12]; | ||
12 | +} | ||
13 | + | ||
14 | +// New graph with a drop shadow | ||
15 | +$graph = new Graph(300,200,'auto'); | ||
16 | +$graph->clearTheme(); | ||
17 | +$graph->SetShadow(); | ||
18 | + | ||
19 | +// Use a "text" X-scale | ||
20 | +$graph->SetScale("textlin"); | ||
21 | + | ||
22 | +// Specify X-labels | ||
23 | +$graph->xaxis->SetTickLabels($databarx); | ||
24 | +$graph->xaxis->SetTextLabelInterval(1); | ||
25 | +$graph->xaxis->SetTextTickInterval(3); | ||
26 | + | ||
27 | +// Set title and subtitle | ||
28 | +$graph->title->Set("Bar tutorial example 5"); | ||
29 | + | ||
30 | +// Use built in font | ||
31 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
32 | + | ||
33 | +// Create the bar plot | ||
34 | +$b1 = new BarPlot($databary); | ||
35 | +$b1->SetLegend("Temperature"); | ||
36 | +$b1->SetWidth(0.4); | ||
37 | + | ||
38 | +// The order the plots are added determines who's ontop | ||
39 | +$graph->Add($b1); | ||
40 | + | ||
41 | +// Finally output the image | ||
42 | +$graph->Stroke(); | ||
43 | + | ||
44 | +?> |
@@ -0,0 +1,46 @@ | @@ -0,0 +1,46 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +require_once ('jpgraph/jpgraph.php'); | ||
3 | +require_once ('jpgraph/jpgraph_bar.php'); | ||
4 | + | ||
5 | +// Some data | ||
6 | +$months=$gDateLocale->GetShortMonth(); | ||
7 | +srand ((double) microtime() * 1000000); | ||
8 | +for( $i=0; $i<25; ++$i) { | ||
9 | + $databary[]=rand(1,50); | ||
10 | + $databarx[]=$months[$i%12]; | ||
11 | +} | ||
12 | + | ||
13 | +// New graph with a drop shadow | ||
14 | +$graph = new Graph(300,200,'auto'); | ||
15 | +$graph->clearTheme(); | ||
16 | +$graph->SetShadow(); | ||
17 | + | ||
18 | +// Use a "text" X-scale | ||
19 | +$graph->SetScale("textlin"); | ||
20 | + | ||
21 | +// Specify X-labels | ||
22 | +$graph->xaxis->SetTickLabels($databarx); | ||
23 | +$graph->xaxis->SetTextLabelInterval(3); | ||
24 | + | ||
25 | +// Hide the tick marks | ||
26 | +$graph->xaxis->HideTicks(); | ||
27 | + | ||
28 | +// Set title and subtitle | ||
29 | +$graph->title->Set("Bar tutorial example 6"); | ||
30 | + | ||
31 | +// Use built in font | ||
32 | +$graph->title->SetFont(FF_FONT1,FS_BOLD); | ||
33 | + | ||
34 | +// Create the bar plot | ||
35 | +$b1 = new BarPlot($databary); | ||
36 | +$b1->SetLegend("Temperature"); | ||
37 | +$b1->SetWidth(0.4); | ||
38 | + | ||
39 | + | ||
40 | +// The order the plots are added determines who's ontop | ||
41 | +$graph->Add($b1); | ||
42 | + | ||
43 | +// Finally output the image | ||
44 | +$graph->Stroke(); | ||
45 | + | ||
46 | +?> |
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Basic contour plot example | ||
3 | + | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_contour.php'); | ||
6 | + | ||
7 | +$data = array( | ||
8 | + array (0.5,1.1,1.5,1,2.0,3,3,2,1,0.1), | ||
9 | + array (1.0,1.5,3.0,5,6.0,2,1,1.2,1,4), | ||
10 | + array (0.9,2.0,2.1,3,6.0,7,3,2,1,1.4), | ||
11 | + array (1.0,1.5,3.0,4,6.0,5,2,1.5,1,2), | ||
12 | + array (0.8,2.0,3.0,3,4.0,4,3,2.4,2,3), | ||
13 | + array (0.6,1.1,1.5,1,4.0,3.5,3,2,3,4), | ||
14 | + array (1.0,1.5,3.0,5,6.0,2,1,1.2,2.7,4), | ||
15 | + array (0.8,2.0,3.0,3,5.5,6,3,2,1,1.4), | ||
16 | + array (1.0,1.5,3.0,4,6.0,5,2,1,0.5,0.2)); | ||
17 | + | ||
18 | +// Basic contour graph | ||
19 | +$graph = new Graph(350,250); | ||
20 | +$graph->SetScale('intint'); | ||
21 | + | ||
22 | +// Adjust the margins to fit the margin | ||
23 | +$graph->SetMargin(30,100,40,30); | ||
24 | + | ||
25 | +// Setup | ||
26 | +$graph->title->Set('Basic contour plot'); | ||
27 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
28 | + | ||
29 | +// A simple contour plot with default arguments (e.g. 10 isobar lines) | ||
30 | +$cp = new ContourPlot($data); | ||
31 | + | ||
32 | +// Display the legend | ||
33 | +$cp->ShowLegend(); | ||
34 | + | ||
35 | +$graph->Add($cp); | ||
36 | + | ||
37 | +// ... and send the graph back to the browser | ||
38 | +$graph->Stroke(); | ||
39 | + | ||
40 | +?> |
@@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Basic contour plot example | ||
3 | + | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_contour.php'); | ||
6 | + | ||
7 | +$data = array( | ||
8 | + array (0.5,1.1,1.5,1,2.0,3,3,2,1,0.1), | ||
9 | + array (1.0,1.5,3.0,5,6.0,2,1,1.2,1,4), | ||
10 | + array (0.9,2.0,2.1,3,6.0,7,3,2,1,1.4), | ||
11 | + array (1.0,1.5,3.0,4,6.0,5,2,1.5,1,2), | ||
12 | + array (0.8,2.0,3.0,3,4.0,4,3,2.4,2,3), | ||
13 | + array (0.6,1.1,1.5,1,4.0,3.5,3,2,3,4), | ||
14 | + array (1.0,1.5,3.0,5,6.0,2,1,1.2,2.7,4), | ||
15 | + array (0.8,2.0,3.0,3,5.5,6,3,2,1,1.4), | ||
16 | + array (1.0,1.5,3.0,4,6.0,5,2,1,0.5,0.2)); | ||
17 | + | ||
18 | +// Basic contour graph | ||
19 | +$graph = new Graph(350,250); | ||
20 | +$graph->SetScale('intint'); | ||
21 | + | ||
22 | +// Show axis on all sides | ||
23 | +$graph->SetAxisStyle(AXSTYLE_BOXOUT); | ||
24 | + | ||
25 | +// Adjust the margins to fit the margin | ||
26 | +$graph->SetMargin(30,100,40,30); | ||
27 | + | ||
28 | +// Setup | ||
29 | +$graph->title->Set('Basic contour plot with multiple axis'); | ||
30 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
31 | + | ||
32 | +// A simple contour plot with default arguments (e.g. 10 isobar lines) | ||
33 | +$cp = new ContourPlot($data); | ||
34 | + | ||
35 | +// Display the legend | ||
36 | +$cp->ShowLegend(); | ||
37 | + | ||
38 | +$graph->Add($cp); | ||
39 | + | ||
40 | +// ... and send the graph back to the browser | ||
41 | +$graph->Stroke(); | ||
42 | + | ||
43 | +?> |
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Basic contour plot example | ||
3 | + | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_contour.php'); | ||
6 | + | ||
7 | +$data = array( | ||
8 | + array ( 12,7,3,15 ), | ||
9 | + array ( 18,5,1, 9 ), | ||
10 | + array ( 13,9,5,12), | ||
11 | + array ( 5,3,8, 9 ), | ||
12 | + array ( 1,8,5, 7 )); | ||
13 | + | ||
14 | + | ||
15 | +// Basic contour graph | ||
16 | +$graph = new Graph(350,250); | ||
17 | +$graph->SetScale('intint'); | ||
18 | + | ||
19 | +// Show axis on all sides | ||
20 | +$graph->SetAxisStyle(AXSTYLE_BOXOUT); | ||
21 | + | ||
22 | +// Adjust the margins to fit the margin | ||
23 | +$graph->SetMargin(30,100,40,30); | ||
24 | + | ||
25 | +// Setup | ||
26 | +$graph->title->Set('Basic contour plot with multiple axis'); | ||
27 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
28 | + | ||
29 | +// A simple contour plot with default arguments (e.g. 10 isobar lines) | ||
30 | +$cp = new ContourPlot($data,10,1); | ||
31 | + | ||
32 | +// Display the legend | ||
33 | +$cp->ShowLegend(); | ||
34 | + | ||
35 | +$graph->Add($cp); | ||
36 | + | ||
37 | +// ... and send the graph back to the browser | ||
38 | +$graph->Stroke(); | ||
39 | + | ||
40 | +?> |
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Basic contour plot example | ||
3 | + | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_contour.php'); | ||
6 | + | ||
7 | +$data = array( | ||
8 | + array ( 12,7,3,15 ), | ||
9 | + array ( 18,5,1, 9 ), | ||
10 | + array ( 13,9,5,12), | ||
11 | + array ( 5,3,8, 9 ), | ||
12 | + array ( 1,8,5, 7 )); | ||
13 | + | ||
14 | + | ||
15 | +// Basic contour graph | ||
16 | +$graph = new Graph(350,250); | ||
17 | +$graph->SetScale('intint'); | ||
18 | + | ||
19 | +// Show axis on all sides | ||
20 | +$graph->SetAxisStyle(AXSTYLE_BOXOUT); | ||
21 | + | ||
22 | +// Adjust the margins to fit the margin | ||
23 | +$graph->SetMargin(30,100,40,30); | ||
24 | + | ||
25 | +// Setup | ||
26 | +$graph->title->Set('Basic contour plot with multiple axis'); | ||
27 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
28 | + | ||
29 | +// A simple contour plot with default arguments (e.g. 10 isobar lines) | ||
30 | +$cp = new ContourPlot($data,10,2); | ||
31 | + | ||
32 | +// Display the legend | ||
33 | +$cp->ShowLegend(); | ||
34 | + | ||
35 | +$graph->Add($cp); | ||
36 | + | ||
37 | +// ... and send the graph back to the browser | ||
38 | +$graph->Stroke(); | ||
39 | + | ||
40 | +?> |
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Basic contour plot example | ||
3 | + | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_contour.php'); | ||
6 | + | ||
7 | +$data = array( | ||
8 | + array ( 12,7,3,15 ), | ||
9 | + array ( 18,5,1, 9 ), | ||
10 | + array ( 13,9,5,12), | ||
11 | + array ( 5,3,8, 9 ), | ||
12 | + array ( 1,8,5, 7 )); | ||
13 | + | ||
14 | + | ||
15 | +// Basic contour graph | ||
16 | +$graph = new Graph(350,250); | ||
17 | +$graph->SetScale('intint'); | ||
18 | + | ||
19 | +// Show axis on all sides | ||
20 | +$graph->SetAxisStyle(AXSTYLE_BOXOUT); | ||
21 | + | ||
22 | +// Adjust the margins to fit the margin | ||
23 | +$graph->SetMargin(30,100,40,30); | ||
24 | + | ||
25 | +// Setup | ||
26 | +$graph->title->Set('Basic contour plot with multiple axis'); | ||
27 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
28 | + | ||
29 | +// A simple contour plot with default arguments (e.g. 10 isobar lines) | ||
30 | +$cp = new ContourPlot($data,10,3); | ||
31 | + | ||
32 | +// Display the legend | ||
33 | +$cp->ShowLegend(); | ||
34 | + | ||
35 | +$graph->Add($cp); | ||
36 | + | ||
37 | +// ... and send the graph back to the browser | ||
38 | +$graph->Stroke(); | ||
39 | + | ||
40 | +?> |
@@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
1 | +<?php // content="text/plain; charset=utf-8" | ||
2 | +// Basic contour plot example | ||
3 | + | ||
4 | +require_once ('jpgraph/jpgraph.php'); | ||
5 | +require_once ('jpgraph/jpgraph_contour.php'); | ||
6 | + | ||
7 | +$data = array( | ||
8 | + array (0.5,1.1,1.5,1,2.0,3,3,2,1,0.1), | ||
9 | + array (1.0,1.5,3.0,5,6.0,2,1,1.2,1,4), | ||
10 | + array (0.9,2.0,2.1,3,6.0,7,3,2,1,1.4), | ||
11 | + array (1.0,1.5,3.0,4,6.0,5,2,1.5,1,2), | ||
12 | + array (0.8,2.0,3.0,3,4.0,4,3,2.4,2,3), | ||
13 | + array (0.6,1.1,1.5,1,4.0,3.5,3,2,3,4), | ||
14 | + array (1.0,1.5,3.0,5,6.0,2,1,1.2,2.7,4), | ||
15 | + array (0.8,2.0,3.0,3,5.5,6,3,2,1,1.4), | ||
16 | + array (1.0,1.5,3.0,4,6.0,5,2,1,0.5,0.2)); | ||
17 | + | ||
18 | +// Basic contour graph | ||
19 | +$graph = new Graph(350,250); | ||
20 | +$graph->SetScale('intint'); | ||
21 | + | ||
22 | +// Show axis on all sides | ||
23 | +$graph->SetAxisStyle(AXSTYLE_BOXOUT); | ||
24 | + | ||
25 | +// Adjust the margins to fit the margin | ||
26 | +$graph->SetMargin(30,100,40,30); | ||
27 | + | ||
28 | +// Setup | ||
29 | +$graph->title->Set('Basic contour plot with multiple axis'); | ||
30 | +$graph->title->SetFont(FF_ARIAL,FS_BOLD,12); | ||
31 | + | ||
32 | +// A simple contour plot with default arguments (e.g. 10 isobar lines) | ||
33 | +$cp = new ContourPlot($data,5); | ||
34 | + | ||
35 | +// Display the legend | ||
36 | +$cp->ShowLegend(); | ||
37 | + | ||
38 | +$graph->Add($cp); | ||
39 | + | ||
40 | +// ... and send the graph back to the browser | ||
41 | +$graph->Stroke(); | ||
42 | + | ||
43 | +?> |