2016-03-26 10 views
3

Bir grafik (Highcharts) üreten komut dosyası üzerinde çalışıyorum. Bu iş iyi ama tıklandığında tıklandığında aynı sitede başka bir scropt olan bir "tıklama" fonksiyonu eklemek istiyorum. Tıklanabilir sütunları okuduktan sonra nasıl çalıştığını bilmiyorum. Söyleyecek bir sütun tıklanabilir yapılan olacağını nasılHighcharts tıklanabilir sütun aynı sitede başka bir sayfa açmak için

google.com

Ben kodu: Zaman ayırdığınız için şimdiden

$(function() { 

var categories=[]; 
var data2 =[]; 


var chart; 
$(document).ready(function() { 

$.getJSON("../charts/imaint_audit_water_temp_cold_chart.php", function(json) { 
    $.each(json,function(i,el) { 
    if (el.name=="Count") 
     categories = el.data; 
    else data2.push(el); 
}); 

$('#container1').highcharts({ 
chart: { 
    renderTo: 'container', 
    type: 'column', 
    marginTop: 40, 
    marginRight: 30, 
    marginBottom: 50, 
    plotBackgroundColor: '#FCFFC5' 
}, 

title: { 
    text: 'Failed cold water temperatures', 
    x: -20, //center 
    style: { 
     fontFamily: 'Tahoma', 
     color: '#000000', 
     fontWeight: 'bold', 
     fontSize: '10px' 
    } 
}, 

subtitle: { 
    text: '', 
    x: -20 
}, 
xAxis: { 
    labels: { 
     enabled: false 
    } 
}, 

yAxis: { 
    showFirstLabel: false, 
    lineColor:'#999', 
    lineWidth:1, 
    tickColor:'#666', 
    tickWidth:1, 
    tickLength:2, 
    tickInterval: 10, 
    gridLineColor:'#ddd', 

    title: { 
     text: '', 
     style: { 
     fontFamily: 'Tahoma', 
     color: '#000000', 
     fontWeight: 'bold', 
     fontSize: '10px' 
     } 
    }, 

plotLines: [{ 
    color: '#808080' 
}] 
}, 

legend: { 
    enabled: true, 
    itemStyle: { 
     font: '11px Trebuchet MS, Verdana, sans-serif', 
     color: '#000000' 
    }, 
    itemHoverStyle: { 
     color: '#000000' 
    }, 
    itemHiddenStyle: { 
     color: '#444' 
    } 
}, 


colors: [ 
    '#0066CC', 
    '#FF2F2F', 
], 

plotOptions: { 
    series: { 
     point: { 
     events: { 
      click: function() { 

      } 
     } 
    } 
}, 
legendIndex:0, 

dataLabels: { 
enabled: true, 
color: '#000000', 
align: 'center', 
cursor: 'pointer', 
y: 0, // 10 pixels down from the top 
style: { 
    fontSize: '10px', 
    fontFamily: 'Verdana, sans-serif' 
} 
} 
} 
}, 

credits: { 
    enabled: false 
}, 

series: data2 
}); 
}); 

}); 
}); 

çok teşekkürler. İşte

cevap

2

açıklanmıştır: http://api.highcharts.com/highcharts#plotOptions.series.point.events.click

Her barda özel URL'sini içeren bunu başarabilir:

plotOptions: { 
      series: { 
       cursor: 'pointer', 
       point: { 
        events: { 
         click: function() { 
          location.href = this.options.url; 
         } 
        } 
       } 
      } 
     }, 

     series: [{ 
      data: [{ 
       y: 29.9, 
       url: 'http://bing.com/search?q=foo' 
      }, { 
       y: 71.5, 
       url: 'http://bing.com/search?q=bar' 
      }, { 
       y: 106.4, 
       url: 'http://bing.com/search?q=foo+bar' 
      }] 
     }] 

çalışma keman:

point: { 
        events: { 
         click: function() { 
          location.href = "http://stackoverflow.com"; 
         } 
        } 
       } 
:

veya hepsi aynı URL http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-point-events-click-url/

Umut eder!

GÜNCELLEME

bir çerçeve içinde ise, kullanarak deneyebilirsiniz:

window.top.location.href='URLGoesHere'; 
üst düzey çerçeve içinde

"_top" yükler içeriği (aslında, bütün tarayıcı penceresi) Geçerli çerçevesinin kaç yuvalanmış seviyesi olursa olsun

+0

Merhaba JP, bu tür yağlar için çok teşekkürler. İyi çalışıyor. Sahip olduğum tek isse, sayfanın iFrame içinde olması, böylece sayfanın iFrame'de yüklenebilmesi. URL'yi ebeveyne yüklemek için ne yapmam gerekir. Yine zaman için çok teşekkürler. – DCJones

+0

Rica ederim. Güncellemeye bakın, size yardımcı olabilir! –

+0

JP, mükemmel. Tekrar çok teşekkürler. – DCJones

İlgili konular