Tips for displaying text on the bubbles of a vector map using the DevExpress library in an Angular and TypeScript environment to showcase counts or other relevant information

I managed to incorporate the devextreme angular 2 map into my demo project. My goal is to display the count of individuals with the name 'x' on the bubble as a label/text on the vector map, without the need for hovering to see a tooltip. I want the label to be visible directly on the bubble itself in the Demos > maps>vectormap>bubble markers

Current state (focus on bubbles): https://i.sstatic.net/Gk3hn.png

Desired outcome (focus on bubbles): https://i.sstatic.net/v9caW.png

This is what I tried:

    <div class="dx-viewport">
<div class="demo-container">
    <dx-vector-map 
    id="vector-map" 
    [bounds]="[-180, 85, 180, -75]">
    <dxo-tooltip 
        [enabled]="true" 
        [customizeTooltip]="customizeTooltip"></dxo-tooltip>
    <dxi-layer 
        [dataSource]="worldMap"
        name="areas"
        palette="Violet"
        [colorGroups]="[100]"
        colorGroupingField="population"
        [customize]="customizeLayers">
        <dxo-label [enabled]="true" dataField="name"></dxo-label>
    </dxi-layer>
    <dxi-layer 
        [dataSource]="markers" 
        name="markers" 
        valueField= "user"
        elementType="bubble" 
        dataField="value" 
        [sizeGroups]="[0, 10000]"
        opacity="0.8">
        <dxo-label [enabled]="true"></dxo-label>
    </dxi-layer>


</dx-vector-map>

</div>
</div>


This is the service map.service.ts 
<pre>
 import { Injectable } from '@angular/core';


 export class FeatureCollection {
  type: string;
  features: Feature[];
}

    export class Feature {
   type: string;
  properties: FeatureProperty;
  geometry: FeatureGeometry;
}

export class FeatureProperty {
  text: string;
  user: string;
  value: number;
   // tooltip: string;
}

export class FeatureGeometry {
  type: string;
  coordinates: number[];
}

// let populations: Object = {
//     "China": 19,
//     "India": 17.4,
//     "United States": 4.44,
//     "Indonesia": 3.45,
//     "Brazil": 2.83,
//     "Nigeria": 2.42,
//     "Bangladesh": 2.18,
//     "Russia": 2.04,
//     "Japan": 1.77,
//     "Mexico": 1.67,
//     "Philippines": 1.39,
//     "Vietnam": 1.25,
//     "Ethiopia": 1.23,
//     "Egypt": 1.21,
//     "Germany": 1.13,
//     "Turkey": 1.07,
//     "Democratic Republic of the Congo": 0.94,
//     "France": 0.92,
//     "Thailand": 0.9,
//     "United Kingdom": 0.89,
//     "Italy": 0.85,
//     "Burma": 0.84,
//     "South Africa": 0.74,
//     "South Korea": 0.7,
//     "Colombia": 0.66,
//     "Spain": 0.65,
//     "Tanzania": 0.63,
//     "Kenya": 0.62,
//     "Ukraine": 0.6,
//     "Argentina": 0.59,
//     "Algeria": 0.54,
//     "Poland": 0.54,
//     "Sudan": 0.52,
//     "Canada": 0.49,
//     "Uganda": 0.49,
//     "Morocco": 0.46,
//     "Uzbekistan": 0.43
// };



let markers: FeatureCollection = {
...
};
  
@Injectable({
  providedIn: 'root'
})
     export class MapService {
    
   ...

</pre>
This is finance.component.ts

<pre>
import { Component, OnInit } from '@angular/core';
import { NgModule, enableProdMode } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { DxVectorMapModule } from 'devextreme-angular';
import * as mapsData from '../../../../assets/vectormap-data/world.js';

...

@Component({
...

export class FinanceComponent implements OnInit {

...

constructor(service: MapService) {...}

...

customizeTooltip(arg) {
return {
text: arg.attribute("text"),
};
}

...

ngOnInit() {
}
}


</pre>

Answer №1

After some investigation, I have managed to find a solution for this issue. You can check out the fix by visiting this link. Simply add dxi-label to your map or chart as demonstrated in the linked article.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Applying Multiple Conditions to setCellProps in Material-UI

I am facing an issue with a data-table that is not in a class extending the React.Component, unlike some examples I have come across. My goal is to setCellProps based on certain conditions as outlined below: If utilization is less than or equal to 50, the ...

The Error message "Property 'data' is not present in Type <void> | AxiosHttpResponse<any>" is indicating that the data property is missing on

When I fetch data for a specific user, I have a promise that I use to setState. Below is the implementation: getUserUsername = (): string => { const { match } = this.props; return match.params.username; }; onFetchUser = () => getUse ...

Is there a way to set a default value for a placeholder or tabstop that is equal to the value of a previous placeholder or tabstop

Looking to create a TypeScript import snippet that is simple and efficient, like this: import * as module from 'module'; I want to maintain the as part as the same as the module name. The following template works well for me: "import * as ${1} ...

Can TypeScript be used to generate a union type that includes all the literal values from an input string array?

Is it feasible to create a function in TypeScript that takes an array of strings and returns a string union? Consider the following example function: function myfn(strs: string[]) { return strs[0]; } If I use this function like: myfn(['a', &a ...

Error message: Object literal is limited to declaring existing properties

The source code was obtained from this Codesandbox demo: CodeSandbox - Cover Image Example Subsequently, an .eslintrc configuration file was generated with the following content (the only content present): { "extends": "react-app" } However, a TypeScri ...

What is the proper way to utilize useRef in TypeScript to assign a function to ref?

I am just diving into Typescript and I am looking to assign a function to a ref within a custom hook. My goal is for the function to remain constant throughout renders. Check out the code on CodeSandbox: https://codesandbox.io/s/918l0wro4r function runFu ...

Substitute data types for certain keys within a Typescript interface

Within this code snippet, the goal is to create a new type from an existing one by iterating through the keys and only replacing those that meet a specific condition. Additionally, union types are being utilized here. class A {} class B { constructor ...

Different Categories of Array Deconstruction

While iterating through an array, I am utilizing destructuring. const newArr = arr.map(({name, age}) => `${name} ${age}`) An error occurs in the above code stating: Binding element 'name' implicitly has an 'any' type To resolve th ...

Angular's custom reactive form validator fails to function as intended

Struggling to incorporate a customized angular validator to check for date ranges. The validator is functioning correctly and throwing a validation error. However, the issue lies in the fact that nothing is being displayed on the client side - there are n ...

Challenges with Spreading Props in TextField Component After MUIv4 Upgrade with TypeScript

Latest Material-UI Version: 4.1.0 I'm encountering difficulties in passing props to an abstracted <TextField /> component that I've developed. Below is the snippet of code: PasswordInput.tsx import * as React from 'react' impo ...

Using the spread operator in Typescript/Javascript to dynamically add members to an object based on certain conditions

I was exploring a method for conditionally adding members to an object, which I found here Below is the code I came up with: const theobj = { field1: "hello", field2: 1, data: { datafield1: "world", datafield2: 2 }, ...

The parameter type 'IScriptEditorProps' does not accept arguments of type 'string'

After trying numerous solutions, I decided to integrate this script editor into a SharePoint site. However, when attempting to implement it, I encountered an issue with the constructor lacking arguments. Despite my efforts to troubleshoot, I have been unab ...

Can anyone offer any suggestions for this issue with Angular? I've tried following a Mosh tutorial but it's

Just finished watching a video at around 1 hour and 35 minutes mark where they added the courses part. However, I encountered an error during compilation. ../src/app/app.component.html:2:1 - error NG8001: 'courses' is not recognized as an elemen ...

Tips on declaring an object with a nested array of objects in TypeScript

In my code, I have defined two classes. One is called Stuff and the other is called Thing. class Stuff { constructor() { } things: Thing[] = []; name: string; } class Thing { constructor() { } active: boolean; } As I was working on my applicat ...

Encountering a TypeError while utilizing a custom hook for an Apollo mutation operation

I'm facing a tough time debugging an issue with my Apollo mutation in my NextJS application. The error I'm encountering is as follows: "TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))" It appears t ...

Is there any special significance to the statement x = x in TypeScript/Angular?

The Fontawesome/Angular documentation provides an example of adding an explicit reference, which may not be as convenient as using the library directly. If you value "explicit is better than implicit," then this method might be for you. The example code sn ...

Declaration files for Typescript ESLint configurations

I've been researching this issue online, but I haven't been able to find any solutions. It could be because I'm not entirely sure what's causing the problem. What I'm trying to do is set a global value on the Node.js global object ...

"Encountered an error: Unable to interpret URL from (URL).vercel.app/api/getMessages" while deploying Next.js 13 using TypeScript on Vercel

Hello to all members of the StackOverflow Community: I am encountering an error message stating "TypeError: Failed to parse URL from next-chat-lenx51hr5-gregory-buffard.vercel.app/api/getMessages" while attempting to build my Next.js 13 application using T ...

The error message "./components/Avatar.tsx Error: Module '@babel/preset-stage-0' not found" appeared on the screen

Even after dedicating a few hours to research, I'm still unable to resolve an ongoing issue with Babel and Webpack. ): The solution must be simple. Here is my .babelrc: { "presets": ["@babel/preset-env", "@babel/preset-reac ...

Issue with handling multiple input files in an *ngFor loop

I am facing difficulties in targeting the correct input within a *ngFor loop. When I include an image with the first input (Certificat dimmatriculation), it displays a placeholder image and a delete button to reset the input, but it appears under both divs ...