当用户将鼠标悬停在amcharts4上时,每个系列都未显示单个工具提示,我该怎么做?

时间:2019-10-26 20:18:57

标签: amcharts amcharts4

我在amcharts4中有一个序列图,但是我很累在amcharts4中找到一个论点,当用户将鼠标悬停在序列上时,会在amcharts4中显示单个工具提示 哪个参数可以设置为将每个系列的鼠标悬停在系列上?

我的图表设置是:

<script>    
am4core.ready(function() {

am4core.useTheme(am4themes_animated);
// Themes end

// Create chart instance
var chart = am4core.create("test1div", am4charts.XYChart);

// Increase contrast by taking evey second color
chart.colors.step = 2;

// Set up data source
chart.dataSource.url ="/static/json/DATA.json";
chart.dataSource.parser = new am4core.JSONParser();
chart.dateFormatter.inputDateFormat = "i";    

// Create axes
var dateAxis = chart.xAxes.push(new am4charts.DateAxis());
dateAxis.renderer.labels.template.location = 0;
dateAxis.renderer.minGridDistance = 20;
dateAxis.renderer.grid.template.location = 0.5;
dateAxis.startLocation = 0.5;
dateAxis.endLocation = 0.5;
dateAxis.dateFormats.setKey("hour", "YYYY/MM/dd hh:mm");
dateAxis.periodChangeDateFormats.setKey("hour", "YYYY/MM/dd hh:mm");
dateAxis.tooltipDateFormat = "YYYY/MM/dd HH:mm";

var valueAxis1 = chart.yAxes.push(new am4charts.ValueAxis());

function createAxisAndSeries(field, name) {
    var series = chart.series.push(new am4charts.LineSeries());
        series.dataFields.valueY = field;
        series.dataFields.dateX = "DATETIME";
        series.strokeWidth = 2;
        series.yAxis = valueAxis1;
        series.name = name;
        series.tooltipText = "{name}: [bold]{valueY}[/]";
        series.tensionX = 0.9;
        series.tensionY = 0.9;
    valueAxis1.renderer.line.strokeOpacity = 1;
    valueAxis1.renderer.line.strokeWidth = 2;
    valueAxis1.renderer.grid.template.disabled = false;
    valueAxis1.cursorTooltipEnabled = true;
    valueAxis1.tooltip.disabled = true;
    valueAxis1.getFillFromObject = false;
}

createAxisAndSeries{"testseries1","testseries1"};
createAxisAndSeries{"testseries2","testseries2"};

   }); 
</script>

0 个答案:

没有答案