如何从动态图表删除行

时间:2019-08-14 06:10:06

标签: amcharts

我想动态从amcharts地图中删除线。我可以动态添加行,但不能动态删除行

var chart = am4core.create("chartdiv", am4maps.MapChart);
chart.geodata = am4geodata_worldLow;
                chart.projection = new am4maps.projections.Miller();
                var markerPoints = [];
                // Create map polygon series
                var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
                polygonSeries.useGeodata = true;
                polygonSeries.mapPolygons.template.fill = chart.colors.getIndex(0).lighten(0.5);
                polygonSeries.mapPolygons.template.nonScalingStroke = true;
                polygonSeries.exclude = ["AQ"];
 var points = chart.series.push(new am4maps.MapImageSeries());

                points.mapImages.template.nonScaling = true;
                var marker = points.mapImages.template.createChild(am4core.Circle);
                marker.radius = 1;
                marker.fill = am4core.color("yellow");
                marker.strokeWidth = 0;
                marker.stroke = am4core.color("yellow");
                marker.tooltipText = '{title}';
                points.mapImages.template.propertyFields.latitude = "latitude";
                points.mapImages.template.propertyFields.longitude = "longitude";
function addPoint(coords, title) { // this is function to add points on map
                    var marker = points.mapImages.create();
                    marker.latitude = coords.latitude;
                    marker.longitude = coords.longitude;
                    return marker;
                }

                var paris = addPoint({ "latitude": 48.8567, "longitude": 2.3510 }, "Paris");
                var toronto = addPoint({ "latitude": 43.8163, "longitude": -79.4287 }, "Toronto");

var lineSeries = chart.series.push(new am4maps.MapArcSeries());
                lineSeries.mapLines.template.line.strokeWidth = 2;
                lineSeries.mapLines.template.line.strokeOpamarker = 0.5;
                lineSeries.mapLines.template.line.stroke = marker.fill;
                lineSeries.mapLines.template.line.nonScalingStroke = true;
                lineSeries.mapLines.template.line.strokeDasharray = "1,5";

                function addLine(from, to) {
                    var line = lineSeries.mapLines.create();
                    line.imagesToConnect = [from, to];
                    line.line.controlPointDistance = -0.3;
                    return line;
                }

                addLine(paris, toronto);
                setInterval(function(){
                addLine(somePoint,somePoint);
                removeLine()//how to implement this one 
                },1000);

我想实现一个函数或代码行,以删除setInterval中已绘制的行。.

1 个答案:

答案 0 :(得分:0)

对于子弹var bulletAttack = bullet.createChild(am4core.Sprite);,我使用:

bullet.hide();    
bullet.kill();

也许会对您有所帮助。