Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
-1 votes
1 answer
61 views

How to sum up multiple datasets [0, 1, 2, 3, 4...] with always data [0] in Javascript [duplicate]

I am still a rookie and need some help. There is my variable chartdata as starting point: var chartdata = { labels: [ "Bar 1", "Bar 2", "Bar 3", "...
npmboy's user avatar
  • 1
1 vote
2 answers
322 views

Angular Push JSON data into Array

im trying to figure out how to push a json object into an array using typescript. I managed to do it with one value of the json object but i need to do it with the second one too. Heres the Structure ...
user avatar
0 votes
1 answer
41 views

Chart.JS - updating Labels from Chart 0 also updated Labels from Chart 1

I have two line chart. I want to update the data for both of them, but somehow, after I update only the first Chart, the Label data on the 2nd Chart is also udpated at the same time. Am i Doing ...
vitoto9010's user avatar
-1 votes
1 answer
33 views

Why does the last question in the array not show in the mapping function and also not taken into the score? (react/chart.js)

I have an array "questions" with 24 questions, but the last one in the array is not shown and taken into the final score. And I can't figure out why it only renders 23 times. I was wondering ...
Noemi Frischknecht's user avatar
0 votes
1 answer
193 views

How to analyze/count an array of objects in Javascript

Stack Overflow! This is my very first. So, say for example I have the following array: [ { "question1": "Apple", "question2": 5, "...
V4LDUS's user avatar
  • 3
1 vote
1 answer
166 views

How to convert json array to object then chartjs

function grab() { return new Promise((resolve, reject) => { $.getJSON({ url: "/hash_results_page/", cache: false, method: "GET", dataType: "...
wreckless's user avatar
1 vote
1 answer
72 views

chart.js PHP to JS string conversion question [duplicate]

I am querying wordpress ACF fieldsdata which needs to plot into a chart.js radar type chart. <?php // Query posts $args = array( 'post_type' => 'resultaten', 'tax_query' => array( ...
Jasper's user avatar
  • 27
0 votes
2 answers
58 views

How can I divide values from two different arrays which are not of the same length?

I am trying to get DividendYield from a company for the last 20 years using ChartJs in laravel project. The arrays came from HTTP client API. The formula is like that :$dividendPayed / $dailyPrice * ...
webdev7's user avatar
0 votes
1 answer
140 views

Assigning a random color to each object in an array

I am working on setting up a graph with chartjs. The graph works as intended but the issue right now is that either all of the graphs will get the same color, or all of the graphs will change to ...
NewProgrammer1500's user avatar
1 vote
1 answer
99 views

Extract arrays from JSON

I'm trying to extract some data from JSON response (from REST API to angular) into arrays to use in Chartjs. The JSON is in this format [ { "A": a, "B": b, ...
SR1919's user avatar
  • 13
0 votes
0 answers
289 views

How do I format data arrays in the correct way React ChartJS

I'm running into some trouble trying to visualize data using the react version of ChartJS. I believe I'm aware of where the problem lies but after not being able to find anything online, I have no ...
Bram Kuitert's user avatar
0 votes
1 answer
132 views

Why can I not push data into labels?

I am using Vue2 and ChartJs. I have a set of array which look like this: I have no issues pushing lossEmptyUnits to my dataset, but I also need to push the date to my labels so that I can try to sort ...
Cphml444's user avatar
3 votes
1 answer
1k views

How to change chart's backgroundColor for specific dataset with onclick event using ChartJS

// Set Chart Global Variables let x_values = [0]; let y_values = [0]; let new_number = 0; let index = 0; // Intialize The Chart Canvas let ctx = document.getElementById('chart_canvas').getContext('2d'...
Ken's user avatar
  • 253
0 votes
1 answer
91 views

ChartJS not loading data but inputting same data hardcoded works

so I got this chartJS (react) element which is working perfectly well when I use hardcoded data: <Line data={{ labels: ['2022-07-04', '2022-07-03', '2022-07-02', '2022-...
sneaker's user avatar
  • 49
0 votes
1 answer
108 views

how to input values at chartjs labels?

i want to make it horizental at my value- lab(ex : 1, 2, 3, 4, 5, 6, 7...) and why print array vertical in chartjs? why don't print my value my value - op3? (360.4,360.4,360.4,360.4,360.4,360.4) my ...
Ryu Hoon Hee's user avatar
1 vote
1 answer
1k views

2 layer doughnut chart using Chart.js

I am trying to create a pie chart that displays an array of countries at the first level and the cities for each country at the second level. I have a JSON file (below) with data that I modified in ...
Daniel H.'s user avatar
  • 660
0 votes
1 answer
246 views

How to separate a single json array into x and y values?

I am utilizing Json.SerializeObject(variable) to obtain an array that I am graphing using Chart.js. In order to get the array, I am creating a list and adding the key and its corresponding value to ...
Roohi's user avatar
  • 1
0 votes
1 answer
215 views

vanilla js error "cannot set property of undefined" on the chrome console

Hey I'm new to chartjs and js in general and keep getting the error ""cannot set property of undefined" on the chrome console const dataPie = { labels: ['Good Packs', 'Bad Packs'], ...
randombroom's user avatar
0 votes
1 answer
739 views

Sum array of objects value based on month - ReactJS

So first of all, because I am using a ChartJS I need to generate an array of months. The creation is looking like this : const [generatedMonths, setGeneratedMonths] = useState<string[]>([]) ...
PandaMastr's user avatar
1 vote
1 answer
2k views

Multiple Chart.js charts on a single page, from 1 function but different data

Thank you for viewing my question. I have multiple charts I need to display on a single page, the values need to be in the HTML, hence the JavaScript retrieving them. The issue I have is both charts ...
MayhemBliz's user avatar
1 vote
0 answers
113 views

i get data not organized in my chartjs symfony

this is my function in my controller public function stat(ChartBuilderInterface $chartBuilder): Response { //livreur par nbr livraison $livreur = $this->getDoctrine()->getRepository(...
safachaari's user avatar
0 votes
2 answers
442 views

Chart.js: Change lengend colors to array

I have a chart with three datasets (Svelte REPL with code and result) and would like to change the background colors of the boxes corresponding to each set, for example: let legendColors = ['#dddddd', ...
Markstar's user avatar
  • 853
2 votes
2 answers
3k views

How to select and pass array object to data setting of chart.js config?

I have a hidden input <input type="hidden" id="0" value="10, 12"> and I am using obj = [document.getElementById('0').value]; in a script tag to retrieve and use ...
Liam's user avatar
  • 553
1 vote
2 answers
153 views

ChartJS Arrays Acting as One Item

I'm trying to import readings from mySQL database, and place them on a ChartJS. $query = mysqli_query($conn, "SELECT * FROM readings ORDER BY readings_id DESC LIMIT 2"); $distance = array()...
Sean_K's user avatar
  • 23
1 vote
1 answer
166 views

How to address type errors when removing data with chart.js?

I'm using chart.js to make a simple chart. No problem producing the chart, but now I've added a remove data function per the documentation but I'm getting a type error. I assume it's because I'm ...
Mark's user avatar
  • 13
0 votes
1 answer
132 views

pass array to chart.js option [closed]

i have this array: array ( 0 => 'rgba(202, 63, 20, 1)', 1 => 'rgba(35, 14, 225, 1)', 2 => 'rgba(73, 128, 13, 1)', 3 => 'rgba(238, 62, 10, 1)', 4 => 'rgba(85, 152, 95, 1)', 5 ...
Claudio's user avatar
  • 11
-2 votes
1 answer
398 views

Reference to the previous element in the array - in Javascript

How can I refer to the previous element in an array? I want to calculate the angular distance of 2 coordinates so that I can move a steering wheel. My data comes from a robot. let arrX = []; let arrY =...
Herka Bela's user avatar
1 vote
0 answers
58 views

Access X and Y coordinate data using an array - CHART.js

In my project, I have X and Y coordinate motion that allows the car to move. I want to be able to put this data into an array because I want to move a steering wheel to see where the car is going. ...
Herka Bela's user avatar
0 votes
1 answer
67 views

How to iterate over array elements inside objects in javascript

I have a graphData array and I would like to push the close price array values of this response data I got from finhub into the x key of the graphData and the timestamps into the y key of the ...
beginner's user avatar
0 votes
0 answers
64 views

ChartJS difficulty with X Axis and pulling appropriate data

I'm having some difficulties with iterating over some json data and displaying the proper X axis (Date/Time) I've tried several times to loop through the json data to extract the time for each worker ...
DEVDEVDEVDEV's user avatar
0 votes
3 answers
497 views

how to access array inside object without keys

I have a JSON data which look like this: { "chart":[ [ 1627776011000, 28 ], [ 1627776371000, 38 ], [ 1627776731000, ...
koubin's user avatar
  • 607
0 votes
0 answers
3k views

Uncaught TypeError: Cannot read properties of undefined (reading 'datasets')and(reading 'initialize')

Update: I was able to solve the error after using method provided by Mr Ivar in the comment(In config object, change ThisMonthData to data: ThisMonthData).Thank you Ivar. I am putting JSON data into ...
Lindsay's user avatar
1 vote
1 answer
99 views

Chart.js date formatting use for

How would I format data using for() and putting that data inside datasets in Chart.js. I tried and it's only showing the date labels and not the marks, but when I add data manually without using the ...
Size's user avatar
  • 31
0 votes
0 answers
39 views

Attach correct data format to draw a chart

I'm new to Vuejs, vue-Chartkick, and Chartjs. I was trying to insert the restructured data into an object to draw a multiple-series chart. But it did not work. <template> <line-chart :...
Cristian's user avatar
  • 167
1 vote
1 answer
69 views

How to convert JSON data to object that contains other objects?

I want to apply my returned data to create a line chart in Vuejs My data: [{"A": 400},{"B": 1597},{"C": 1567}] My template from vuejs: <template> <line-...
Cristian's user avatar
  • 167
0 votes
1 answer
206 views

is it possible to sum up the properties of an array of objects and to filter it according to another property?

My Title seems a bit confusing, Here's my problem, i want to destructure an array of objects in order to use it's properties in a chartJS Line Graph. Here's a reproduced array: [{ "page":...
Yacine Sidi Attallah's user avatar
0 votes
2 answers
2k views

Display php array data in chart.js javascript

I'm trying to display a chart using chart.js, the chart data would be gotten from a php mysql database and displayed into the function below; const pieChart2 = new Chart(document.getElementById('chats'...
Chima's user avatar
  • 182
0 votes
2 answers
2k views

How to pass my array of objects into a graph with Chart.js

Hello I am trying to present my array of objects in a graph with Chart.js here is the code let timers = {neutral: 0, happy: 0, sad: 0, angry: 0, surprised: 0, disgust: 0}; var detection = new Chart(c, ...
Νικόλαος Καλαμπόκας's user avatar
0 votes
4 answers
2k views

How to use forEach loop on my array to plot x and y variables on my chart (Chart.js)

I'm trying to use a forEach loop to iterate over my array that holds my x and y variables, and plot them on my chart. However, it doesnt loop through the array correctly, and when I console.log the ...
Matthew's user avatar
  • 271
1 vote
1 answer
522 views

Chart.js displaying each letter of label and data as a single value on chart. The data and labels provided are arrays

I am using Chart.js to make a line chart. The working of the code is as follows. (Snapshots of the code below) Data is retrieved from MongoDB and then the array of numerical data is passed to ejs ...
Facts Theory  Story's user avatar
-1 votes
2 answers
599 views

Return values from nested array

I'm trying to combine the string values from a nested array to display as a label on a chart.js chart I have. I have used the below code to return part of my data: const data = [ { "TITANIC....
Ghatzi's user avatar
  • 597
0 votes
1 answer
121 views

Create Chart using $getJSON and ChartJS

I need to create a chart using ChartJS and a JSON file. The format is give below and I wish to push the data into an array, where the x-Axis has the Station labeled, and the y-Axis shows the Arrivals. ...
sppokky's user avatar
  • 115
2 votes
1 answer
117 views

Creating dynamic object to reorganize API response using Typescript

Explanation of what i am doing right now: This resembles the data array I get from the API response responseBarDataStacked = [ { sku: "Data 1", month: "Jun", value: 20 }, { ...
Luzan Baral's user avatar
  • 3,698
-2 votes
2 answers
1k views

charts.js add data with date

So Im trying to find an smart way to pass data with dates to chart.js. On the x-axis i would like to show a time line for example a week, 14/06 15/06 16/06 17/06 18/06 19/06 20/6 But the data will not ...
Brendan O'Shea's user avatar
1 vote
2 answers
69 views

How to assign variables to data passed through a WEB API in Angular?

I am consuming a WEB API endpoint that returns product data. However, upon subscribing, I want to assign variables to this data to be used as part of a bar chart generated using Chart.js (Not relevant)...
SeventhWarhawk's user avatar
0 votes
1 answer
321 views

Chart.js - access yAxes properties

From everything I've seen we access the y axis on a 2-axis cartesian graph like so: chart.options.scales.yAxes[0] However I get 'undefined'. This despite the fact that my chart is generated with the ...
Clinton J's user avatar
  • 2,073
0 votes
1 answer
109 views

Trying to update data in chart.js chart

I want to have a dynamic dataset in a chart, which takes in value from an API and utilizes it as data in the chart. So I expected the chart to display the data, but instead, it shows nothing console ...
Dan's user avatar
  • 91
-2 votes
1 answer
274 views

Why is my chart not working? What am I missing

SO I am currently following a tutorial on youtube https://www.youtube.com/watch?v=sE08f4iuOhA and the guy uses a script in html. I dont want to separate them and created a js file. Seemed easy but its ...
Julius's user avatar
  • 21
0 votes
1 answer
3k views

How remove duplicates xAxis labels and show all values on chart

How i can remove all label duplicates if i remove duplicates by spread operator labelsNonUnique = [29.03,30.03,30.03,30.03,30.03,30.03,30.03,31.03,31.03,31.03,01.04,01.04,01.04,01.04,01.04,01.04,02....
RedCoub's user avatar
  • 23
0 votes
2 answers
2k views

Count the duplicates in a string array using React JS

Following is a code I implemented to create a bar chart using chart js in React app. Here it creates a bar chart with all the data in an array. But, I want to change this code only to give the output ...
user avatar

1
2 3 4 5