AMCharts 4 - Map stroke uneven when applied to single countries The Next CEO of Stack OverflowValue of selected country amchartsamCharts center mapAmchart dynamically load maps with scrollTo colored the particular country using amcharts using country nameAMcharts Map in angular jsHow to make a world map with clickable countries in AMcharts?Page is reloading when using 'LinkToObject' in amChart MapHover group of countries instead of single one on Amcharts 4AmCharts maps - how to get only 2 first letters of country name?Exclude countries dynamically amCharts

Won the lottery - how do I keep the money?

sp_blitzCache results Memory grants

Indicator light circuit

Why don't programming languages automatically manage the synchronous/asynchronous problem?

What's the best way to handle refactoring a big file?

Is micro rebar a better way to reinforce concrete than rebar?

Is 'diverse range' a pleonastic phrase?

How do I transpose the 1st and -1th levels of an arbitrarily nested array?

Sending manuscript to multiple publishers

Why do remote companies require working in the US?

Complex fractions

Does it take more energy to get to Venus or to Mars?

What happens if you roll doubles 3 times then land on "Go to jail?"

How do we know the LHC results are robust?

Unreliable Magic - Is it worth it?

How does the Z80 determine which peripheral sent an interrupt?

What does convergence in distribution "in the Gromov–Hausdorff" sense mean?

How do I reset passwords on multiple websites easily?

What benefits would be gained by using human laborers instead of drones in deep sea mining?

Inappropriate reference requests from Journal reviewers

Bold, vivid family

Can I equip Skullclamp on a creature I am sacrificing?

MessageLevel in QGIS3

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?



AMCharts 4 - Map stroke uneven when applied to single countries



The Next CEO of Stack OverflowValue of selected country amchartsamCharts center mapAmchart dynamically load maps with scrollTo colored the particular country using amcharts using country nameAMcharts Map in angular jsHow to make a world map with clickable countries in AMcharts?Page is reloading when using 'LinkToObject' in amChart MapHover group of countries instead of single one on Amcharts 4AmCharts maps - how to get only 2 first letters of country name?Exclude countries dynamically amCharts










2















enter image description here



As you can see in the above image. I've applied a stroke to the USA. However the top of the mainland stroke is clearly thinner than the rest of the stroke. My config is below:



 polygonTemplate.stroke = am4core.color('#2c2626')
polygonTemplate.strokeWidth = 0
polygonTemplate.nonScalingStroke = true


And then I have an adaptor to stroke the active country,



polygonTemplate.adapter.add('strokeWidth', (stroke, target) => 
if (target.dataItem && target.dataItem.dataContext && this.selectedCountry)
if (target.dataItem.dataContext.id === this.selectedCountry.id)
return 2


return stroke
)


From what I can find from examples online, this is the right way to apply a stroke. Is there a way I can make this stroke even all around the country? It happens on most countries but there are a few where it's not as bad..



EDIT: Thanks to Sam for his help, I now have an even stroke. But it seems I've got to press on a new country twice for it to take the active state - once to toggle the old country to inactive, then once again to add the active state. GIF below



enter image description here










share|improve this question




























    2















    enter image description here



    As you can see in the above image. I've applied a stroke to the USA. However the top of the mainland stroke is clearly thinner than the rest of the stroke. My config is below:



     polygonTemplate.stroke = am4core.color('#2c2626')
    polygonTemplate.strokeWidth = 0
    polygonTemplate.nonScalingStroke = true


    And then I have an adaptor to stroke the active country,



    polygonTemplate.adapter.add('strokeWidth', (stroke, target) => 
    if (target.dataItem && target.dataItem.dataContext && this.selectedCountry)
    if (target.dataItem.dataContext.id === this.selectedCountry.id)
    return 2


    return stroke
    )


    From what I can find from examples online, this is the right way to apply a stroke. Is there a way I can make this stroke even all around the country? It happens on most countries but there are a few where it's not as bad..



    EDIT: Thanks to Sam for his help, I now have an even stroke. But it seems I've got to press on a new country twice for it to take the active state - once to toggle the old country to inactive, then once again to add the active state. GIF below



    enter image description here










    share|improve this question


























      2












      2








      2


      0






      enter image description here



      As you can see in the above image. I've applied a stroke to the USA. However the top of the mainland stroke is clearly thinner than the rest of the stroke. My config is below:



       polygonTemplate.stroke = am4core.color('#2c2626')
      polygonTemplate.strokeWidth = 0
      polygonTemplate.nonScalingStroke = true


      And then I have an adaptor to stroke the active country,



      polygonTemplate.adapter.add('strokeWidth', (stroke, target) => 
      if (target.dataItem && target.dataItem.dataContext && this.selectedCountry)
      if (target.dataItem.dataContext.id === this.selectedCountry.id)
      return 2


      return stroke
      )


      From what I can find from examples online, this is the right way to apply a stroke. Is there a way I can make this stroke even all around the country? It happens on most countries but there are a few where it's not as bad..



      EDIT: Thanks to Sam for his help, I now have an even stroke. But it seems I've got to press on a new country twice for it to take the active state - once to toggle the old country to inactive, then once again to add the active state. GIF below



      enter image description here










      share|improve this question
















      enter image description here



      As you can see in the above image. I've applied a stroke to the USA. However the top of the mainland stroke is clearly thinner than the rest of the stroke. My config is below:



       polygonTemplate.stroke = am4core.color('#2c2626')
      polygonTemplate.strokeWidth = 0
      polygonTemplate.nonScalingStroke = true


      And then I have an adaptor to stroke the active country,



      polygonTemplate.adapter.add('strokeWidth', (stroke, target) => 
      if (target.dataItem && target.dataItem.dataContext && this.selectedCountry)
      if (target.dataItem.dataContext.id === this.selectedCountry.id)
      return 2


      return stroke
      )


      From what I can find from examples online, this is the right way to apply a stroke. Is there a way I can make this stroke even all around the country? It happens on most countries but there are a few where it's not as bad..



      EDIT: Thanks to Sam for his help, I now have an even stroke. But it seems I've got to press on a new country twice for it to take the active state - once to toggle the old country to inactive, then once again to add the active state. GIF below



      enter image description here







      maps amcharts






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 16:23







      Josh Undefined

















      asked Mar 7 at 15:14









      Josh UndefinedJosh Undefined

      60911119




      60911119






















          1 Answer
          1






          active

          oldest

          votes


















          2














          The Problem is, that the bordering countries are overlapping the stroke of your selected country. I increased the strokeWidth to 10 and set the fillOpacity to 0.6. You can clearly see that in the following picture or in that code pen.



          example image



          Also setting the zIndex in an adapter doesn't change anything for me.



          But you can use states:



          Create an active (or a custom) state with the properties you want to use. You can also use zIndex there. Now set that state to every country you want to highlight.



          var polygonTemplate = polygonSeries.mapPolygons.template;
          polygonTemplate.tooltipText = "name";
          polygonTemplate.fillOpacity = 0.6;
          polygonTemplate.stroke = am4core.color('#2c2626');
          polygonTemplate.strokeWidth = 0;
          polygonTemplate.zIndex = 0;
          polygonTemplate.nonScalingStroke = true;

          // Create active state
          var activeState = polygonTemplate.states.create("active");
          activeState.properties.strokeWidth = 10;
          activeState.properties.zIndex = 1;

          // Create an event to toggle "active" statestate
          polygonTemplate.events.on("hit", function(ev)
          ev.target.isActive = !ev.target.isActive;
          console.log(ev.target.dataItem.dataContext.id);
          );

          chart.events.once('inited', event =>
          polygonSeries.mapPolygons.values.find(i => i.dataItem.dataContext.id === 'US').isActive = true;
          );


          Here is the result:



          example image



          This code pen shows the states example. Hope that helps.



          EDIT:



          To use double click to toggle the active state you can just replace the hit event with the doublehit event (docs). But you maybe want to disable zoom on double click now. That's possible with the following lines (docs):



          chart.seriesContainer.events.disableType("doublehit");
          chart.chartContainer.background.events.disableType("doublehit");


          I created this code pen to show you an example.






          share|improve this answer

























          • Hey thanks for this. It seems to be working, however i need to press countries twice for the active state to trigger. Any thoughts?

            – Josh Undefined
            Mar 8 at 11:59












          • You can just replace the hit event with doublehit. I updated my answer according to that and included a code pen.

            – Samuel Philipp
            Mar 8 at 15:02











          • Ah I'm sorry Sam, perhaps I was not clear - I've edited my OP to include a gif of what is happening. But basically it seems like I've got to click once to toggle off the active state from one country, then click again to add it to the new country.

            – Josh Undefined
            Mar 8 at 16:21











          • Nevermind! It was my only computed function in vue which was destroying the active prop AMcharts makes :)

            – Josh Undefined
            Mar 8 at 16:35











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047122%2famcharts-4-map-stroke-uneven-when-applied-to-single-countries%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          The Problem is, that the bordering countries are overlapping the stroke of your selected country. I increased the strokeWidth to 10 and set the fillOpacity to 0.6. You can clearly see that in the following picture or in that code pen.



          example image



          Also setting the zIndex in an adapter doesn't change anything for me.



          But you can use states:



          Create an active (or a custom) state with the properties you want to use. You can also use zIndex there. Now set that state to every country you want to highlight.



          var polygonTemplate = polygonSeries.mapPolygons.template;
          polygonTemplate.tooltipText = "name";
          polygonTemplate.fillOpacity = 0.6;
          polygonTemplate.stroke = am4core.color('#2c2626');
          polygonTemplate.strokeWidth = 0;
          polygonTemplate.zIndex = 0;
          polygonTemplate.nonScalingStroke = true;

          // Create active state
          var activeState = polygonTemplate.states.create("active");
          activeState.properties.strokeWidth = 10;
          activeState.properties.zIndex = 1;

          // Create an event to toggle "active" statestate
          polygonTemplate.events.on("hit", function(ev)
          ev.target.isActive = !ev.target.isActive;
          console.log(ev.target.dataItem.dataContext.id);
          );

          chart.events.once('inited', event =>
          polygonSeries.mapPolygons.values.find(i => i.dataItem.dataContext.id === 'US').isActive = true;
          );


          Here is the result:



          example image



          This code pen shows the states example. Hope that helps.



          EDIT:



          To use double click to toggle the active state you can just replace the hit event with the doublehit event (docs). But you maybe want to disable zoom on double click now. That's possible with the following lines (docs):



          chart.seriesContainer.events.disableType("doublehit");
          chart.chartContainer.background.events.disableType("doublehit");


          I created this code pen to show you an example.






          share|improve this answer

























          • Hey thanks for this. It seems to be working, however i need to press countries twice for the active state to trigger. Any thoughts?

            – Josh Undefined
            Mar 8 at 11:59












          • You can just replace the hit event with doublehit. I updated my answer according to that and included a code pen.

            – Samuel Philipp
            Mar 8 at 15:02











          • Ah I'm sorry Sam, perhaps I was not clear - I've edited my OP to include a gif of what is happening. But basically it seems like I've got to click once to toggle off the active state from one country, then click again to add it to the new country.

            – Josh Undefined
            Mar 8 at 16:21











          • Nevermind! It was my only computed function in vue which was destroying the active prop AMcharts makes :)

            – Josh Undefined
            Mar 8 at 16:35















          2














          The Problem is, that the bordering countries are overlapping the stroke of your selected country. I increased the strokeWidth to 10 and set the fillOpacity to 0.6. You can clearly see that in the following picture or in that code pen.



          example image



          Also setting the zIndex in an adapter doesn't change anything for me.



          But you can use states:



          Create an active (or a custom) state with the properties you want to use. You can also use zIndex there. Now set that state to every country you want to highlight.



          var polygonTemplate = polygonSeries.mapPolygons.template;
          polygonTemplate.tooltipText = "name";
          polygonTemplate.fillOpacity = 0.6;
          polygonTemplate.stroke = am4core.color('#2c2626');
          polygonTemplate.strokeWidth = 0;
          polygonTemplate.zIndex = 0;
          polygonTemplate.nonScalingStroke = true;

          // Create active state
          var activeState = polygonTemplate.states.create("active");
          activeState.properties.strokeWidth = 10;
          activeState.properties.zIndex = 1;

          // Create an event to toggle "active" statestate
          polygonTemplate.events.on("hit", function(ev)
          ev.target.isActive = !ev.target.isActive;
          console.log(ev.target.dataItem.dataContext.id);
          );

          chart.events.once('inited', event =>
          polygonSeries.mapPolygons.values.find(i => i.dataItem.dataContext.id === 'US').isActive = true;
          );


          Here is the result:



          example image



          This code pen shows the states example. Hope that helps.



          EDIT:



          To use double click to toggle the active state you can just replace the hit event with the doublehit event (docs). But you maybe want to disable zoom on double click now. That's possible with the following lines (docs):



          chart.seriesContainer.events.disableType("doublehit");
          chart.chartContainer.background.events.disableType("doublehit");


          I created this code pen to show you an example.






          share|improve this answer

























          • Hey thanks for this. It seems to be working, however i need to press countries twice for the active state to trigger. Any thoughts?

            – Josh Undefined
            Mar 8 at 11:59












          • You can just replace the hit event with doublehit. I updated my answer according to that and included a code pen.

            – Samuel Philipp
            Mar 8 at 15:02











          • Ah I'm sorry Sam, perhaps I was not clear - I've edited my OP to include a gif of what is happening. But basically it seems like I've got to click once to toggle off the active state from one country, then click again to add it to the new country.

            – Josh Undefined
            Mar 8 at 16:21











          • Nevermind! It was my only computed function in vue which was destroying the active prop AMcharts makes :)

            – Josh Undefined
            Mar 8 at 16:35













          2












          2








          2







          The Problem is, that the bordering countries are overlapping the stroke of your selected country. I increased the strokeWidth to 10 and set the fillOpacity to 0.6. You can clearly see that in the following picture or in that code pen.



          example image



          Also setting the zIndex in an adapter doesn't change anything for me.



          But you can use states:



          Create an active (or a custom) state with the properties you want to use. You can also use zIndex there. Now set that state to every country you want to highlight.



          var polygonTemplate = polygonSeries.mapPolygons.template;
          polygonTemplate.tooltipText = "name";
          polygonTemplate.fillOpacity = 0.6;
          polygonTemplate.stroke = am4core.color('#2c2626');
          polygonTemplate.strokeWidth = 0;
          polygonTemplate.zIndex = 0;
          polygonTemplate.nonScalingStroke = true;

          // Create active state
          var activeState = polygonTemplate.states.create("active");
          activeState.properties.strokeWidth = 10;
          activeState.properties.zIndex = 1;

          // Create an event to toggle "active" statestate
          polygonTemplate.events.on("hit", function(ev)
          ev.target.isActive = !ev.target.isActive;
          console.log(ev.target.dataItem.dataContext.id);
          );

          chart.events.once('inited', event =>
          polygonSeries.mapPolygons.values.find(i => i.dataItem.dataContext.id === 'US').isActive = true;
          );


          Here is the result:



          example image



          This code pen shows the states example. Hope that helps.



          EDIT:



          To use double click to toggle the active state you can just replace the hit event with the doublehit event (docs). But you maybe want to disable zoom on double click now. That's possible with the following lines (docs):



          chart.seriesContainer.events.disableType("doublehit");
          chart.chartContainer.background.events.disableType("doublehit");


          I created this code pen to show you an example.






          share|improve this answer















          The Problem is, that the bordering countries are overlapping the stroke of your selected country. I increased the strokeWidth to 10 and set the fillOpacity to 0.6. You can clearly see that in the following picture or in that code pen.



          example image



          Also setting the zIndex in an adapter doesn't change anything for me.



          But you can use states:



          Create an active (or a custom) state with the properties you want to use. You can also use zIndex there. Now set that state to every country you want to highlight.



          var polygonTemplate = polygonSeries.mapPolygons.template;
          polygonTemplate.tooltipText = "name";
          polygonTemplate.fillOpacity = 0.6;
          polygonTemplate.stroke = am4core.color('#2c2626');
          polygonTemplate.strokeWidth = 0;
          polygonTemplate.zIndex = 0;
          polygonTemplate.nonScalingStroke = true;

          // Create active state
          var activeState = polygonTemplate.states.create("active");
          activeState.properties.strokeWidth = 10;
          activeState.properties.zIndex = 1;

          // Create an event to toggle "active" statestate
          polygonTemplate.events.on("hit", function(ev)
          ev.target.isActive = !ev.target.isActive;
          console.log(ev.target.dataItem.dataContext.id);
          );

          chart.events.once('inited', event =>
          polygonSeries.mapPolygons.values.find(i => i.dataItem.dataContext.id === 'US').isActive = true;
          );


          Here is the result:



          example image



          This code pen shows the states example. Hope that helps.



          EDIT:



          To use double click to toggle the active state you can just replace the hit event with the doublehit event (docs). But you maybe want to disable zoom on double click now. That's possible with the following lines (docs):



          chart.seriesContainer.events.disableType("doublehit");
          chart.chartContainer.background.events.disableType("doublehit");


          I created this code pen to show you an example.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 8 at 15:01

























          answered Mar 8 at 8:57









          Samuel PhilippSamuel Philipp

          3,2591627




          3,2591627












          • Hey thanks for this. It seems to be working, however i need to press countries twice for the active state to trigger. Any thoughts?

            – Josh Undefined
            Mar 8 at 11:59












          • You can just replace the hit event with doublehit. I updated my answer according to that and included a code pen.

            – Samuel Philipp
            Mar 8 at 15:02











          • Ah I'm sorry Sam, perhaps I was not clear - I've edited my OP to include a gif of what is happening. But basically it seems like I've got to click once to toggle off the active state from one country, then click again to add it to the new country.

            – Josh Undefined
            Mar 8 at 16:21











          • Nevermind! It was my only computed function in vue which was destroying the active prop AMcharts makes :)

            – Josh Undefined
            Mar 8 at 16:35

















          • Hey thanks for this. It seems to be working, however i need to press countries twice for the active state to trigger. Any thoughts?

            – Josh Undefined
            Mar 8 at 11:59












          • You can just replace the hit event with doublehit. I updated my answer according to that and included a code pen.

            – Samuel Philipp
            Mar 8 at 15:02











          • Ah I'm sorry Sam, perhaps I was not clear - I've edited my OP to include a gif of what is happening. But basically it seems like I've got to click once to toggle off the active state from one country, then click again to add it to the new country.

            – Josh Undefined
            Mar 8 at 16:21











          • Nevermind! It was my only computed function in vue which was destroying the active prop AMcharts makes :)

            – Josh Undefined
            Mar 8 at 16:35
















          Hey thanks for this. It seems to be working, however i need to press countries twice for the active state to trigger. Any thoughts?

          – Josh Undefined
          Mar 8 at 11:59






          Hey thanks for this. It seems to be working, however i need to press countries twice for the active state to trigger. Any thoughts?

          – Josh Undefined
          Mar 8 at 11:59














          You can just replace the hit event with doublehit. I updated my answer according to that and included a code pen.

          – Samuel Philipp
          Mar 8 at 15:02





          You can just replace the hit event with doublehit. I updated my answer according to that and included a code pen.

          – Samuel Philipp
          Mar 8 at 15:02













          Ah I'm sorry Sam, perhaps I was not clear - I've edited my OP to include a gif of what is happening. But basically it seems like I've got to click once to toggle off the active state from one country, then click again to add it to the new country.

          – Josh Undefined
          Mar 8 at 16:21





          Ah I'm sorry Sam, perhaps I was not clear - I've edited my OP to include a gif of what is happening. But basically it seems like I've got to click once to toggle off the active state from one country, then click again to add it to the new country.

          – Josh Undefined
          Mar 8 at 16:21













          Nevermind! It was my only computed function in vue which was destroying the active prop AMcharts makes :)

          – Josh Undefined
          Mar 8 at 16:35





          Nevermind! It was my only computed function in vue which was destroying the active prop AMcharts makes :)

          – Josh Undefined
          Mar 8 at 16:35



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047122%2famcharts-4-map-stroke-uneven-when-applied-to-single-countries%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved