Entering edit mode
11 months ago
Muhammad
•
0
i have this type of database and I am using sql query to get the data and make graph by using chart js
Protein starve_th_37°C starve_th_49°C starve_th_58°C
P62424 1 0.437534765 0.214595311
Q13148 1 0.371686426 0.127905346
and I want to make line chart (three point connecting each other) for each row like
P62424 1 0.437534765 0.214595311
and
Q13148 1 0.371686426 0.127905346
now I have this code
$labels[] = $row['table_name'];
$labels[] = $row['protein'];
// $distChangeData[] = $row['Dist_change'];
// $dynamicSigData[] = $row['Dynamic_Sig'];
$starve0h37Data[] = $row['starve_0h_37'];
$starve0h49Data[] = $row['starve_0h_49'];
$starve0h58Data[] = $row['starve_0h_58'];
echo "<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: " . json_encode($labels) . ",
datasets: [
{
label: 'starve_0h_37°C',
data: " . json_encode($starve0h37Data) . ",
fill: false,
},
{
label: 'starve_0h_49°C',
data: " . json_encode($starve0h49Data) . ",
fill: false,
},
{
label: 'starve_0h_58°C',
data: " . json_encode($starve0h58Data) . ",
fill: false,
},
],
},
});
</script>";
but what I get article line on the side of graph container infect points not line now what I want two things
- line char of these three row points for each protein ? is it possible and how it can be done ?
- also the coulmn names on x axis starve_th_37°C starve_th_49°C starve_th_58°C?
Please help me or guide me the possible solution becuase as far as I know chart js takes data from database columns so I cannot make graph? Is there any possible solution?