[JS]
$("#container").ejChart(
{
trackToolTip:"onTrackballRendering"
});
function onTrackballRendering(sender){
if(sender.data.Series.name == "Japan" && sender.data.serIndex == 2){
sender.cancel = true;
}
}
|
many thanks Saravana for your reply,
One more question could it be possible to remove also the circle that appears over the series that is not displayed in the trackball?
[JS]
$("#container").ejChart(
{
trackToolTip:"onTrackballRendering"
}
var markerElement, markerId,seriesIndex;
function onTrackballRendering(sender){
var chart = $("#container").ejChart("instance");
if(sender.data.Series.name == "Japan" && sender.data.serIndex == 2) {
sender.cancel = true;
seriesIndex = sender.data.serIndex;
}
markerId = "container_svg_TrackSymbol_" + seriesIndex + "_" + sender.data.pointIndex;
if(!(ej.isNullOrUndefined(markerId))){
for(var i=0;i< chart.gTrackball.childElementCount;i++){
var trackElement = chart.gTrackball.childNodes[i];
(trackElement.id == markerId) ? trackElement.remove() : "" ;
}
}
}
|
[JS]
$("#container").ejChart(
{
trackToolTip:"onTrackballRendering"
}
var markerElement, markerId, markerClipId;
function onTrackballRendering(sender){
var seriesIndex;
var chart = $("#container").ejChart("instance");
if(sender.data.Series.name == "Japan" && sender.data.serIndex == 2) {
sender.cancel = true;
seriesIndex = sender.data.serIndex;
}
if(!(ej.isNullOrUndefined(seriesIndex))){
markerId = "container_svg_Series" + seriesIndex + "_Point" + sender.data.pointIndex +"_symbol";
var markerElement = document.getElementById(markerId);
markerClipId = "container_svg_TrackSymbol_" + seriesIndex + "_" + sender.data.pointIndex;
for(var j = 0; j < markerElement.parentElement.childElementCount;j++){
var currentElement = markerElement.parentElement.children[j];
currentElement.style.display= (currentElement.id == markerId) ? "none" : "block";
}
for(var i=0;i< chart.gTrackball.childElementCount;i++){
var trackElement = chart.gTrackball.childNodes[i];
(trackElement.id == markerClipId) ? trackElement.remove() : "" ;
}
}
}
|
Thanks Saravana, your support is priceless.
I'm not able to make it work on my implementation, as I get an undefined object error at line:
for (var i = 0; i < chart.gTrackball.childElementCount; i++) {
gTackball is undefined.
I've tried to make the two example as similar as possible but on mine doesn't work, maybe some configuration that generates a conflict.
Effectively, inspecting the chart object I don't see any gTrackball member.
Here is the playground where you can see the issue at line 235:
http://jsplayground.syncfusion.com/231ie1es
[JS]
$("#chart").ejChart({
trackToolTip: 'onTrackballRendering'
}
function onTrackballRendering(sender) {
var chart = $("#chart").ejChart("instance");
if (sender.data.Series.name != '"2017"' && sender.data.Series.name != '"average"') {
sender.cancel = true;
seriesIndex = sender.data.serIndex;
}
markerId = (chart.model.enableCanvasRendering) ? "chart_canvas_trackSymbol_" + seriesIndex + "_" + sender.data.pointIndex : "chart_svg_TrackSymbol_" + seriesIndex + "_" + sender.data.pointIndex;
var trackElement;
if (!chart.model.enableCanvasRendering) {
if (!(ej.isNullOrUndefined(seriesIndex))) {
for (var i = 0; i < chart.gTrackball.childElementCount; i++) {
trackElement = chart.gTrackball.childNodes[i];
(trackElement.id == markerId) ? trackElement.remove() : "";
}
}
} else {
trackElement = document.getElementById(markerId);
trackElement.style.visibility = "hidden";
}
}
|
Many thanks Saravana.
The example works fine but as you can see from the playground the labels keep their "original" position, therefore, due to the high number of series, they look like they are misplaced. Sometimes they are never displayed as they go outside of the chart area.
Is there a way to change their positions?
JS:
$("#chart").ejChart({
//...
trackToolTip: 'onTrackballRendering',
});
function onTrackballRendering(sender) {
//Removed default tooltip
sender.cancel = true;
//Added tooltip with respect to series
if(sender.data.Series.name == '"2017"') {
ele.fillStyle =sender.data.Series.fill;
ele.fillRect(sender.model.m_AreaBounds.Width/2,sender.model.m_AreaBounds.Height/3,80, 30);
ele.fillStyle ="white";
ele.fillText(sender.data.currentText, sender.model.m_AreaBounds.Width/2 +
padding,sender.model.m_AreaBounds.Height/3 + 20);
ele.font = "11px Segoe UI";
ele.textAlign = "center";
ele.stroke();
}
else if (sender.data.Series.name == '"average"') {
ele.fillStyle = sender.data.Series.fill;
ele.fillRect(sender.model.m_AreaBounds.Width/2,sender.model.m_AreaBounds.Height/2,80, 30);
ele.fillStyle ="white"
ele.font = "11px Segoe UI";
ele.textAlign = "center";
ele.fillText(sender.data.currentText, sender.model.m_AreaBounds.Width/2 + padding
,sender.model.m_AreaBounds.Height/2+20 );
ele.stroke();
}
} |