Issue with Highcharts: The useHTML flag is not functioning properly when trying to render labels

Currently, I am utilizing highcharts and a phantomjs server for rendering charts and labels. However, I have encountered an issue where the useHTML flag does not function as expected when rendering the labels. Following the instructions in the documentation, I initiated the server using the command phantomjs highcharts-convert.js -host 127.0.0.1 -port 3003

Subsequently, I am sending post requests with the following JSON data as the input file:

{
chart: {
    events: {
        load: function() {
            var label = this.renderer.label('Hello      World', {useHTML:true})
            .css({
                    color: '#FF11FF',
                    fontSize: '12px'
                })
            .attr({
                    fill: 'rgba(0, 0, 100, 0.75)',
                    padding: 8,
                    r: 5,
                    zIndex: 6
                })
            .add()

            box = label.getBBox();
            label.align(Highcharts.extend(box, {
                    align: 'center',
                    verticalAlign: 'top',
                    x: 0,
                    y: 20
                }),
                null, 'spacingBox');

            var label2 = this.renderer.label('Goodbye World')
                .css({
                    color: '#222222'
                })
                .add()
            label2.align(Highcharts.extend(label2.getBBox(), {
                    align: 'left',
                    verticalAlign: 'top',
                    x: 0,
                    y: box.height + 40
                }),
                null, 'spacingBox');
        }

    },
    height: 800,
    width: 500
},
title: {
    text: ''
}
};

After exporting this as an SVG, I noticed that the label text remains unchanged. I attempted to modify the code like this:

var label = this.renderer.label('Hello      World',null, null, 'rect', null, null, true)

However, this caused the first text to be completely omitted, adding a blue background along with the second text. Surprisingly, the initial text is also unresponsive on export.highcharts.com while the modified version works seamlessly there. Can someone guide me on what error I might be making in this scenario?

Answer №1

It appears that you forgot to provide all the necessary arguments for Renderer.label in your code. You can find more information about this function in the following documentation: http://api.highcharts.com/highcharts/Renderer.label

Here is an example of how Renderer.label should be used:

this.renderer.label('Hello      World',null,null,null,null,null,true)

To see a working example of Renderer.label usage, check out this fiddle: https://jsfiddle.net/6atnc2xj/

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

JavaScript: table is not defined

When creating a table using Django models and JavaScript, I encountered an issue where the cells values of the table could not be accessed from another JavaScript function. The error message indicated that the table was "undefined". Below is the HTML code ...

Use JavaScript to add a div element to the page ten times every time the button is clicked

Here is the code I have written: $(document).ready(function () { $('<button class="btn more">View More</button>') .appendTo(".listing-item-container") .click(function() { $(this).closest(". ...

Issues with retrieving the scope attribute within a directive

I am currently facing an issue where I am unable to access the values stored in $scope.photoRes within my directive. When I use console.log(scope.photoRes) in the directive, it only displays an empty object. Here is the output from the console: Object {fi ...

Switching out one block of HTML with another in JavaScript is a powerful way to dynamically update

I am working on creating a feature on a webpage where clicking a button will change the HTML code inside a specific div. Essentially, I want to be able to update the content of a div by simply clicking a link. Here are two different sets of HTML code: Co ...

The ssh2 module experiences a quiet failure when provided with credentials that are successful when used from

After successfully connecting to Google Cloud Compute using the CLI with a command like this: ssh -i ~/.ssh/my-ssh-key me@ipnumber I have encountered a problem where the ssh2 module is not providing any output or errors. var fs = require('fs') ...

Is there a way to simulate Pinia and vue-i18n simultaneously?

Exploring Vue 3's Composition API with a twist: The store.ts file import { ref, Ref } from 'vue'; import { defineStore } from 'pinia'; export const useStore = defineStore('store', () => { const isLoading: Ref<bo ...

Creating an array of objects by utilizing another array - the process explained

I am looking to create a new array by pushing objects after checking the values in an existing array. Here are the conditions: var ar=['aa','cc','po'] var arr =[{name:"po"},{name:'aa'},{name:'cc'}]; Desi ...

Can I obtain a dictionary containing the connections between labels and phrases from the classifier?

I've implemented a LogisticRegressionClassifier using the natural library for node: const natural = require('natural'); const classifier = new natural.LogisticRegressionClassifier(); classifier.addDocument('category1', 'sent ...

Mongoose retrieves the entire document, rather than just a portion of it

I'm currently experiencing an issue with my mongoose query callback from MongoDB. Instead of returning just a specific portion of the document, the code I'm using is returning the entire document. I have verified that in the database, the 'p ...

Ace Code Editor: Turn off highlighted line beneath cursor

I am currently utilizing the Ace editor and would like to remove the shadowed line where the cursor is located. Here's an example Even after experimenting with different themes provided by Ace Mode Creator, the shadowed line still persists. Any sug ...

The program encountered an unexpected identifier 'getProject' instead of ';'. It was expecting to find a semicolon after the async variable declaration

When using this JavaScript on a webpage, I encounter an issue: <script async type="module"> import {projectCode} from "./assets/js/config.js"; import {getProject} from "./assets/js/saleproject.js"; import {getAccount} fr ...

Updating parent array values within child components in React

Currently, I am working on a React application where I need to save the handlers for all windows opened from the app. Previously, before using React, I stored these windows in a global array attached to the parent window, although I understand that using J ...

Ways to modify the hue of an li element in the context menu upon hovering

I'm currently working on a project that involves VueJS and Bootstrap. To enhance user experience, I've incorporated a context menu using the npm package called vue-context Vue Context Menu When a user hovers over an item on the context menu, the ...

Evolving the appearance of every vacant element

Currently, I am working on a project that allows users to add items. To facilitate this process, I have included an "add another" button which enables them to include additional items all at once. In order to validate the form and save values to the datab ...

Tips for maintaining the position of a camera in three.js while also keeping its rotation fixed on the origin

In three.js, I'm looking to dynamically adjust my camera's position while ensuring that its rotation automatically aligns with the world origin. For instance, if the camera is initially set at: camera.position.set(25,25,25) I aim to have the ...

Issues arise in mobile Safari when attempting to load JavaScript files, resulting in

Encountering an issue with my Angular app on mobile Safari during the initial load, where it hangs on a blank page for nearly 2 minutes. Interestingly, the app functions perfectly on other browsers, including Mac Safari and iPad Safari. Initially, I suspe ...

Mastering Angular2: Leveraging TypeScript's Power to Unleash JavaScript ES6 Syntax with

I am having trouble implementing a translation feature using the ng2-translate pipe in my Angular2/Ionic2 app, which is entirely written in JavaScript ES6. However, I have encountered an issue during the setup phase. The code snippets I have found on the ...

Why is the lower sub-component positioned above the rest of the page?

I have set up a sandbox environment to demonstrate an issue that I am facing. The main problem is that when I click on "Option 1" in the main menu, a new component appears where a bottom sub-component (named BottomControls.js) is displayed at the top of t ...

What are the best ways to incorporate a theme into your ReactJS project?

Looking to create a context for applying dark or light themes in repositories without the need for any manual theme change buttons. The goal is to simply set the theme and leave it as is. Currently, I have a context setup like this: import { createContext ...

Encountering the "node:internal/modules/cjs/loader:1050" error while attempting to execute a folder using the "npm run dev" command

I am encountering an issue while attempting to execute a folder using npm run dev, consistently resulting in the same error message. PS C:\Users\My Name\Desktop\My Folder> npm run dev Debugger attached. > <a href="/cdn-cgi/l/e ...