की तरह ऐसा लगता है जैसे कि यह असंभव है अपने उदाहरण के साथ किया जाना चाहिए जिस पाठ को मैं GeoChart टूल के साथ करने का प्रयास कर रहा था, उस पाठ को प्रारूपित करें।
टूलटिप दृश्य के साथ गाया मानचित्र
पीएचपी & जावास्क्रिप्ट कोड
<!-- generate geo map -->
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', { 'packages': ['geochart'] });
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap()
{
// create data table
var data = google.visualization.arrayToDataTable([
<?php echo $data_table; ?>
]);
// create chart object
var chart = new google.visualization.GeoChart(
document.getElementById('chart_div')
);
// defines the data for the tooltip
var formatter = new google.visualization.PatternFormat('{0}');
formatter.format(data, [0,1], 1);
var formatter = new google.visualization.PatternFormat('{2}');
formatter.format(data, [0,1,2], 0);
// defines the data for the chart values
var view = new google.visualization.DataView(data);
view.setColumns([0, 1]);
// set options for this chart
var options =
{
width: <?php echo $width; ?>,
region: 'US',
resolution: 'provinces',
colorAxis: { colors: ['#abdfab', '#006600'] },
legend: 'none'
};
// draw chart
chart.draw(view, options);
};
</script>
<div id="chart_div" style="width: <?php echo $width; ?>px; height: <?php echo $height; ?>px;"></div>
गाया HTML: नीचे समाधान मैं अंत में के साथ आया था और गाया नक्शा है
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', { 'packages': ['geochart'] });
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap()
{
// create data table
var data = google.visualization.arrayToDataTable([
[ 'State', 'in', 'String' ],
[ 'Arizona', 2, 'Has Facility, Sells Direct' ],
[ 'California', 4, 'Has Facility, Has Distributor, Sells Direct' ],
[ 'Colorado', 1, 'Sells Direct' ],
[ 'Florida', 1, 'Has Distributor' ],
[ 'Georgia', 1, 'Has Distributor' ],
[ 'Idaho', 1, 'Sells Direct' ],
[ 'Illinois', 1, 'Has Distributor' ],
[ 'Indiana', 1, 'Has Distributor' ],
[ 'Iowa', 1, 'Has Distributor' ],
[ 'Kansas', 1, 'Has Distributor' ],
[ 'Kentucky', 1, 'Has Distributor' ],
[ 'Louisiana', 1, 'Has Distributor' ],
[ 'Maryland', 2, 'Has Distributor' ],
[ 'Montana', 1, 'Sells Direct' ],
[ 'Nevada', 2, 'Has Facility, Sells Direct' ],
[ 'New Mexico', 2, 'Has Facility, Sells Direct' ],
[ 'North Carolina', 1, 'Has Distributor' ],
[ 'North Dakota', 1, 'Has Distributor' ],
[ 'Oklahoma', 1, 'Sells Direct' ],
[ 'Oregon', 1, 'Sells Direct' ],
[ 'Pennsylvania', 1, 'Has Distributor' ],
[ 'South Carolina', 1, 'Has Distributor' ],
[ 'Tennessee', 1, 'Has Distributor' ],
[ 'Texas', 1, 'Has Distributor' ],
[ 'Utah', 2, 'Has Facility, Sells Direct' ],
[ 'Washington', 1, 'Sells Direct' ],
[ 'Wyoming', 1, 'Sells Direct' ], ]);
// create chart object
var chart = new google.visualization.GeoChart(
document.getElementById('chart_div')
);
// defines the data for the tooltip
var formatter = new google.visualization.PatternFormat('{0}');
formatter.format(data, [0,1], 1);
var formatter = new google.visualization.PatternFormat('{2}');
formatter.format(data, [0,1,2], 0);
// defines the data for the chart values
var view = new google.visualization.DataView(data);
view.setColumns([0, 1]);
// set options for this chart
var options =
{
width: 286,
region: 'US',
resolution: 'provinces',
colorAxis: { colors: ['#abdfab', '#006600'] },
legend: 'none'
};
// draw chart
chart.draw(view, options);
};
</script>
<div id="chart_div" style="width: 286px; height: 180px;"></div>
क्या आपको कोई विचार है कि टूलटिप के अंदर एक नई लाइन कैसे जोड़नी है? मैंने सामान्य '\ n \ r
'आदि –
को प्रारूप पाठ में एक नई लाइन या HTML जोड़ने में सक्षम नहीं किया है :( – fglez
मैं यह काम करने में सक्षम नहीं हूं। मेरा डेटासेट प्राप्त करने के लिए arrayToDataTable का भी उपयोग कर रहा है, लेकिन यह विधि मेरे लिए काम नहीं करती है। – mavili