【问题标题】:AmCharts4 Remove Continent(s) in a MapChartAmCharts 4 在 MapChart 中删除 Continent(is)
【发布时间】:2021-04-13 13:56:19
【问题描述】:

我正在使用@amcharts/amcharts4-geodata/worldLow" 创建一个简单的地图,但不需要南极洲。有没有办法隐藏或移除它,但要让地图利用南极洲留下的空间来使地图相应地调整,让其他大陆更加突出?

初始化代码:

import * as am4maps from "@amcharts/amcharts4/maps";
import am4geodata_worldLow from "@amcharts/amcharts4-geodata/worldLow";
import am4themes_animated from "@amcharts/amcharts4/themes/animated";

let chart = am4core.create("globediv", am4maps.MapChart);

try {
    chart.geodata = am4geodata_worldLow;
} catch (e) {
  chart.raiseCriticalError(new Error("Map geodata could not be loaded."));
}

chart.projection = new am4maps.projections.Projection;
chart.panBehavior = "move";

let polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
polygonSeries.data = myData;
polygonSeries.useGeodata = true;

【问题讨论】:

    标签: amcharts amcharts4


    【解决方案1】:

    按照文档中的here 使用polygonSeries 中的exclude 属性

    polygonSeries.exclude = ["AQ"];
    

    let chart = am4core.create("chartdiv", am4maps.MapChart);
    
    try {
      chart.geodata = am4geodata_worldLow;
    } catch (e) {
      chart.raiseCriticalError(new Error("Map geodata could not be loaded."));
    }
    
    chart.projection = new am4maps.projections.Miller();
    chart.panBehavior = "move";
    
    let polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
    polygonSeries.useGeodata = true;
    polygonSeries.exclude = ["AQ"];
    #chartdiv {
      width: 100%;
      height: 400px;
     }
    <script src="https://cdn.amcharts.com/lib/4/core.js"></script>
    <script src="https://cdn.amcharts.com/lib/4/maps.js"></script>
    <script src="https://cdn.amcharts.com/lib/4/geodata/worldLow.js"></script>
    <div id="chartdiv"></div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-08
      • 2017-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多