Fixed there are many bullet charts in one page (such as dashboard). TICKET: #3187

(cherry picked from commit 11f9f2ec3295289f2e05628d18ab2e4d8d401181)
This commit is contained in:
mdtrooper 2016-01-11 15:18:13 +01:00
parent a5f8a9ca24
commit ed78a4e44f

View File

@ -144,16 +144,18 @@ function d3_sunburst_graph ($data, $width = 700, $height = 700, $return = false)
function d3_bullet_chart($chart_data, $width, $height, $color, $legend, function d3_bullet_chart($chart_data, $width, $height, $color, $legend,
$homeurl, $unit, $font, $font_size) { $homeurl, $unit, $font, $font_size) {
global $config; global $config;
$output = ''; $output = '';
$output .= include_javascript_d3(true); $output .= include_javascript_d3(true);
$id_bullet = uniqid();
$output .= $output .=
'<div id="bullet_graph" style="overflow: hidden;"></div> '<div id="bullet_graph_' . $id_bullet . '" class="bulle" style="overflow: hidden;"></div>
<style> <style>
#bullet_graph { .bullet_graph {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: auto; margin: auto;
padding-top: 40px; padding-top: 40px;
@ -211,7 +213,7 @@ function d3_bullet_chart($chart_data, $width, $height, $color, $legend,
'; ';
$output .= ' $output .= '
var svg = d3.select("#bullet_graph").selectAll("svg") var svg = d3.select("#bullet_graph_' . $id_bullet . '").selectAll("svg")
.data(data) .data(data)
.enter().append("svg") .enter().append("svg")
.attr("class", "bullet") .attr("class", "bullet")