Amcharts displays individual balloons for each graph instead of a single balloon for all graphs

My goal is to have a single balloon for all stacked graphs. I modified my code according to this guide. Unfortunately, the data for messages is not being displayed.

https://i.sstatic.net/2MRhc.jpg

Did I make an error in my implementation?

function createChart(chartDiv, title) {
    return AmCharts.makeChart(chartDiv, {
        "type": "stock",    
        "theme": "black",           
        "chartCursor": {
            "oneBalloonOnly": true,
        },
        "dataSets": [{
            "fieldMappings": [{
                "fromField": "ack",
                "toField": "ack"
            }, {
                "fromField": "messages",
                "toField": "messages"
            }],
            "color": "#1d6a96",
            "categoryField": "date",
        }],
        "categoryAxesSettings": {
            "alwaysGroup": true,
            "groupToPeriods": ["6mm"],
            "minPeriod": "4mm",
            "dashLength": 0,
        },
        "panels": [{
            "gridAboveGraphs": true,
            "stockGraphs": [{
                "type": "column",
                "id": "g1",
                "valueField": "ack",
                "lineColor": "#7f8da9",
                "fillColors": "#7f8da9",
                "fillAlphas": 0.85,
                "periodValue": "Sum",
                "useDataSetColors": false,
                "balloonText": "Ack:[[value]], missing:[[messages]]",
            }, {
                "type": "column",
                "id": "g2",
                "valueField": "messages",
                "lineColor": "#FDD400",
                "fillColors": "#FDD400",
                "fillAlphas": 0.85,
                "periodValue": "Close",
                "useDataSetColors": false,
                "showBalloon": false
            }],
        }],
        "valueAxesSettings": {
            "inside": false,
            "id": "v1",
            "dashLength": 0,
            "minimum": 0,
            "gridAlpha": 0,
            "stackType": "regular",
            "axisAlpha": 0.5,
            "showFirstLabel": false,
        },
    });
}

I am passing data to the chart from an Ajax response as JSON.

function insertChartData(chart, response) {
    var dataProvider = [];
    for (var i = 0; i < response.Stats.length; i++) {
        dataProvider.push({
            date: new Date(response.Stats[i].Checked),
            ack: response.Stats[i].Income,
            messages: response.Stats[i].Messages,
        });
    }

    chart.AmChart.dataSets[0].dataProvider = dataProvider;
    chart.AmChart.validateData();
}

Answer №1

The stock chart's data grouping feature is the reason behind this issue. When the data is aggregated, referencing fields by name becomes ineffective as they are not stored in the internal data grouping structure. This limitation also applies to fields like lineColorField. To work around this, you must turn off data grouping by setting maxSeries to 0 so that you can refer to properties by name.

    "categoryAxesSettings": {
        "maxSeries": 0,
        "minPeriod": "4mm",
        "dashLength": 0,
    },

Note that disabling data grouping may affect performance, especially with a large dataset.

For a demonstration, check out this Demo.

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

The system is unable to locate a compatible object with the identifier '[object Object]' of type 'object'. NgFor is limited to binding with iterables like Arrays, not JSON data

Working with JSON data data:[ { assets:[[tool_order_id: "38",order_status_id: "10"]], order_info:[id: "1", order_type: "6",check: "1", current_Stage_id: "29"] }, { assets:[tool_order_ ...

Ensure modifications to a variable are restricted within an if statement

I am struggling to find a way to globally change a variable within an if statement and ensure that the modifications persist. User input: !modify Bye var X = "Hello" if (msg.content.includes ('!modify')) { X = msg.content.replace('!modi ...

The use of JSON.parse does not support parsing URL links

As a junior developer specializing in Javascript and Google Apps Script, I decided to enhance the functionality of my Google Sheets by tracking the last modification time of URLs stored in them. Although I attempted to create a script for this task, it see ...

React- hiding div with hover effect not functioning as expected

I'm having trouble using the :hover feature in CSS to control the display of one div when hovering over another, it's not functioning as expected. I've successfully implemented this on other elements, but can't seem to get it right in t ...

Creating an efficient login system for my website - where do I start?

I've recently started diving into the world of web development, starting with HTML, CSS, and a bit of JavaScript. However, I've hit a roadblock - while I can perform basic styling, I'm struggling to make my projects interactive. My main que ...

Error: Attempting to access property 'propeller' of an undefined object has caused a TypeError

I am working on a tutorial that can be found at this link: https://tympanus.net/codrops/2016/04/26/the-aviator-animating-basic-3d-scene-threejs/ During the process, I encountered an error message: Uncaught TypeError: Cannot read property 'propeller& ...

Error message encountered in PHP due to an undefined index

My goal is to add items from a form to a table named products. The form layout can be seen here: https://i.stack.imgur.com/f9e08.png The "Add more suppliers: +" link adds a new row to the form when clicked. The corresponding script for this action is as ...

increasing the size of the JSON object

I have a function that is being called multiple times utilizing jQuery to fetch different JSON data from an API. My aim is to calculate the total count of a specific portion of the JSON retrieved. Below is an example of what I currently have: getTheData( ...

Anticipated request for spy navigation with path '/members' was expected, but unfortunately was not triggered

I am facing an issue with a service method that performs an HTTP delete operation. The expected behavior is that upon successful deletion, the page should be redirected to another location. However, during testing, I noticed that the router navigation func ...

Guide to importing a JSON file in a Node.js JavaScript file

I am trying to incorporate a JSON file into my JavaScript code in a Node.js application. I attempted to include it using the "require();" method, but encountered an issue: "Uncaught ReferenceError: require is not defined". ...

How to efficiently store data using ajax and php techniques

I'm currently working on sending data via ajax for the user_question and language input fields. Can anyone help me with the correct way to include this element in the ajax JavaScript code so that I can save the table element value in my database? Tha ...

Having trouble with your Javascript Ajax call?

I've been attempting to make a POST request using Ajax, but I keep encountering an error with status code 0. Strangely, all the request parameters seem to be functioning correctly in the Advanced REST Client. Here's My Code Snippet: <button& ...

Transferring an object from Javascript to C++/CX following a C++/CX interface in Windows Runtime Components

As a newcomer to Windows Runtime Component, I've been exploring ways to accomplish the following task. I'm looking to extend a C++ interface in JavaScript. namespace MySDK { public interface class LoggerPlugin { public: virt ...

What are some strategies for stopping a form from redirecting me while utilizing ReactJS and ExpressJS?

Recently, I created a form that redirects to the route /repair upon submission with an action of /repair. However, I would prefer to keep it as a Single Page Application (SPA) where after submitting the form, the fields are cleared, and a simple message l ...

What are the best ways to enhance performance for ajax requests using Jquery?

Currently, I am in the process of developing a mobile application that utilizes jquery mobile, jquery, and a PHP backend. My issue arises when dealing with certain pages as there are numerous ajax requests being sent and received simultaneously, resulting ...

Is there a limit to the number of else if statements I can use? The final else statement

How can I enhance this code snippet? The last else if statement is not working, despite my efforts to fix it. var selectedDntTyp = $("#donationTypDD"); if (selectedDntTyp.length > 0) var DropInitValue = selectedDntTyp.val(); if(DropInitValue == &apos ...

Using ESM imports in webpack configuration

I'm in the process of creating a webpack application and I am keen on utilizing ESM (ECMAScript Modules) throughout the entire project. This involves configuring the webpack.config file to allow for ESM imports. Previously, I knew that this could be ...

Looking to switch up the hide/show toggle animation?

Currently, I have a functioning element with the following code. It involves an object named #obj1 that remains hidden upon page load but becomes visible when #obj2 is clicked. #obj1{ position:fixed; width:100px; bottom:180px; right:10 ...

React child component does not refresh upon modification of an array property

In my main application, I have two subcomponents that both receive the same model property. The first subcomponent deals with a number prop from model.myNumberProperty, and the second subcomponent handles an array prop from model.myArrayProperty. When ch ...

Testing a Vue.js/Node.js application using Websockets

I'm working on a Vue project (version 3.0.3) integrated with a Node.js server. Can you provide guidance on how to conduct unit testing for this setup? The application is a game that relies on web-sockets for communication. ...