Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JPGraph Subform and Legend Issues

Status
Not open for further replies.

PCHomepage

Programmer
Feb 24, 2009
609
US
I have a JPGraph line plot inside a function and have showed below only the portions in question. The plot is working in pulling up multiple columns of data but I can't seem to get the legend to show properly, especially as there is also a sub form to selest what to graph. By default, all four columns are graphed, then there are checkboxes to pick more specifics. As it is, it shows all properly or I can pick only one at a time without a JPGraph crash (any two or more crashes it) but the main problem is in the legend, which has to get a title from a database table, shows all the titles for each column and it's obvious why but I'm not sure what to do about it! It's also showing all the same title so if two are being graphed, and there are four columns of data, I see the same file name eight times and it does not show the mark type.

I would also like it to show the column name at the peak of each graph.

Can anyone help?

Code:
if ($result = $mysqli->query("$Query")) :
	while ($row = $result->fetch_array()) :
		$datax[$row[0]][] = $row[1];
		$datay1[$row[0]][] = $row[2];
		$datay2[$row[0]][] = $row[3];
		$datay3[$row[0]][] = $row[4];
		$datay4[$row[0]][] = $row[5];
	endwhile;
	$result->close();
else:
	echo "<div class=\"Message\">\n";
	printf("MySQLi Error: %s\n", $mysqli->error);
	echo "</div>\n\n";
endif;

foreach($datay1 as $key=>$_datay): // for Legend
	$queryFN = "SELECT FileName FROM dcs_uploads ";
	$queryFN .= "WHERE ID = ".$key." ";
	$queryFN .= "ORDER by FileName";
	if ($result = $mysqli->query($queryFN)):
		$row = $result->fetch_row();
		$FileName = $row[0];
	endif;
endforeach;

if (!$SubData || $SubData == 'Red'):
	foreach($datay1 as $key=>$_datay): // for Red
		$lp[$key] = new LinePlot($_datay,$datax[$key]);
		$graph->Add($lp[$key]);
		$lp[$key]->mark->SetType(MARK_DIAMOND, 'red', 0.3);				
		$lp[$key] = new LinePlot($_datay,$datax[$key]);
		$graph->Add($lp[$key]);
		$lp[$key]->SetLegend(basename($FileName, ".csv"));
	endforeach;
endif;

if (!$SubData || $SubData == 'Gr'):
	foreach($datay2 as $key=>$_datay): // for Gr
		$lp[$key] = new LinePlot($_datay,$datax[$key]);
		$graph->Add($lp[$key]);
		$lp[$key]->mark->SetType(MARK_UTRIANGLE, 'green', 0.3);	
		$lp[$key] = new LinePlot($_datay,$datax[$key]);
		$graph->Add($lp[$key]);
		$lp[$key]->SetLegend(basename($FileName, ".csv"));
	endforeach;
endif;

if (!$SubData || $SubData == 'Gb'):
	foreach($datay3 as $key=>$_datay): // for Gb
		$lp[$key] = new LinePlot($_datay,$datax[$key]);
		$graph->Add($lp[$key]);
		$lp[$key]->mark->SetType(MARK_DTRIANGLE, 'teal', 0.3);	
		$lp[$key] = new LinePlot($_datay,$datax[$key]);
		$graph->Add($lp[$key]);
		$lp[$key]->SetLegend(basename($FileName, ".csv"));
	endforeach;
endif;

if (!$SubData || $SubData == 'B'):
	foreach($datay4 as $key=>$_datay): // for B
		$lp[$key] = new LinePlot($_datay,$datax[$key]);
		$graph->Add($lp[$key]);
		$lp[$key]->mark->SetType(MARK_SQUARE, 'blue', 0.3);	
		$lp[$key] = new LinePlot($_datay,$datax[$key]);
		$graph->Add($lp[$key]);
		$lp[$key]->SetLegend(basename($FileName, ".csv"));
	endforeach;
endif;
 
Thank you! This will be long but here goes!

Code:
Array
(
    [datax] => Array
        (
            [46] => Array
                (
                    [0] => 390
                    [1] => 400
                    [2] => 410
                    [3] => 420
                    [4] => 430
                    [5] => 440
                    [6] => 450
                    [7] => 459.9
                    [8] => 469.9
                    [9] => 479.9
                    [10] => 489.9
                    [11] => 499.9
                    [12] => 509.8
                    [13] => 519.7
                    [14] => 529.7
                    [15] => 539.7
                    [16] => 549.7
                    [17] => 559.7
                    [18] => 569.6
                    [19] => 579.6
                    [20] => 589.6
                    [21] => 599.5
                    [22] => 609.5
                    [23] => 619.5
                    [24] => 629.5
                    [25] => 639.5
                    [26] => 649.6
                    [27] => 659.6
                    [28] => 669.6
                    [29] => 679.6
                    [30] => 689.6
                    [31] => 699.5
                    [32] => 709.6
                    [33] => 719.6
                    [34] => 729.6
                    [35] => 739.6
                    [36] => 749.6
                    [37] => 759.6
                    [38] => 769.6
                    [39] => 779.6
                    [40] => 789.6
                    [41] => 799.6
                    [42] => 809.6
                    [43] => 819.6
                    [44] => 829.6
                    [45] => 839.6
                    [46] => 849.6
                    [47] => 859.6
                    [48] => 869.6
                    [49] => 879.6
                    [50] => 889.6
                    [51] => 899.6
                    [52] => 909.6
                    [53] => 919.6
                    [54] => 929.6
                    [55] => 939.6
                    [56] => 949.6
                    [57] => 959.6
                    [58] => 969.6
                    [59] => 979.6
                    [60] => 989.6
                    [61] => 999.6
                    [62] => 1009.6
                    [63] => 1019.6
                    [64] => 1029.6
                    [65] => 1039.6
                    [66] => 1049.6
                    [67] => 1059.6
                    [68] => 1069.6
                    [69] => 1079.7
                    [70] => 1089.7
                    [71] => 1099.7
                )

            [53] => Array
                (
                    [0] => 390
                    [1] => 390
                    [2] => 400
                    [3] => 400
                    [4] => 410
                    [5] => 410
                    [6] => 420
                    [7] => 420
                    [8] => 430
                    [9] => 430
                    [10] => 440
                    [11] => 440
                    [12] => 450
                    [13] => 450
                    [14] => 459.9
                    [15] => 459.9
                    [16] => 469.9
                    [17] => 469.9
                    [18] => 479.9
                    [19] => 479.9
                    [20] => 489.9
                    [21] => 489.9
                    [22] => 499.9
                    [23] => 499.9
                    [24] => 509.8
                    [25] => 509.8
                    [26] => 519.7
                    [27] => 519.7
                    [28] => 529.7
                    [29] => 529.7
                    [30] => 539.7
                    [31] => 539.7
                    [32] => 549.7
                    [33] => 549.7
                    [34] => 559.7
                    [35] => 559.7
                    [36] => 569.6
                    [37] => 569.6
                    [38] => 579.6
                    [39] => 579.6
                    [40] => 589.6
                    [41] => 589.6
                    [42] => 599.5
                    [43] => 599.5
                    [44] => 609.5
                    [45] => 609.5
                    [46] => 619.5
                    [47] => 619.5
                    [48] => 629.5
                    [49] => 629.5
                    [50] => 639.5
                    [51] => 639.5
                    [52] => 649.6
                    [53] => 649.6
                    [54] => 659.6
                    [55] => 659.6
                    [56] => 669.6
                    [57] => 669.6
                    [58] => 679.6
                    [59] => 679.6
                    [60] => 689.6
                    [61] => 689.6
                    [62] => 699.5
                    [63] => 699.5
                    [64] => 709.6
                    [65] => 709.6
                    [66] => 719.6
                    [67] => 719.6
                    [68] => 729.6
                    [69] => 729.6
                    [70] => 739.6
                    [71] => 739.6
                    [72] => 749.6
                    [73] => 749.6
                    [74] => 759.6
                    [75] => 759.6
                    [76] => 769.6
                    [77] => 769.6
                    [78] => 779.6
                    [79] => 779.6
                    [80] => 789.6
                    [81] => 789.6
                    [82] => 799.6
                    [83] => 799.6
                    [84] => 809.6
                    [85] => 809.6
                    [86] => 819.6
                    [87] => 819.6
                    [88] => 829.6
                    [89] => 829.6
                    [90] => 839.6
                    [91] => 839.6
                    [92] => 849.6
                    [93] => 849.6
                    [94] => 859.6
                    [95] => 859.6
                    [96] => 869.6
                    [97] => 869.6
                    [98] => 879.6
                    [99] => 879.6
                    [100] => 889.6
                    [101] => 889.6
                    [102] => 899.6
                    [103] => 899.6
                    [104] => 909.6
                    [105] => 909.6
                    [106] => 919.6
                    [107] => 919.6
                    [108] => 929.6
                    [109] => 929.6
                    [110] => 939.6
                    [111] => 939.6
                    [112] => 949.6
                    [113] => 949.6
                    [114] => 959.6
                    [115] => 959.6
                    [116] => 969.6
                    [117] => 969.6
                    [118] => 979.6
                    [119] => 979.6
                    [120] => 989.6
                    [121] => 989.6
                    [122] => 999.6
                    [123] => 999.6
                    [124] => 1009.6
                    [125] => 1009.6
                    [126] => 1019.6
                    [127] => 1019.6
                    [128] => 1029.6
                    [129] => 1029.6
                    [130] => 1039.6
                    [131] => 1039.6
                    [132] => 1049.6
                    [133] => 1049.6
                    [134] => 1059.6
                    [135] => 1059.6
                    [136] => 1069.6
                    [137] => 1069.6
                    [138] => 1079.7
                    [139] => 1079.7
                    [140] => 1089.7
                    [141] => 1089.7
                    [142] => 1099.7
                    [143] => 1099.7
                )

        )

    [datay1] => Array
        (
            [46] => Array
                (
                    [0] => 8.48
                    [1] => 6.6
                    [2] => 4.93
                    [3] => 3.75
                    [4] => 2.89
                    [5] => 2.29
                    [6] => 1.89
                    [7] => 1.72
                    [8] => 1.81
                    [9] => 1.96
                    [10] => 1.97
                    [11] => 2.18
                    [12] => 2.85
                    [13] => 3.99
                    [14] => 4.55
                    [15] => 3.79
                    [16] => 3.02
                    [17] => 2.92
                    [18] => 5.52
                    [19] => 21.73
                    [20] => 43.69
                    [21] => 50.54
                    [22] => 48.8
                    [23] => 46.03
                    [24] => 44.25
                    [25] => 42.9
                    [26] => 41.09
                    [27] => 38.77
                    [28] => 35.74
                    [29] => 32.16
                    [30] => 29.43
                    [31] => 28.15
                    [32] => 28.23
                    [33] => 28.57
                    [34] => 27.93
                    [35] => 26.74
                    [36] => 25.3
                    [37] => 23.81
                    [38] => 22.33
                    [39] => 20.63
                    [40] => 19.31
                    [41] => 18.33
                    [42] => 17.14
                    [43] => 15.89
                    [44] => 14.74
                    [45] => 13.45
                    [46] => 12.13
                    [47] => 11
                    [48] => 10.13
                    [49] => 9.29
                    [50] => 8.33
                    [51] => 7.49
                    [52] => 6.72
                    [53] => 5.9
                    [54] => 5.12
                    [55] => 4.48
                    [56] => 4
                    [57] => 3.52
                    [58] => 2.98
                    [59] => 2.51
                    [60] => 2.12
                    [61] => 1.76
                    [62] => 1.45
                    [63] => 1.15
                    [64] => 0.9
                    [65] => 0.69
                    [66] => 0.52
                    [67] => 0.38
                    [68] => 0.28
                    [69] => 0.21
                    [70] => 0.16
                    [71] => 0.12
                )

            [53] => Array
                (
                    [0] => 7.38
                    [1] => 7.38
                    [2] => 5.86
                    [3] => 5.86
                    [4] => 4.44
                    [5] => 4.44
                    [6] => 3.4
                    [7] => 3.4
                    [8] => 2.7
                    [9] => 2.7
                    [10] => 2.12
                    [11] => 2.12
                    [12] => 1.76
                    [13] => 1.76
                    [14] => 1.57
                    [15] => 1.57
                    [16] => 1.69
                    [17] => 1.69
                    [18] => 1.82
                    [19] => 1.82
                    [20] => 1.83
                    [21] => 1.83
                    [22] => 2.07
                    [23] => 2.07
                    [24] => 2.8
                    [25] => 2.8
                    [26] => 4.02
                    [27] => 4.02
                    [28] => 4.6
                    [29] => 4.6
                    [30] => 3.82
                    [31] => 3.82
                    [32] => 2.95
                    [33] => 2.95
                    [34] => 2.77
                    [35] => 2.77
                    [36] => 5.36
                    [37] => 5.36
                    [38] => 21.41
                    [39] => 21.41
                    [40] => 42.22
                    [41] => 42.22
                    [42] => 48.34
                    [43] => 48.34
                    [44] => 48.3
                    [45] => 48.3
                    [46] => 47.27
                    [47] => 47.27
                    [48] => 45.38
                    [49] => 45.38
                    [50] => 43.37
                    [51] => 43.37
                    [52] => 41.64
                    [53] => 41.64
                    [54] => 39.45
                    [55] => 39.45
                    [56] => 36.38
                    [57] => 36.38
                    [58] => 32.72
                    [59] => 32.72
                    [60] => 30.26
                    [61] => 30.26
                    [62] => 29.54
                    [63] => 29.54
                    [64] => 29.51
                    [65] => 29.51
                    [66] => 28.96
                    [67] => 28.96
                    [68] => 27.88
                    [69] => 27.88
                    [70] => 26.83
                    [71] => 26.83
                    [72] => 25.91
                    [73] => 25.91
                    [74] => 24.7
                    [75] => 24.7
                    [76] => 23.11
                    [77] => 23.11
                    [78] => 21.42
                    [79] => 21.42
                    [80] => 19.77
                    [81] => 19.77
                    [82] => 18.56
                    [83] => 18.56
                    [84] => 17.57
                    [85] => 17.57
                    [86] => 16.41
                    [87] => 16.41
                    [88] => 15.19
                    [89] => 15.19
                    [90] => 13.93
                    [91] => 13.93
                    [92] => 12.57
                    [93] => 12.57
                    [94] => 11.39
                    [95] => 11.39
                    [96] => 10.5
                    [97] => 10.5
                    [98] => 9.67
                    [99] => 9.67
                    [100] => 8.67
                    [101] => 8.67
                    [102] => 7.69
                    [103] => 7.69
                    [104] => 6.86
                    [105] => 6.86
                    [106] => 6.1
                    [107] => 6.1
                    [108] => 5.29
                    [109] => 5.29
                    [110] => 4.55
                    [111] => 4.55
                    [112] => 3.96
                    [113] => 3.96
                    [114] => 3.48
                    [115] => 3.48
                    [116] => 2.99
                    [117] => 2.99
                    [118] => 2.53
                    [119] => 2.53
                    [120] => 2.14
                    [121] => 2.14
                    [122] => 1.78
                    [123] => 1.78
                    [124] => 1.46
                    [125] => 1.46
                    [126] => 1.16
                    [127] => 1.16
                    [128] => 0.87
                    [129] => 0.87
                    [130] => 0.65
                    [131] => 0.65
                    [132] => 0.49
                    [133] => 0.49
                    [134] => 0.36
                    [135] => 0.36
                    [136] => 0.26
                    [137] => 0.26
                    [138] => 0.2
                    [139] => 0.2
                    [140] => 0.15
                    [141] => 0.15
                    [142] => 0.11
                    [143] => 0.11
                )

        )

    [datay2] => Array
        (
            [46] => Array
                (
                    [0] => 5.71
                    [1] => 5.92
                    [2] => 6.06
                    [3] => 6.34
                    [4] => 7.12
                    [5] => 8.3
                    [6] => 9.78
                    [7] => 12.92
                    [8] => 18.06
                    [9] => 22.22
                    [10] => 25.22
                    [11] => 32.4
                    [12] => 42.45
                    [13] => 50.62
                    [14] => 54.6
                    [15] => 54.28
                    [16] => 50.66
                    [17] => 44.95
                    [18] => 38.01
                    [19] => 30.61
                    [20] => 22.81
                    [21] => 15.36
                    [22] => 9.64
                    [23] => 6.42
                    [24] => 5.05
                    [25] => 4.5
                    [26] => 4.22
                    [27] => 4.32
                    [28] => 5.02
                    [29] => 6.21
                    [30] => 7.75
                    [31] => 9.45
                    [32] => 10.62
                    [33] => 10.81
                    [34] => 10.47
                    [35] => 10.76
                    [36] => 11.69
                    [37] => 12.52
                    [38] => 12.94
                    [39] => 12.98
                    [40] => 13.14
                    [41] => 13.51
                    [42] => 13.59
                    [43] => 13.4
                    [44] => 13
                    [45] => 12.25
                    [46] => 11.29
                    [47] => 10.46
                    [48] => 9.81
                    [49] => 9.11
                    [50] => 8.21
                    [51] => 7.31
                    [52] => 6.53
                    [53] => 5.73
                    [54] => 4.98
                    [55] => 4.37
                    [56] => 3.87
                    [57] => 3.4
                    [58] => 2.89
                    [59] => 2.44
                    [60] => 2.07
                    [61] => 1.76
                    [62] => 1.44
                    [63] => 1.14
                    [64] => 0.89
                    [65] => 0.69
                    [66] => 0.52
                    [67] => 0.38
                    [68] => 0.28
                    [69] => 0.21
                    [70] => 0.16
                    [71] => 0.13
                )

            [53] => Array
                (
                    [0] => 6.12
                    [1] => 6.12
                    [2] => 6.35
                    [3] => 6.35
                    [4] => 6.75
                    [5] => 6.75
                    [6] => 7.26
                    [7] => 7.26
                    [8] => 8.18
                    [9] => 8.18
                    [10] => 9.44
                    [11] => 9.44
                    [12] => 11.03
                    [13] => 11.03
                    [14] => 14.14
                    [15] => 14.14
                    [16] => 19.25
                    [17] => 19.25
                    [18] => 23.22
                    [19] => 23.22
                    [20] => 26.07
                    [21] => 26.07
                    [22] => 33.11
                    [23] => 33.11
                    [24] => 42.98
                    [25] => 42.98
                    [26] => 50.98
                    [27] => 50.98
                    [28] => 54.78
                    [29] => 54.78
                    [30] => 53.67
                    [31] => 53.67
                    [32] => 49.38
                    [33] => 49.38
                    [34] => 43.88
                    [35] => 43.88
                    [36] => 37.16
                    [37] => 37.16
                    [38] => 30.3
                    [39] => 30.3
                    [40] => 23.33
                    [41] => 23.33
                    [42] => 16.21
                    [43] => 16.21
                    [44] => 10.66
                    [45] => 10.66
                    [46] => 7.49
                    [47] => 7.49
                    [48] => 6.12
                    [49] => 6.12
                    [50] => 5.49
                    [51] => 5.49
                    [52] => 5.22
                    [53] => 5.22
                    [54] => 5.4
                    [55] => 5.4
                    [56] => 6.14
                    [57] => 6.14
                    [58] => 7.34
                    [59] => 7.34
                    [60] => 8.97
                    [61] => 8.97
                    [62] => 10.74
                    [63] => 10.74
                    [64] => 11.85
                    [65] => 11.85
                    [66] => 11.83
                    [67] => 11.83
                    [68] => 11.42
                    [69] => 11.42
                    [70] => 11.69
                    [71] => 11.69
                    [72] => 12.6
                    [73] => 12.6
                    [74] => 13.37
                    [75] => 13.37
                    [76] => 13.66
                    [77] => 13.66
                    [78] => 13.71
                    [79] => 13.71
                    [80] => 13.82
                    [81] => 13.82
                    [82] => 14.12
                    [83] => 14.12
                    [84] => 14.24
                    [85] => 14.24
                    [86] => 13.84
                    [87] => 13.84
                    [88] => 13.27
                    [89] => 13.27
                    [90] => 12.54
                    [91] => 12.54
                    [92] => 11.58
                    [93] => 11.58
                    [94] => 10.59
                    [95] => 10.59
                    [96] => 9.74
                    [97] => 9.74
                    [98] => 8.99
                    [99] => 8.99
                    [100] => 8.18
                    [101] => 8.18
                    [102] => 7.33
                    [103] => 7.33
                    [104] => 6.58
                    [105] => 6.58
                    [106] => 5.84
                    [107] => 5.84
                    [108] => 5.06
                    [109] => 5.06
                    [110] => 4.35
                    [111] => 4.35
                    [112] => 3.81
                    [113] => 3.81
                    [114] => 3.39
                    [115] => 3.39
                    [116] => 2.93
                    [117] => 2.93
                    [118] => 2.48
                    [119] => 2.48
                    [120] => 2.07
                    [121] => 2.07
                    [122] => 1.72
                    [123] => 1.72
                    [124] => 1.4
                    [125] => 1.4
                    [126] => 1.11
                    [127] => 1.11
                    [128] => 0.85
                    [129] => 0.85
                    [130] => 0.64
                    [131] => 0.64
                    [132] => 0.47
                    [133] => 0.47
                    [134] => 0.35
                    [135] => 0.35
                    [136] => 0.26
                    [137] => 0.26
                    [138] => 0.19
                    [139] => 0.19
                    [140] => 0.15
                    [141] => 0.15
                    [142] => 0.12
                    [143] => 0.12
                )

        )

    [datay3] => Array
        (
            [46] => Array
                (
                    [0] => 5.65
                    [1] => 5.84
                    [2] => 5.98
                    [3] => 6.33
                    [4] => 7.08
                    [5] => 8.28
                    [6] => 9.77
                    [7] => 12.88
                    [8] => 18.03
                    [9] => 22.25
                    [10] => 25.25
                    [11] => 32.42
                    [12] => 42.49
                    [13] => 50.64
                    [14] => 54.69
                    [15] => 54.33
                    [16] => 50.65
                    [17] => 45.01
                    [18] => 37.99
                    [19] => 30.68
                    [20] => 22.96
                    [21] => 15.52
                    [22] => 9.78
                    [23] => 6.55
                    [24] => 5.18
                    [25] => 4.62
                    [26] => 4.36
                    [27] => 4.44
                    [28] => 5.12
                    [29] => 6.29
                    [30] => 7.82
                    [31] => 9.5
                    [32] => 10.66
                    [33] => 10.83
                    [34] => 10.51
                    [35] => 10.79
                    [36] => 11.73
                    [37] => 12.61
                    [38] => 12.94
                    [39] => 12.99
                    [40] => 13.15
                    [41] => 13.5
                    [42] => 13.59
                    [43] => 13.39
                    [44] => 12.98
                    [45] => 12.24
                    [46] => 11.31
                    [47] => 10.43
                    [48] => 9.76
                    [49] => 9.09
                    [50] => 8.19
                    [51] => 7.31
                    [52] => 6.53
                    [53] => 5.74
                    [54] => 4.96
                    [55] => 4.35
                    [56] => 3.86
                    [57] => 3.38
                    [58] => 2.88
                    [59] => 2.43
                    [60] => 2.06
                    [61] => 1.75
                    [62] => 1.44
                    [63] => 1.15
                    [64] => 0.89
                    [65] => 0.68
                    [66] => 0.52
                    [67] => 0.38
                    [68] => 0.28
                    [69] => 0.21
                    [70] => 0.16
                    [71] => 0.12
                )

            [53] => Array
                (
                    [0] => 6.08
                    [1] => 6.08
                    [2] => 6.44
                    [3] => 6.44
                    [4] => 6.84
                    [5] => 6.84
                    [6] => 7.29
                    [7] => 7.29
                    [8] => 8.21
                    [9] => 8.21
                    [10] => 9.57
                    [11] => 9.57
                    [12] => 11.14
                    [13] => 11.14
                    [14] => 14.25
                    [15] => 14.25
                    [16] => 19.36
                    [17] => 19.36
                    [18] => 23.32
                    [19] => 23.32
                    [20] => 26.16
                    [21] => 26.16
                    [22] => 33.15
                    [23] => 33.15
                    [24] => 42.9
                    [25] => 42.9
                    [26] => 50.95
                    [27] => 50.95
                    [28] => 54.67
                    [29] => 54.67
                    [30] => 53.5
                    [31] => 53.5
                    [32] => 49.33
                    [33] => 49.33
                    [34] => 43.74
                    [35] => 43.74
                    [36] => 37.05
                    [37] => 37.05
                    [38] => 30.15
                    [39] => 30.15
                    [40] => 23.18
                    [41] => 23.18
                    [42] => 16.08
                    [43] => 16.08
                    [44] => 10.5
                    [45] => 10.5
                    [46] => 7.35
                    [47] => 7.35
                    [48] => 5.99
                    [49] => 5.99
                    [50] => 5.38
                    [51] => 5.38
                    [52] => 5.13
                    [53] => 5.13
                    [54] => 5.3
                    [55] => 5.3
                    [56] => 6.04
                    [57] => 6.04
                    [58] => 7.27
                    [59] => 7.27
                    [60] => 8.88
                    [61] => 8.88
                    [62] => 10.61
                    [63] => 10.61
                    [64] => 11.69
                    [65] => 11.69
                    [66] => 11.67
                    [67] => 11.67
                    [68] => 11.28
                    [69] => 11.28
                    [70] => 11.56
                    [71] => 11.56
                    [72] => 12.49
                    [73] => 12.49
                    [74] => 13.26
                    [75] => 13.26
                    [76] => 13.56
                    [77] => 13.56
                    [78] => 13.58
                    [79] => 13.58
                    [80] => 13.71
                    [81] => 13.71
                    [82] => 14.04
                    [83] => 14.04
                    [84] => 14.12
                    [85] => 14.12
                    [86] => 13.76
                    [87] => 13.76
                    [88] => 13.16
                    [89] => 13.16
                    [90] => 12.45
                    [91] => 12.45
                    [92] => 11.51
                    [93] => 11.51
                    [94] => 10.51
                    [95] => 10.51
                    [96] => 9.65
                    [97] => 9.65
                    [98] => 8.92
                    [99] => 8.92
                    [100] => 8.12
                    [101] => 8.12
                    [102] => 7.26
                    [103] => 7.26
                    [104] => 6.53
                    [105] => 6.53
                    [106] => 5.8
                    [107] => 5.8
                    [108] => 5.03
                    [109] => 5.03
                    [110] => 4.31
                    [111] => 4.31
                    [112] => 3.78
                    [113] => 3.78
                    [114] => 3.35
                    [115] => 3.35
                    [116] => 2.92
                    [117] => 2.92
                    [118] => 2.46
                    [119] => 2.46
                    [120] => 2.05
                    [121] => 2.05
                    [122] => 1.71
                    [123] => 1.71
                    [124] => 1.39
                    [125] => 1.39
                    [126] => 1.1
                    [127] => 1.1
                    [128] => 0.84
                    [129] => 0.84
                    [130] => 0.63
                    [131] => 0.63
                    [132] => 0.47
                    [133] => 0.47
                    [134] => 0.35
                    [135] => 0.35
                    [136] => 0.25
                    [137] => 0.25
                    [138] => 0.19
                    [139] => 0.19
                    [140] => 0.15
                    [141] => 0.15
                    [142] => 0.11
                    [143] => 0.11
                )

        )

    [datay4] => Array
        (
            [46] => Array
                (
                    [0] => 19.1
                    [1] => 28.18
                    [2] => 34.36
                    [3] => 38.3
                    [4] => 41.71
                    [5] => 44.82
                    [6] => 46.3
                    [7] => 45.75
                    [8] => 42.68
                    [9] => 36.61
                    [10] => 27.91
                    [11] => 19.05
                    [12] => 12.11
                    [13] => 7.68
                    [14] => 5.54
                    [15] => 4.56
                    [16] => 3.71
                    [17] => 2.93
                    [18] => 2.42
                    [19] => 2.24
                    [20] => 2.07
                    [21] => 1.74
                    [22] => 1.4
                    [23] => 1.25
                    [24] => 1.36
                    [25] => 1.78
                    [26] => 2.41
                    [27] => 3.13
                    [28] => 3.69
                    [29] => 3.98
                    [30] => 4.17
                    [31] => 4.33
                    [32] => 4.21
                    [33] => 3.72
                    [34] => 3.19
                    [35] => 2.95
                    [36] => 2.88
                    [37] => 2.93
                    [38] => 3.43
                    [39] => 5.02
                    [40] => 8.44
                    [41] => 12.4
                    [42] => 14.57
                    [43] => 14.82
                    [44] => 14.19
                    [45] => 13.28
                    [46] => 12.11
                    [47] => 11.12
                    [48] => 10.35
                    [49] => 9.57
                    [50] => 8.61
                    [51] => 7.64
                    [52] => 6.8
                    [53] => 6.04
                    [54] => 5.27
                    [55] => 4.56
                    [56] => 3.98
                    [57] => 3.46
                    [58] => 2.97
                    [59] => 2.52
                    [60] => 2.14
                    [61] => 1.8
                    [62] => 1.5
                    [63] => 1.2
                    [64] => 0.93
                    [65] => 0.7
                    [66] => 0.53
                    [67] => 0.39
                    [68] => 0.29
                    [69] => 0.21
                    [70] => 0.16
                    [71] => 0.13
                )

            [53] => Array
                (
                    [0] => 17.61
                    [1] => 17.61
                    [2] => 26.51
                    [3] => 26.51
                    [4] => 32.89
                    [5] => 32.89
                    [6] => 37.43
                    [7] => 37.43
                    [8] => 41.49
                    [9] => 41.49
                    [10] => 44.8
                    [11] => 44.8
                    [12] => 46.36
                    [13] => 46.36
                    [14] => 45.54
                    [15] => 45.54
                    [16] => 42.31
                    [17] => 42.31
                    [18] => 35.92
                    [19] => 35.92
                    [20] => 26.84
                    [21] => 26.84
                    [22] => 17.93
                    [23] => 17.93
                    [24] => 11.19
                    [25] => 11.19
                    [26] => 7.1
                    [27] => 7.1
                    [28] => 5.23
                    [29] => 5.23
                    [30] => 4.41
                    [31] => 4.41
                    [32] => 3.59
                    [33] => 3.59
                    [34] => 2.81
                    [35] => 2.81
                    [36] => 2.3
                    [37] => 2.3
                    [38] => 2.1
                    [39] => 2.1
                    [40] => 1.94
                    [41] => 1.94
                    [42] => 1.65
                    [43] => 1.65
                    [44] => 1.38
                    [45] => 1.38
                    [46] => 1.26
                    [47] => 1.26
                    [48] => 1.4
                    [49] => 1.4
                    [50] => 1.8
                    [51] => 1.8
                    [52] => 2.43
                    [53] => 2.43
                    [54] => 3.17
                    [55] => 3.17
                    [56] => 3.73
                    [57] => 3.73
                    [58] => 4.03
                    [59] => 4.03
                    [60] => 4.21
                    [61] => 4.21
                    [62] => 4.39
                    [63] => 4.39
                    [64] => 4.23
                    [65] => 4.23
                    [66] => 3.69
                    [67] => 3.69
                    [68] => 3.23
                    [69] => 3.23
                    [70] => 3.04
                    [71] => 3.04
                    [72] => 3.01
                    [73] => 3.01
                    [74] => 3.08
                    [75] => 3.08
                    [76] => 3.62
                    [77] => 3.62
                    [78] => 5.19
                    [79] => 5.19
                    [80] => 8.4
                    [81] => 8.4
                    [82] => 12.01
                    [83] => 12.01
                    [84] => 14.28
                    [85] => 14.28
                    [86] => 15.13
                    [87] => 15.13
                    [88] => 14.78
                    [89] => 14.78
                    [90] => 13.94
                    [91] => 13.94
                    [92] => 12.85
                    [93] => 12.85
                    [94] => 11.59
                    [95] => 11.59
                    [96] => 10.43
                    [97] => 10.43
                    [98] => 9.41
                    [99] => 9.41
                    [100] => 8.47
                    [101] => 8.47
                    [102] => 7.63
                    [103] => 7.63
                    [104] => 6.82
                    [105] => 6.82
                    [106] => 6.06
                    [107] => 6.06
                    [108] => 5.27
                    [109] => 5.27
                    [110] => 4.53
                    [111] => 4.53
                    [112] => 3.91
                    [113] => 3.91
                    [114] => 3.44
                    [115] => 3.44
                    [116] => 3.08
                    [117] => 3.08
                    [118] => 2.69
                    [119] => 2.69
                    [120] => 2.26
                    [121] => 2.26
                    [122] => 1.86
                    [123] => 1.86
                    [124] => 1.51
                    [125] => 1.51
                    [126] => 1.19
                    [127] => 1.19
                    [128] => 0.91
                    [129] => 0.91
                    [130] => 0.68
                    [131] => 0.68
                    [132] => 0.5
                    [133] => 0.5
                    [134] => 0.36
                    [135] => 0.36
                    [136] => 0.26
                    [137] => 0.26
                    [138] => 0.2
                    [139] => 0.2
                    [140] => 0.16
                    [141] => 0.16
                    [142] => 0.12
                    [143] => 0.12
                )

        )

)
 
Thanks.
I am struggling to visualise the graph now. I don't currently understand why there are two plots for each datayX.
I would expect instead two line plots on each of four graphs. Is this what you are trying to achieve? Or are you trying to get each graph of two plots on a single canvas?
 
That's a good question! For each set of data, these is only a single X and four Y columns. And, of course, it can also plot multiple sets of data for each one so the plot can get quite busy and hence the original question. After tomorrow it will be a moot point, though, because it's my last day on this contract. However, I realized one issue yesterday that I had it called a new LinePlot twice although it did not show in the code I posted here. The result was that the second call was cancelling out a couple of the settings but that's been fixed.

One thing that might help if I can get it to work is for it to choose the mark shape and line style from an array. Right now, the mark shapes and lines are the same for any given color so, of course, it's impossible to know which it is in the plot. I tried this for the marks and while there were no errors, neither were there marks. I tried it both with the values quoted and unquoted but it was the same either way although that there was no error with the latter was a surprise:

Code:
$Marks = array(MARK_DIAMOND,MARK_UTRIANGLE,MARK_DTRIANGLE,MARK_FILLEDCIRCLE);
if ($Mark) $lp[$key]->mark->SetType($Marks[$key], $red, 0.3);
 
so i'm still a bit confused.

are you looking for:

1. one canvas
2. one x-axis
3. four plots sharing one y-axis
4. four plots sharing a second y-axis

or are you looking for two graphs? each with four plots on it, sharing the same y-axis.

i will take a look at the plot markers when I understand what is actually being sought.
 
I have the graphs and plots already. What I am looking for is how to differenciate them in the legend.

Because each color, which is in its own Y column, is blocked into the code in such a way that I can enable or disable it from the plot at will, anything I apply to the color is the same for all datasets it is plotting. With one dataset it's no problem but when there are two or more, each has the same line style and mark. In other words, if I tell it to give Red a triangle mark and a dashed line style, all the Red plots will have a triangle mark and a dashed line style so it's impossible to tell one from another.

To answer your question, there is a single X and four Y columns (five columns total in the database) and there might be multiple datasets, each separated from the other by a FileID field. Each dataset can produce four plots (one for each color: Red, Gr, Gb, Blue) but, as mentioned, by using a check box I can show or hide any of them. By using other check boxes, I can add or remove fill, change the line weight, add or remove the marks and hide or show the legend.

Here is the block for Red and there are three others:

Code:
if (!$SubData || $Red):
	foreach($datay1 as $key=>$_datay): // for Red
		$red = randColor('red', 'dark', 255);
		$queryFN = "SELECT DISTINCT FileName FROM dcs_uploads ";
		$queryFN .= "WHERE ID = ".$key." ";
		$queryFN .= "ORDER by FileName";
		if ($result = $mysqli->query($queryFN)):
			$row = $result->fetch_row();
			$FileName = $row[0];
		endif;
		$lp[$key] = new LinePlot($_datay,$datax[$key]);
		$graph->Add($lp[$key]);

		//if ($Mark) $lp[$key]->mark->SetType($Marks[$key], $red, 0.3);
		if ($Mark) $lp[$key]->mark->SetType(MARK_DIAMOND, $red, 0.3);
		if ($Fill) $lp[$key]->SetFillColor($red.'@0.7');
		if ($Weight) $lp[$key]->SetWeight(3);
		if ($Legend) $lp[$key]->SetLegend("Red-".basename($FileName, ".csv"));
		if ($Values) $lp[$key]->value->Show();
		if ($Values) $lp[$key]->value->SetMargin(0);
		$lp[$key]->SetStyle('dashed');
		$lp[$key]->SetColor($red);
	endforeach;
endif;
 
using this I get a reasonable plot although I have not been able to test the legends and the other conditionals that you have added (e.g. if $Values etc).

for each dataset a different plot mark is used.

I created manually an array of colours. However I don't know what Gb relates to in terms of colour and hue etc so I leave it up to you to replace the references to 'something' and create an array of named colour ranges. The names should be taken from here:
In the alternative, instead of randomising the colours, start (say) with red and increment by 1/20 of the spectrum (or whatever), for each subsequent call to the colour getter (see the 'static' keyword for how to maintain state inside a function. something like this would work
Code:
[COLOR=#990000]<?php[/color]
[b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]getColour[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$type[/color][COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
[tab][b][COLOR=#0000FF]static[/color][/b] [COLOR=#009900]$red[/color] [COLOR=#990000]=[/color] [COLOR=#993399]255[/color][COLOR=#990000];[/color]
[tab][b][COLOR=#0000FF]static[/color][/b] [COLOR=#009900]$green[/color] [COLOR=#990000]=[/color] [COLOR=#993399]255[/color][COLOR=#990000];[/color]
[tab][b][COLOR=#0000FF]static[/color][/b] [COLOR=#009900]$blue[/color] [COLOR=#990000]=[/color] [COLOR=#993399]255[/color][COLOR=#990000];[/color]
[tab][b][COLOR=#0000FF]if[/color][/b][COLOR=#990000]([/color]$[COLOR=#FF0000]{[/color][COLOR=#009900]$type[/color][COLOR=#FF0000]}[/color] [COLOR=#990000]<[/color] [COLOR=#993399]0[/color][COLOR=#990000])[/color] $[COLOR=#FF0000]{[/color][COLOR=#009900]$type[/color][COLOR=#FF0000]}[/color] [COLOR=#990000]=[/color] [COLOR=#993399]255[/color][COLOR=#990000];[/color]
[tab][COLOR=#009900]$increment[/color] [COLOR=#990000]=[/color] [COLOR=#993399]30[/color][COLOR=#990000];[/color]
[tab][COLOR=#009900]$format[/color] [COLOR=#990000]=[/color] [COLOR=#009900]$type[/color] [COLOR=#990000]==[/color] [COLOR=#FF0000]'red'[/color] [COLOR=#990000]?[/color] [COLOR=#FF0000]'#%02s0000'[/color] [COLOR=#990000]:[/color] [COLOR=#990000]([/color][COLOR=#009900]$type[/color] [COLOR=#990000]==[/color] [COLOR=#FF0000]'green'[/color] [COLOR=#990000]?[/color] [COLOR=#FF0000]'#00%02s00'[/color] [COLOR=#990000]:[/color] [COLOR=#FF0000]'#0000%02s'[/color][COLOR=#990000]);[/color]
[tab][COLOR=#009900]$col[/color] [COLOR=#990000]=[/color] [b][COLOR=#000000]sprintf[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$format[/color][COLOR=#990000],[/color] [b][COLOR=#000000]dechex[/color][/b][COLOR=#990000]([/color]$[COLOR=#FF0000]{[/color][COLOR=#009900]$type[/color][COLOR=#FF0000]}[/color][COLOR=#990000])[/color] [COLOR=#990000]);[/color] 
[tab]$[COLOR=#FF0000]{[/color][COLOR=#009900]$type[/color][COLOR=#FF0000]}[/color] [COLOR=#990000]=[/color] $[COLOR=#FF0000]{[/color][COLOR=#009900]$type[/color][COLOR=#FF0000]}[/color] [COLOR=#990000]-[/color] [COLOR=#009900]$increment[/color][COLOR=#990000];[/color]
[tab][b][COLOR=#0000FF]return[/color][/b] [b][COLOR=#000000]str_replace[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]' '[/color][COLOR=#990000],[/color][COLOR=#FF0000]''[/color][COLOR=#990000],[/color][COLOR=#009900]$col[/color][COLOR=#990000]);[/color]
[COLOR=#FF0000]}[/color]
[i][COLOR=#9A1900]//eg[/color][/i]
[b][COLOR=#0000FF]foreach[/color][/b][COLOR=#990000]([/color][b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'red'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'green'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'blue'[/color][COLOR=#990000])[/color] [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$type[/color][COLOR=#990000]):[/color]
[tab][b][COLOR=#0000FF]for[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$i[/color] [COLOR=#990000]=[/color] [COLOR=#993399]0[/color][COLOR=#990000];[/color] [COLOR=#009900]$i[/color] [COLOR=#990000]<[/color] [COLOR=#993399]10[/color][COLOR=#990000];[/color] [COLOR=#009900]$i[/color][COLOR=#990000]++):[/color]
[tab][tab][COLOR=#009900]$col[/color] [COLOR=#990000]=[/color] [b][COLOR=#000000]getColour[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$type[/color][COLOR=#990000],[/color] [COLOR=#993399]50[/color][COLOR=#990000]);[/color]
[tab][tab][b][COLOR=#0000FF]echo[/color][/b] [COLOR=#990000]<<<[/color]HTML
[tab][COLOR=#990000]<[/color]div style[COLOR=#990000]=[/color][COLOR=#FF0000]"background-color:$col;"[/color][COLOR=#990000]>[/color][COLOR=#009900]$col[/color][COLOR=#990000]</[/color]div[COLOR=#990000]>[/color]

HTML[COLOR=#990000];[/color]
[tab][b][COLOR=#0000FF]endfor[/color][/b][COLOR=#990000];[/color]
[b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[COLOR=#990000]?>[/color]


note that with the code below you do not need one segment for each $datayX. it will do them all sequentially.

Code:
[b][COLOR=#000080]require_once[/color][/b] [COLOR=#FF0000]'src/jpgraph.php'[/color][COLOR=#990000];[/color]
[b][COLOR=#000080]require_once[/color][/b] [COLOR=#FF0000]'src/jpgraph_line.php'[/color][COLOR=#990000];[/color]
[b][COLOR=#000080]require_once[/color][/b] [COLOR=#FF0000]'src/jpgraph_scatter.php'[/color][COLOR=#990000];[/color]
[COLOR=#009900]$graph[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]new[/color][/b] [b][COLOR=#000000]graph[/color][/b][COLOR=#990000]([/color][COLOR=#993399]800[/color][COLOR=#990000],[/color][COLOR=#993399]800[/color][COLOR=#990000]);[/color]
[COLOR=#009900]$graph[/color][COLOR=#990000]->[/color][b][COLOR=#000000]setScale[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'lin'[/color][COLOR=#990000]);[/color]
[COLOR=#009900]$marks[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]([/color][tab] MARK_SQUARE[COLOR=#990000],[/color] 
[tab][tab][tab][tab][tab]MARK_X[COLOR=#990000],[/color]
[tab][tab][tab][tab][tab]MARK_DIAMOND[COLOR=#990000],[/color] 
[tab][tab][tab][tab][tab]MARK_CIRCLE[COLOR=#990000],[/color] 
[tab][tab][tab][tab][tab]MARK_STAR
[tab][tab][tab][tab][COLOR=#990000]);[/color]

[COLOR=#009900]$queryFN[/color] [COLOR=#990000]=[/color] [COLOR=#990000]<<<[/color]SQL
SELECT DISTINCT FileName 
FROM dcs_uploads 
WHERE ID [COLOR=#990000]=[/color] [COLOR=#FF0000]'%s'[/color]
ORDER by FileName
SQL[COLOR=#990000];[/color]

[i][COLOR=#9A1900]//use this for the colour types distinguished by datayX[/color][/i]
[COLOR=#009900]$types[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]([/color][tab] [COLOR=#FF0000]'red'[/color][COLOR=#990000],[/color]
[tab][tab][tab][tab][tab][COLOR=#FF0000]'green'[/color][COLOR=#990000],[/color]
[tab][tab][tab][tab][tab][COLOR=#FF0000]'something'[/color][COLOR=#990000],[/color] [i][COLOR=#9A1900]//replace with something meaningful[/color][/i]
[tab][tab][tab][tab][tab][COLOR=#FF0000]'blue'[/color]
[tab][tab][tab][COLOR=#990000]);[/color]
[COLOR=#009900]$colours[/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]([/color] 
[tab][tab][tab][tab][tab][COLOR=#FF0000]'red'[/color][COLOR=#990000]=>[/color][b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'darkred'[/color][COLOR=#990000],[/color] [COLOR=#FF0000]'indianred'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'lightred'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'mediumred'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'orangered'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'palevioletred'[/color][COLOR=#990000]),[/color] 
[tab][tab][tab][tab][tab][COLOR=#FF0000]'green'[/color][COLOR=#990000]=>[/color][b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'darkgreen'[/color][COLOR=#990000],[/color] [COLOR=#FF0000]'darkseagreen'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'forestgreen'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'green'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'lightseagreen'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'palegreen3'[/color][COLOR=#990000]),[/color]
[tab][tab][tab][tab][tab][COLOR=#FF0000]'something'[/color][COLOR=#990000]=>[/color][b][COLOR=#0000FF]array[/color][/b][COLOR=#990000](),[/color]
[tab][tab][tab][tab][tab][COLOR=#FF0000]'blue'[/color][COLOR=#990000]=>[/color][b][COLOR=#0000FF]array[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'blue'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'cadetblue'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'cornflowerblue'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'darkblue'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'darkslateblue'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'dodgerblue'[/color][COLOR=#990000])[/color]
[tab][tab][tab][tab][tab][COLOR=#990000]);[/color]
[tab][tab][tab][tab][tab]
[i][COLOR=#9A1900]//assemble the plot data into a single array[/color][/i]
[COLOR=#009900]$text[/color] [COLOR=#990000]=[/color] [b][COLOR=#000000]compact[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'datax'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'datay1'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'datay2'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'datay3'[/color][COLOR=#990000],[/color][COLOR=#FF0000]'datay4'[/color][COLOR=#990000]);[/color]

[i][COLOR=#9A1900]//iterate over the plot data[/color][/i]
[b][COLOR=#0000FF]foreach[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$text[/color][COLOR=#990000][[/color][COLOR=#FF0000]'datax'[/color][COLOR=#990000]][/color] [b][COLOR=#0000FF]as[/color][/b] [COLOR=#009900]$key[/color][COLOR=#990000]=>[/color][COLOR=#009900]$data[/color][COLOR=#990000]):[/color]
[tab][i][COLOR=#9A1900]/*[/color][/i]
[i][COLOR=#9A1900][tab] * sort out the filename[/color][/i]
[i][COLOR=#9A1900][tab] */[/color][/i]
[tab][COLOR=#009900]$FileName[/color] [COLOR=#990000]=[/color] [COLOR=#FF0000]''[/color][COLOR=#990000];[/color]
[tab][b][COLOR=#0000FF]if[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$result[/color] [COLOR=#990000]=[/color] [COLOR=#009900]$mysqli[/color][COLOR=#990000]->[/color][b][COLOR=#000000]query[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]sprintf[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$queryFN[/color][COLOR=#990000],[/color] [COLOR=#009900]$key[/color][COLOR=#990000]))):[/color]
[tab][tab][tab][COLOR=#009900]$row[/color] [COLOR=#990000]=[/color] [COLOR=#009900]$result[/color][COLOR=#990000]->[/color][b][COLOR=#000000]fetch_row[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][COLOR=#009900]$FileName[/color] [COLOR=#990000]=[/color] [COLOR=#009900]$row[/color][COLOR=#990000][[/color][COLOR=#993399]0[/color][COLOR=#990000]];[/color]
[tab][b][COLOR=#0000FF]endif[/color][/b][COLOR=#990000];[/color]
[tab]
[tab][i][COLOR=#9A1900]/*[/color][/i]
[i][COLOR=#9A1900][tab] * sort out the plot markers[/color][/i]
[i][COLOR=#9A1900][tab] */[/color][/i]
[tab][tab]
[tab][COLOR=#009900]$mark[/color] [COLOR=#990000]=[/color] [b][COLOR=#000000]current[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$marks[/color][COLOR=#990000]);[/color] 
[tab][b][COLOR=#0000FF]if[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$mark[/color] [COLOR=#990000]===[/color] false[COLOR=#990000])[/color] [COLOR=#009900]$mark[/color] [COLOR=#990000]=[/color] [b][COLOR=#000000]reset[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$marks[/color][COLOR=#990000]);[/color]
[tab][b][COLOR=#000000]next[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$marks[/color][COLOR=#990000]);[/color]
[tab]
[tab][i][COLOR=#9A1900]/*[/color][/i]
[i][COLOR=#9A1900][tab] * sort out the plots[/color][/i]
[i][COLOR=#9A1900][tab] */[/color][/i]
[tab][b][COLOR=#0000FF]for[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$i[/color][COLOR=#990000]=[/color][COLOR=#993399]1[/color][COLOR=#990000];[/color] [COLOR=#009900]$i[/color][COLOR=#990000]<=[/color][COLOR=#993399]4[/color][COLOR=#990000];[/color] [COLOR=#009900]$i[/color][COLOR=#990000]++):[/color]
[tab][tab][COLOR=#009900]$plots[/color][COLOR=#990000][][/color] [COLOR=#990000]=[/color] [b][COLOR=#0000FF]new[/color][/b] [b][COLOR=#000000]lineplot[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$text[/color][COLOR=#990000][[/color][COLOR=#FF0000]"datay"[/color] [COLOR=#990000].[/color] [COLOR=#009900]$i[/color][COLOR=#990000]][[/color][COLOR=#009900]$key[/color][COLOR=#990000]],[/color] [COLOR=#009900]$text[/color][COLOR=#990000][[/color][COLOR=#FF0000]'datax'[/color][COLOR=#990000]][[/color][COLOR=#009900]$key[/color][COLOR=#990000]]);[/color]
[tab][tab][COLOR=#009900]$lp[/color] [COLOR=#990000]=&[/color] [b][COLOR=#000000]end[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$plots[/color][COLOR=#990000]);[/color]
[tab][tab][b][COLOR=#0000FF]if[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$Mark[/color][COLOR=#990000])[/color] [COLOR=#009900]$lp[/color][COLOR=#990000]->[/color]mark[COLOR=#990000]->[/color][b][COLOR=#000000]setType[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$mark[/color][COLOR=#990000]);[/color]
[tab][tab][tab][tab][COLOR=#009900]$col[/color] [COLOR=#990000]=[/color]  [b][COLOR=#0000FF]isset[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$colours[/color][COLOR=#990000][[/color][COLOR=#009900]$types[/color][COLOR=#990000][[/color][COLOR=#009900]$i[/color][COLOR=#990000]-[/color][COLOR=#993399]1[/color][COLOR=#990000]]][[/color][COLOR=#009900]$i[/color][COLOR=#990000]-[/color][COLOR=#993399]1[/color][COLOR=#990000]])[/color] [COLOR=#990000]?[/color] [COLOR=#009900]$colours[/color][COLOR=#990000][[/color][COLOR=#009900]$types[/color][COLOR=#990000][[/color][COLOR=#009900]$i[/color][COLOR=#990000]-[/color][COLOR=#993399]1[/color][COLOR=#990000]]][[/color][COLOR=#009900]$i[/color][COLOR=#990000]-[/color][COLOR=#993399]1[/color][COLOR=#990000]][/color] [COLOR=#990000]:[/color] [COLOR=#FF0000]'black'[/color] [COLOR=#990000]);[/color]  [i][COLOR=#9A1900]//picks a colour[/color][/i]
[tab][tab][tab][tab][b][COLOR=#0000FF]if[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$Fill[/color][COLOR=#990000])[/color] [COLOR=#009900]$lp[/color][COLOR=#990000]->[/color][b][COLOR=#000000]SetFillColor[/color][/b][COLOR=#990000]([/color] [COLOR=#009900]$col[/color] [COLOR=#990000].[/color][COLOR=#FF0000]'@0.7'[/color] [COLOR=#990000]);[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]if[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$Weight[/color][COLOR=#990000])[/color] [COLOR=#009900]$lp[/color][COLOR=#990000]->[/color][b][COLOR=#000000]SetWeight[/color][/b][COLOR=#990000]([/color][COLOR=#993399]3[/color][COLOR=#990000]);[/color]
[tab][tab][b][COLOR=#0000FF]if[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$Legend[/color][COLOR=#990000])[/color] [COLOR=#009900]$lp[/color][COLOR=#990000]->[/color][b][COLOR=#000000]SetLegend[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]sprintf[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]"%s-%s"[/color][COLOR=#990000],[/color][b][COLOR=#000000]ucfirst[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$types[/color][COLOR=#990000][[/color][COLOR=#009900]$i[/color][COLOR=#990000]-[/color][COLOR=#993399]1[/color][COLOR=#990000]]),[/color][b][COLOR=#000000]basename[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$FileName[/color][COLOR=#990000],[/color] [COLOR=#FF0000]".csv"[/color][COLOR=#990000])));[/color]
[tab][tab][COLOR=#009900]$lp[/color][COLOR=#990000]->[/color]mark[COLOR=#990000]->[/color][b][COLOR=#000000]setWidth[/color][/b][COLOR=#990000]([/color][COLOR=#993399]3[/color][COLOR=#990000]);[/color]
[tab][tab][COLOR=#009900]$lp[/color][COLOR=#990000]->[/color][b][COLOR=#000000]SetColor[/color][/b][COLOR=#990000]([/color] [COLOR=#009900]$col[/color] [COLOR=#990000]);[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]if[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$Values[/color][COLOR=#990000]):[/color]
[tab][tab][tab][tab]  [COLOR=#009900]$lp[/color][COLOR=#990000]->[/color]value[COLOR=#990000]->[/color][b][COLOR=#000000]Show[/color][/b][COLOR=#990000]();[/color]
[tab][tab][tab][tab]  [COLOR=#009900]$lp[/color][COLOR=#990000]->[/color]value[COLOR=#990000]->[/color][b][COLOR=#000000]SetMargin[/color][/b][COLOR=#990000]([/color][COLOR=#993399]0[/color][COLOR=#990000]);[/color]
[tab][tab][tab][tab][b][COLOR=#0000FF]endif[/color][/b][COLOR=#990000];[/color]
[tab][tab][tab][tab][COLOR=#009900]$lp[/color][COLOR=#990000]->[/color][b][COLOR=#000000]SetStyle[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]'dashed'[/color][COLOR=#990000]);[/color]
[tab][tab][COLOR=#009900]$graph[/color][COLOR=#990000]->[/color][b][COLOR=#000000]Add[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$lp[/color][COLOR=#990000]);[/color]
[tab][b][COLOR=#0000FF]endfor[/color][/b][COLOR=#990000];[/color]
[b][COLOR=#0000FF]endforeach[/color][/b][COLOR=#990000];[/color]
[COLOR=#009900]$graph[/color][COLOR=#990000]->[/color][b][COLOR=#000000]stroke[/color][/b][COLOR=#990000]();[/color]
 
and just to finish up on the legends issue.

Code:
[COLOR=#009900]$graph[/color][COLOR=#990000]->[/color]legend[COLOR=#990000]->[/color][b][COLOR=#000000]setColumns[/color][/b][COLOR=#990000]([/color][COLOR=#993399]1[/color][COLOR=#990000]);[/color]
[COLOR=#009900]$graph[/color][COLOR=#990000]->[/color]legend[COLOR=#990000]->[/color][b][COLOR=#000000]setAbsPos[/color][/b][COLOR=#990000]([/color][COLOR=#993399]0[/color][COLOR=#990000],[/color][COLOR=#993399]0[/color][COLOR=#990000],[/color][COLOR=#FF0000]'left'[/color][COLOR=#990000],[/color]top[COLOR=#FF0000]');[/color]

If you want to limit the horizontal length of the legend text then run it through a function before using it. As follows

Code:
[b][COLOR=#0000FF]function[/color][/b] [b][COLOR=#000000]wrapLegend[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$legend[/color][COLOR=#990000])[/color][COLOR=#FF0000]{[/color]
  [b][COLOR=#0000FF]return[/color][/b] [b][COLOR=#000000]wordwrap[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$legend[/color][COLOR=#990000],[/color] [COLOR=#993399]40[/color][COLOR=#990000]);[/color] [i][COLOR=#9A1900]//change the number as you need[/color][/i]
[COLOR=#FF0000]}[/color]
 
Code:
[b][COLOR=#0000FF]if[/color][/b] [COLOR=#990000]([/color][COLOR=#009900]$Legend[/color][COLOR=#990000])[/color] [COLOR=#009900]$lp[/color][COLOR=#990000]->[/color][b][COLOR=#000000]SetLegend[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]wrapLegend[/color][/b][COLOR=#990000]([/color][b][COLOR=#000000]sprintf[/color][/b][COLOR=#990000]([/color][COLOR=#FF0000]"%s-%s"[/color][COLOR=#990000],[/color][b][COLOR=#000000]ucfirst[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$types[/color][COLOR=#990000][[/color][COLOR=#009900]$i[/color][COLOR=#990000]-[/color][COLOR=#993399]1[/color][COLOR=#990000]]),[/color][b][COLOR=#000000]basename[/color][/b][COLOR=#990000]([/color][COLOR=#009900]$FileName[/color][COLOR=#990000],[/color] [COLOR=#FF0000]".csv"[/color][COLOR=#990000]))));[/color]
 
Thank you! I'll give it a try. I'm not sure how I can tell it to turn on or off a specific color since there is nothing I can find on which to build a conditional for the form's check boxes (maybe in the compact() function) but otherwise it looks perfect.

The color function also looks much better than what I have. There are no differences between Gr and Gb as both are green but from a plotting point of view, Gr would be the lighter colors that favor yellow while Gb would be darker and favor blue. There is another plot too that has even finer color distinctions but it's okay as it is for now.
 
You're right. There is no way to turn off a specific colour. But it is easy enough. Add a conditional after the beginning of the for loop. If the condition matches (eg exclude Gb) then do this
Code:
If (in_array($i, $excludes)) continue;
Where the $excludes variable is an array of which plot numbers to exclude (1-4).

Not sure how to fix the colours for different greens. Definitely change the format line to allow for gb and perhaps add some also add some blue to the gb format?
 
That might work. The values being submitted by the form are not numeric, though, and cannot be changed because they are being created automatically from the subform function. They are currently "Red", "Gr", "Gb" and "Blue".

The color function works perfectly. However, the plot on which I am working has two different greens and others plots have several greens and several different reds so I modified it slightly to feed in the $increment value. It helps but it still seems to start in the same place so some are not as far apart in color as they might be.

Code:
function getColor($type, $increment) {
	static $red = 255;
	static $green = 255;
	static $blue = 255;
	if(${$type} < 0) ${$type} = 255;
	$increment = (!$increment) ? 30: $increment;
	$format = $type == 'red' ? '#%02s0000' : ($type == 'green' ? '#00%02s00' : '#0000%02s');
	$col = sprintf($format, dechex(${$type}) ); 
	${$type} = ${$type} - $increment;
	return str_replace(' ','',$col);
}
 
Just use the $type map instead of $i on its own

Code:
If (in_array($type[$i-1],$exclusions)) continue;
 
I have not implimented the legend or other tweaks discussed after that but the code for dynamically creating a plot seems to work well. Thank you for that.

However, is there a way to make it even more dynamic where there is an unknown number of Y columns with the given that the first is the FileName and the second is the FileID? Is there a way to be able to choose whether Y is logrithmic or not? I see that it is including both line and scatter programming so can it be switched from line to scatter by a variable on demand?

I am thinking it might be useful for a new free-form query tool on the site. In other words, an engineer who knows SQL would be able to enter their own SELECT query (destructve queries are filtered out) and right now there is no way to know what result they may get in order to be able to properly plot it.

Also, the FileName value can be fed in as part of the query and does not need to be in its own separate query. Wehen I tried implimenting it in the existing programming, though, I was unable to fetch the field so that's why a secondary query was added.

Thanks again.
 
yes. you can make Y-axes logarithmic in the addY method.
and yes as well, you can make it dynamic by deriving the number of Y data-sets, probably during the query process, and then using that parameter in the for loop.
and yes again, you could grab the filename in a join but sometimes over-optimising queries leads to greater onus on manipulating the shape of the data for use later (i.e. the graphing) and you may not have optimised the tables well enough for the JOIN to be efficient, so actually be better off doing it as a separate query. For example there are ways to do month calendar queries in one go, but every time i've had to write calendar apps i've always ended up doing the event queries in a loop, one per day. simple queries are so fast that they are unlikely to be problematic for your application layer.
 
That's okay as this freeform query area has had me puzzled on what to do with the output. I could just write it to the screen and I am prodiding a way to download it as a CSV but I would really like to plot it too in a very generic way. Can you suggest how to make it accept an unknown number of columns with the assumption that the first two will be FileName and FileID?

As far as making it generic enough to replace those existing that are working, I don't have the time to do it anyway due to the end of the contract having been last Friday. I have a couple half-day weeks to take care of loose ends so getting the freeform query to plot is one of the goals for today and I know I can take care of the optional stuff via conditionals.

Thank you.
 
Yea, the engineer can use a form to type in any SELECT query they want so, of course, there is no way to know in advance which or how many columns will be in the result and the code you wrote is ideal as long as it can accept an unknown number of columns.
 
I assume you have logic in the system to prevent a non idempotent query from being submitted?
 
Yes, I mentioned that a couple postings ago where I said that "destructive queries are filtered out". Only SELECT statements will work.
 
destructive is not the same as non-idempotent. however if you've got the logic for this, then fine. I would go with an alternative login/password combo for the db when that routine is called, with the relevant login being given only limited select privileges.

I see very little way of creating an abstract graphing function based on a query over which we have no knowledge.

I suspect the better solution for this is to dump a csv of the query output and let the user model it in excel.

for the 'guided' query or a query where you can mandate the first n columns, please show a sample query and a few rows of sample output so that I can see how the modelling might work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top