0
私はReactにとってかなり新しいです。 私のリアクションWebアプリケーションにd3マップがあります。クリックイベントをmap.Couldに添付する必要があります。私はこのマップにクリックを添付する方法を教えてください。svg要素にイベントリスナーをアタッチする
const County = ({geoPath,feature}) => (
//<path d={geoPath(feature)} style={{fill: color}} title={feature.id} />
<path d={geoPath(feature)} style={{fill: color(Math.random()*5)}} title={feature.id} />
);
----------
render(){
if(!this.props.usTopoJson){
return null;
}else{
let color = 'rgb(42,73,120)';
//let color = 'orange';
const us = this.props.usTopoJson,
statesMesh=topojson.mesh(us,us.objects.countries.geometries,(a,b) => a !==b),
countries = topojson.feature(us,us.objects.countries).features;
return(
//<g>
<g ref={(g) => { this.myG = g; }}>
{countries.map((feature) =>
<County geoPath={this.geoPath}
feature={feature}
key={feature.id}
quantize={this.quantize} />)}
<path d={this.geoPath(statesMesh)} style={{fill:'color',stroke:'#aaa',
strokeLinejoin:'round'}}/>
</g>
);
}
}
あなたは '' の属性として 'onClick'を追加してみました –
DroidNoob