Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I make 'Picture' rounded and add border to it? #1050

Closed
thrashzone13 opened this issue Aug 16, 2023 · 2 comments
Closed

How can I make 'Picture' rounded and add border to it? #1050

thrashzone13 opened this issue Aug 16, 2023 · 2 comments
Labels

Comments

@thrashzone13
Copy link

thrashzone13 commented Aug 16, 2023

Hi, I've put a Picture object inside a Bullet which I'm pushing to the MapPointSeries's bullets. Now I need to make the picture rounded and add border with color to it but It doesn't seem to be possible. Is there any way to handle this?

Here is part of my code

  let pointSeriers = chart.series.push(am5map.MapPointSeries.new(root, {}));

  pointSeriers.bullets.push(function (root, series, dataItem) {
    return am5.Bullet.new(root, {
      sprite: am5.Picture.new(root, {
        templateField: "pictureSettings",
        showTooltipOn: "click",
      }),
    });
  });

  pointSeriers.data.setAll([
    {
      properties: {
        name: "New York",
      },
      geometry: {
        type: "Point",
        coordinates: [-73.778137, 40.641312],
      },
      pictureSettings: {
        src: "https://picsum.photos/200/300",
        width: 50,
        height: 50,
        centerX: am5.p50,
        centerY: am5.p50,
      },
    },
  ]);

amCharts version: 5

@martynasma
Copy link
Collaborator

martynasma commented Aug 16, 2023

This can be done by using a masked Container in bullet:

pointSeriers.bullets.push(function (root, series, dataItem) {
  let container = am5.Container.new(root, {});

  container.children.push(am5.Picture.new(root, {
    templateField: "pictureSettings",
    showTooltipOn: "click",
  }));

  let circle = container.children.push(am5.Circle.new(root, {
    radius: 20,
    stroke: am5.color(0xff0000),
    strokeWidth: 3
  }));

  container.set("mask", circle);

  return am5.Bullet.new(root, {
    sprite: container
  });
});

@thrashzone13
Copy link
Author

Thank you so much @martynasma. Saved my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants