MikeOscarEcho
MikeOscarEcho

Reputation: 548

highcharts pulling data from database table

Demo of what I'm working with: http://jsfiddle.net/98Fuq/4/

I've got Job Numbers displaying on the x-axis using

$sql = "SELECT * FROM view_job_budgetreport";
$result = mysqli_query($dbc3, $sql);
while($row = mysqli_fetch_assoc($result)) {
    $jobNum[] = $row['Job_Num'];
}

Then in my code:

var colors = Highcharts.getOptions().colors,
categories = [<?php echo join($jobNum, ',') ?>], //I display the job nums here
name = '% of budgeted hours',
level = 0,
data = [{
      y: 300,
      color: colors[0],
      drilldown: {
         name: 'Job # Detailed Overview',
         categories: ['Surfacing', 'Design', 'Details', 'Ejector', 'EDM', 'GD/BM', 'CNC', 'Mold Making', 'Spotting', 'Spotting Line', 'Handwork', 'Tryout'  ],
         level: 1,
         data: [{
             y: 30,
             drilldown: {
                 level: 2,
                 name: 'Job # Machining Overview',
                 categories: ['CNC 1', 'CNC 2', 'CNC 3', 'CNC4', 'Gun Drill 1', 'Gun Drill 2', 'Boring Mill 1', 'Boring Mill 2', 'EDM 1', 'EDM 2', 'EDM 3'],
                 data: [23,54,47, 58, 42, 10, 34, 78, 10, 55, 25],
                 color: colors[3]
             }
         }, 40, 7.35, 2.41, 200, 100, 50, 75, 86, 95, 75, 25],
         color: colors[2]
      }
   }

Now that part works well however I can't for the life of me figure out level 2 and 3 of the drilldown. I've tried using the same method as I used for Job Numbers.

Table structure:

Table Structure

Upvotes: 0

Views: 440

Answers (1)

Volkan Ulukut
Volkan Ulukut

Reputation: 4218

change your php like this, so you got all values you need;

$sql = "SELECT * FROM view_job_budgetreport";
$result = mysqli_query($dbc3, $sql);
while($row = mysqli_fetch_assoc($result)) {
    $jobNum[] = $row['Job_Num'];
    $jobData[$row['Job_Num']] = $row['Job_Y'];
    $jobDrillData[$row['Job_Num']][] = $row;
}

and then loop these variable in highcharts

Upvotes: 1

Related Questions