The diameter of the pie chart in HighCharts adjusts dynamically based on the values specified within the series

I am currently utilizing HighCharts to display a doughnut (pie) chart in my Angular application. One issue I am facing is that the 'inner size' of the graph changes based on the values provided in the series. When the series has only two values, such as 50 and 50, the inner size appears very thin. However, when I provide values like 20 and 80, the chart looks fine.

An interesting observation is that when I run the same code for the scenario with values 50 and 50 on JsFiddle, the inner size of the chart does not appear thin. It should be noted that in JsFiddle, I have selected relevant dev settings - JavaScript + AngularJS 2.0.0-alpha.47).

In my application, the 'package.json' file indicates the Highchart versions as "highcharts": "^6.1.4", "highcharts-angular": "^2.3.0". Below, you can find my Angular version and some additional information. Kindly help me unravel this mystery.

setCompletedTasksDonutChartRM(completedTasks, notCompletedTasks) {
this.donutChartOptionsForRM_Completed = {
  chart: {
    type: 'pie'
  },
  credits: {
    enabled: false
  },
  title: {
    text: ''
  },
  plotOptions: {
    pie: {
      innerSize: 250
    }
  },
  colors: ['#F0F0F0', '#4BB482', '#4cb581'],
  series: [{
    name: 'Tasks (%)',
    data: [
      ['Not completed', 50],
      ['Completed', 50],
    ]
  }]
};
}

https://jsfiddle.net/kushannc/4pLkbtzc/5/

https://i.sstatic.net/V65pE.png

https://i.sstatic.net/P4jpJ.png

https://i.sstatic.net/d6qYO.png

Answer №1

One simple solution is available. If you adjust the position of 50, 50 data labels horizontally, they may take up too much space. The value of innerSize remains fixed (e.g. innerSize = 250 in your case), so reducing the thickness of the pie is the only way to ensure the chart fits within the plot area. Test this with wider screen settings for confirmation.

To resolve this issue, consider utilizing innerSize as a percentage of the pie.

Here's the code snippet:

Highcharts.chart('container', {
  chart: {
    type: 'pie'
  },
  credits: {
    enabled: false
  },
  title: {
    text: ''
  },
  plotOptions: {
    pie: {
      innerSize: '70%'
    }
  },
  colors: ['#F0F0F0', '#4BB482', '#4cb581'],
  series: [{
    name: 'Tasks (%)',
    data: [
      ['Not completed', 50],
      ['Completed', 50],
    ]
  }]
});

Check out the demo: https://jsfiddle.net/BlackLabel/c0Lyx3jo/2/

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

Incorporating Moment.js into React Native Typescript for Enhanced Date and

I am currently facing an issue while using Moment.js and React Native to work with date and time. My code snippet below showcases how I am attempting to utilize the library. import * as React from 'react'; import { Text, View, StyleSheet } from ...

Connecting the VSCode Debugger to a C# Winforms Application for Efficient Typescript/Javascript Debugging

Within my C# WinForms application, I am utilizing jint to execute JavaScript. This JavaScript code is the output of transpiled TypeScript file, complete with inline source mapping. I am now interested in providing users of my application with the ability ...

Is it possible to expand or merge Nestjs decorators?

My custom decorator named "User" is quite simple: export const User: () => ParameterDecorator = createParamDecorator( (data: any, req): UserIdentity => { const user = getUser(req); return user; }, ); Now, I'm in need of validating ...

Incorporate axios within getStaticProps while utilizing Next.js

I am working on a new project where I am utilizing axios to handle request data. However, I am facing an issue when using axios in the getStaticProps function which results in an error on my index.js page. Here is a snippet of my index.js code: import ...

Developing a discriminated union by utilizing the attribute names from a different type

In my quest to create a unique generic type, I am experimenting with extracting property names and types from a given type to create a discriminated union type. Take for example: type FooBar = { foo: string; bar: number; }; This would translate t ...

What is the best way to replicate certain key-value pairs in an array of objects?

I am working with an array of objects. resources=[{name:'x', title:'xx',..},{name:'y',title:'yy',..}..] To populate my HTML tooltip, I am pushing all the titles from the resources array to a new array. dialogOkCli ...

Incorporating timed hover effects in React applications

Take a look at the codesandbox example I'm currently working on implementing a modal that appears after a delay when hovering over a specific div. However, I've encountered some challenges. For instance, if the timeout is set to 1000ms and you h ...

ajax loading of highstock chart results in choppy animations

Utilizing the HighStock API and setExtremes callback to fetch data from the server. Whenever there is a change in the extremes, the entire chart suddenly jumps to certain values (x-axis and lines) until the new data is fetched from the server. This behav ...

Is it possible to eliminate a parameter when the generic type 'T' is equal to 'void'?

In the code snippet below, I am attempting to specify the type of the resolve callback. Initially: Generic Approach export interface PromiseHandler<T> { resolve: (result: T) => void // <----- My query is about this line reject: (error: a ...

Modifying an onClick handler function within a react element located in a node module, which points to a function in a prop declared in the main Component file

I have successfully implemented the coreui CDataTable to display a table. return ( <CDataTable items={data} fields={fields} ... /> ) Everything is working smoothly, but I wanted to add an extra button in the header of the C ...

Ways to dynamically update button properties in Angular 2

Customized Template, <div *ngFor="let item of items" class = "col-sm-12 nopadding"> <a class="button buttonaquacss button-mini button-aqua text-right pull-right" [ngClass]="{activec: isActive}" (click)='updateStatus(item)& ...

Download pictures from swift into typescript with the help of share extensions

Currently, I am working on setting up Share Extensions in my ionic3 application. To begin with, I followed these steps: Firstly, I built the app and then launched it in Xcode. After that, I added a Share Extension by navigating to File -> New -> Ta ...

"Encountering issues with npm installation while trying to set up Angular

Whenever I attempt to execute npm install, I encounter the following error message: npm ERR! node v0.12.12 npm ERR! npm v3.3.6 npm ERR! code ELIFECYCLE npm ERR! <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4d5dad3c1d8d5c6 ...

Ways to incorporate style links in Angular v2 components?

Currently, I am working through the Angular tutorial available on their website. In my quest to create various components, templates, and styles, I have hit a roadblock. The issue lies in incorporating my styles into the components using the 'styleUR ...

Printing with Angular 7: A Handy Service

As I was attempting to generate the angular form, I came across this example on https://stackblitz.com/github/IdanCo/angular-print-service?file=src%2Fapp%2Fapp.component.html I explored the named routes but faced some confusion. There were two points tha ...

Trouble with parsing JSON in rxjs ajax response

Currently, I am facing an issue while parsing a JSON string within an ajax callback in Angular2. After executing response.json()) and using console.log(), everything seems to be functioning correctly. This is the specific JSON data that I am attempting ...

Receiving a SyntaxError in Node.js with the message "Unexpected token *" while attempting to import

node: v10.16.3 npm: 6.12.0 Encountered an error while trying to import express in node. Referencing the code from https://github.com/angular-university/rxjs-course, specifically server/server.ts. To run server.ts, used the following command: $ ts-node ...

Firebase authentication link for email sign-in in Angularfire is invalid

Currently, I am utilizing the signInWithEmailLink wrapper from AngularFire for Firebase authentication. Despite providing a valid email address and return URL as arguments, an error is being thrown stating "Invalid email link!" without even initiating any ...

Is the validity of the expression !args.value || args.value.length true?

After analyzing this segment of code, I noticed an interesting expression: !args.value || args.value.length For instance, consider the following scenario: let v = {}; console.log(!v.value); //outputs true console.log(v.value); //outputs undefined con ...

How can I add multiple filters to a Kendo Grid?

Is there a way to include two separate filter fields for date filtering in Kendo Grid UI? Currently, the method I am using only allows for one date filter to be displayed. filterable: { ui: function (element: any) { element.ken ...