google visualization api - displaying multiple y-axis values for a single date on x-axis

I have a dataset that I need to graph with some given values.

Here is how my data is structured...
(Date on the x-axis and Values on the y-axis)

|| Date       || X1 || X2 || X3 ||
|| 01-01-2008 ||  1 ||  2 ||  3 ||
|| 01-01-2008 ||  2 ||  3 ||  4 ||
|| 01-02-2008 ||  1 ||  2 ||  3 ||
|| 01-03-2008 ||  1 ||  2 ||  3 ||
|| 01-04-2008 ||  1 ||  2 ||  3 ||

In the chart, I want to show a straight vertical line for the first two plotted values.

However, the visualization API's line chart is displaying separate columns for each of the first two dates...

For example,

xAxis - Jan 01, 2008 || Jan 01, 2008 || Feb 01, 2008 || Mar 01, 2008 || Apr 01, 2008

instead of just showing:

xAxis - Jan 01, 2008 || Feb 01, 2008 || Mar 01, 2008 || Apr 01, 2008

with a vertical straight line indicating Jan 01, 2008

The desired outcome is to have a vertical straight line representing Jan 01, 2008 without excluding the duplicate values...
this will ensure that both values corresponding to Jan 01, 2008 are displayed vertically on the chart.

If you can assist me in resolving this issue, it would be greatly appreciated.

Answer №1

Utilize Set collections to store values effectively. A Set is a unique collection that does not allow duplicate elements. Once you add "Jan 01, 2008", it will prevent duplicates from being stored.

Choose any implementation class of Set,

//initialize a hashset
HashSet<String> xAxis = new HashSet<String>();

//add values like this

xAxis.add(date1)
xAxis.add(date2)

In this example, String values are used but you can modify it as needed.

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

JS setTimeout not postponing execution

Attempting to introduce a delay before an AJAX call. var delay = 2000; $("#c_name").on("keyup", function() { var entered = $(this).val(); if (entered.length > 1) { setTimeout(dosearch(entered), delay) } }); Struggling to implement a d ...

Issues are arising with the for loop in an express node js app using ejs, as it is not displaying the intended data and

I am currently utilizing a for loop in JavaScript to display all the users from the database using ejs. I have included the code snippet below. This is within an express/node js application where SQL is used for data storage. <div class = "Contacts ...

The structure of NodeJS Express API calls revolves around handling asynchronous events

Currently, I am working on a hobby project using NodeJS and Express, but I am finding it challenging to manage asynchronous calls. There is a bug that I would like the community's help in resolving. I have set up an Express layout where I send post r ...

What is the best method for preserving HTML content using Ajax?

I am having difficulty storing HTML code in a database using AJAX. Despite having the correct connection information, I am unable to write to the table. <div id="others"> <div id="name"><input type="text" name="results" class="name"> ...

Calculate the combined sum of values within dynamic inputs that share a common class, and automatically update the sum whenever input values are altered or new rows are added or removed dynamically

$("#add-btn").click(function() { $("#dynamic").append('<tr>' + '<td class="td">' + '<input type="number" name="Debit" class="form-control Debit"/>' + '</td>' + '<td c ...

What is the process for immediately changing the background color of an input field as soon as text is entered?

I am encountering an issue with the code snippet provided below. My goal is to change the background color of an input field as soon as I start typing something into it. The scenario involves 4 input fields where if the submit button is clicked and any f ...

Slack API seems to be exclusively detecting text fields

I'm facing an issue while attempting to send a message with attachments to a Slack chat using a Slack bot. Despite successfully connecting to the API via WebSocket, I am encountering difficulties with sending messages that contain attachments. Below ...

java program to rotate an array of strings

Is there a way to rotate a string array in Java for a Tetris game that I'm developing? As an example, consider the following string array: [ "JJJJ", "KKKK", "UUUU" ] After rotating, it should look like this: [ "UKJ", "UKJ", "UKJ", "UKJ" ] I have s ...

Is there a method to access a particular element within an array without using array[somenumber]?

I am currently using Mongoose to work with MongoDB and making GET requests with Axios from the client to the server. So, I am executing this call with Axios axios.get(route).then(res => { const races = res.data[0].InsideRaceResults ...

Updating the text input value in a database with PHP upon button click

Here is a breakdown of what has been implemented so far: The database table is named adhar_card. Below is the structure image for reference (Adhard_card_id serves as the primary key). https://i.sstatic.net/8j4m6.jpg Clicking on the verify button will cha ...

The function could possibly be asynchronous as it does not yield any results

My goal is to incorporate XPATH evaluation into my form. When a user inputs an XPATH, it gets evaluated on the server using AJAX and then returns either true or false. The issue I'm facing is that this function always seems to return undefined. I sus ...

PHP + MySQL + JavaScript for an Interactive Web Communication Platform

My goal is to develop a Web Chat system using PHP, MySQL, and JavaScript. Currently, I store messages in a MySQL database with an incremental ID (indexed), timestamp, sender, and message. To retrieve new messages, I use AJAX to query the database every 50 ...

Experiment with creating a TabLayout on an Android platform

I recently followed a tutorial on creating a Tablayout in Android, but I encountered an issue. In my FirstActivity.java file: package info.mandai.animegallery; import com.example.animegallery.R; import info.mandai.animegallery.adapter.TabsPagerAdapter; ...

Discovering the minimum and maximum values in a Java two-dimensional array

public class DataHandler { static Integer[][] data = new Integer[10][12]; static int x = 0, y = 0; static int number; public DataHandler() { try { BufferedReader reader = new BufferedReader(new FileRe ...

Can an array of objects be filtered based on various dynamic conditions provided by another array of data?

My goal is to dynamically filter data using multiple checkboxes and their respective attributes, all coming from this main data object. [ { "_id": "61f0a145c6a48a907bd102ce", ... "rank": 1 }, { "_id& ...

Cookie Consent has an impact on the performance of PageSpeed Insights

On my website, I have implemented Cookie Consent by Insights. The documentation for this can be found at However, I noticed a significant drop in my Google PageSpeed Insight scores after loading the JavaScript source for Cookie Consent. The main issue hig ...

Can you please tell me the size of the Survivor space in Java 7?

My JVM process recently dumped core with a maximum heap size of 1024 MB (using OpenJDK 7 on Linux). Upon analyzing the core dump file using Yourkit Java Profiler 10.0.6, I discovered that the process only utilized 803 MB of heap when it encountered an Out ...

Effectively encoding and decoding AJAX and JSON objects with PHP scripting

I've successfully set up a basic HTML file with a fixed JSON object. My goal is to transfer this object to a PHP file named text.php, encode it, decode it, display it in the PHP file, and then showcase it back in the HTML file. <!DOCTYPE html> ...

Json data integrated dropdown menu

I have successfully retrieved data from a Json array and displayed it in a dropdown list. However, I am facing an issue where I want to only show the name of the city instead of both the name and description. If I remove cities[i]['description'], ...

Organize a JSON dataset

I am facing a challenge with a JSON structure that looks like this: "hotel": [ { "id": 90091, "hotelGroup": "A1", "hotelRoom": [ { "name":"Room1", "minimumQuantity": 1, "maximumQuantity": 6, }, { "na ...