You must be logged in to post your query.
Home › Forums › Chart Support › PHP Charts & Graphs with Multiple Axes
Hi,
I want to use PHP Charts & Graphs with Multiple Axes for my project.
I have a problem adjusting my datapoint,
I need a dynamic array and I wrote it like this:
$dataPoints1 = array();
$n=33;
$m=34;
while($m<$max){
//for ($x=0; $x<$max; $x++) {
$dataPoints1[] = array(“x”=> $pieces[$n], “y”=> $pieces[$m]);
// }
$n=$n+11;
$m=$m+11;
}
print_r($dataPoints1);
original code looks like this:
$dataPoints1 = array(
array(“x”=> 0, “y”=> 0),
array(“x”=> 0.05, “y”=> 23), // immer plus 11
array(“x”=> 0.1, “y”=> 12),
array(“x”=> 0.15, “y”=> 12),
array(“x”=> 0.2, “y”=> 23),
array(“x”=> 0.25, “y”=> 24),
array(“x”=> 0.3, “y”=> 45),
array(“x”=> 0.35, “y”=> 45),
array(“x”=> 0.4, “y”=> 34),
array(“x”=> 0.45, “y”=> 67),
array(“x”=> 0.5, “y”=> 67),
array(“x”=> 0.55, “y”=> 43),
array(“x”=> 0.6, “y”=> 23),
array(“x”=> 0.65, “y”=> 12),
array(“x”=> 0.7, “y”=> 23),
array(“x”=> 0.75, “y”=> 34),
array(“x”=> 0.8, “y”=> 67),
array(“x”=> 0.85, “y”=> 90),
array(“x”=> 0.9, “y”=> 24),
array(“x”=> 0.95, “y”=> 78),
array(“x”=> 1, “y”=> 12),
array(“x”=> 1.05, “y”=> 90),
array(“x”=> 1.1, “y”=> 34),
array(“x”=> 1.15, “y”=> 45),
array(“x”=> 1.2, “y”=> 78),
);
wenn i put my datapoint in javascript part, is not working.
Please take a look at this gallery page for an example on creating chart with multiple axes in PHP.
If you are still facing the issue in creating a chart with multiple axes, kindly create a sample project reproducing the issue you are facing and share it with us over Google-Drive or Onedrive so that we can look into the code, understand the scenario better and help you out.
—
Shashi Ranjan
Team CanvasJS
datapoint1 is entered directly into this gallery. data is not fixed in my project, there is an input field, if you change the input, another graph is drawn.
So I need a dynamic array so that different datapoint is created each time.
i wrote a dynamic array but when i put that in javascript cod, plot is not drawn.
my dynamic Array:
$dataPoints1 = array();
$n=33;
$m=34;
while($m<$max){
//for ($x=0; $x<$max; $x++) {
$dataPoints1[] = array(“x”=> $pieces[$n], “y”=> $pieces[$m]);
// }
$n=$n+11;
$m=$m+11;
}
here again google Drive link from my project:
https://drive.google.com/drive/folders/1O8sS2gbRwaCqwfeSN-Pb3BPr18Rqv5cX?usp=sharing
best regard
Armin
https://drive.google.com/drive/folders/1O8sS2gbRwaCqwfeSN-Pb3BPr18Rqv5cX?usp=sharing
I put everything in an oedner again,
you have to open post.php and copy PN file content in structure
and click send button.
I need the same chart: (PHP Dynamic / Live Line Charts & Graphs) but without update.
regard
Armin
x-value can either be a numeric or a date-time object. Since the value being passed by you seems to be invalid (0 0.05 – there is a space between 0 & 0.05). Passing x-values in a valid number format based on your requirements should work fine in this case.
—
Shashi Ranjan
Team CanvasJS
thanks, how can i solve a problem, maybe you have an idea?
$pieces = explode(” “, $Result);
I use this command to convert string to array with space separation, but it takes 0 from last element end previous line with first number new line so I get 0 0.05
regard
Armin
Splitting string using the explode method before passing it to dataPoints should work fine in your case. Please take a look at this updated Sample Project.
—
Shashi Ranjan
Team CanvasJS
thanks, it worked but i have other problem, i have several graphs to show about 10 plot, what can i do?
regard
Armin
Please take a look at this documentation page for step-to-step tutorial on rendering multiple charts in a page.
—
Shashi Ranjan
Team CanvasJS
thanks, I have a question, can I use dropdown filters and if so, how can I do that?
regard
Armin
Updating chart options based on user selection and re-rendering it should work fine in this case. Please refer this documentation page for more information on updating chart options. Also take a look at this JSFiddle for updating dataPoints based on the value selected from the dropdown list.
—
Shashi Ranjan
Team CanvasJS
thanks Shashi, I still need to show Graf in Logarithmic, there is an example for Logarithmic but how can I use this for several Graf?
best regard
Armin
You can set the logarithmic property to true for changing the axis scale to a logarithmic. Please refer documentation page for more customization options available.
—
Shashi Ranjan
Team CanvasJS
You must be logged in to reply to this topic.