score:7
Part of your problem stems from pushing the same object into the 2 different arrays here:
for(i = 0; i < languages.length; i++) {
currentLanguage = new Language(languages[i].language)
learningLanguages.push(currentLanguage)
nativeLanguages.push(currentLanguage)
}
This does not copy currentLanguage
into each, it pushes references of the same object into each.
Then whatever you do to that object reference in one will be reflected in the other
Try making 2 separate objects
for(i = 0; i < languages.length; i++) {
learningLanguages.push(new Language(languages[i].language))
nativeLanguages.push(new Language(languages[i].language))
}
the use of global variables will also get you into trouble...don't do it!
score:1
learningLanguages = []
nativeLanguages = []
These two variables look like they are not defined in an above scope - thus the second XHR call does not know about these variables.
Second piece of the answer is reference to the same object instance, with the same "count" attribute touched twice.
I'd suggest two options are here:
- use
new Language(...)
for each of these two arrays separately - or have a separate counter for each type of
native/learning
counts.
Source: stackoverflow.com
Related Query
- Can't figure out why the values in my objects are changing
- Why are changing the time value of my axis (moment.js)?
- How to rename properties in objects that are in an array. What is the right way to solve the task?
- Chart.js. Values in a big range. The smallest values are not available
- Why are the default Chart.js legend boxes transparent rectangles?
- Why are my two charts repeating the same label?
- Why are the chartjs tooltip labels always showing the first x-axis label?
- Can't figure out how to skip first datapoint on the x-axis and labels on X-axis skip second-to-last datapoint with Chart.js
- ChartJS : Hook before values are given to doughnut (absolute value in chart and real values in the tooltips)
- chart js: when all the values passed to data are zeros, nothing is showing
- How to stop displaying the data values from different data objects on Chart JS 2.x?
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- If a radar chart values are full it occupies half the space (Chart.js)
- how can i grab a property from an array of JSON objects to use the values of that property as a labels in my chart?
- Why the bar are not aligned the y axis
- Change the Y-axis values from real numbers to integers in Chart.js
- Why is chart.js canvas not respecting the padding of the container element?
- Chart.js: passing objects instead of int values as data
- ChartJS and jsPDF - why the background is black?
- Using Chart.js - The X axis labels are not all showing
- how to change the Y-axis values from float number to integer in chartjs?
- What is the order in which the hooks (plugins) of Chart.js are executed?
- Why are these 2.9 ChartJS bar charts different?
- Chart.js PolarArea Chart. Changing the labels to a 45 degree angle
- Why can I not see a data value when hovering over a point on the radar chart?
- Changing the base of the logarithmic scale in Chart.js
- Changing the Y axis unit in Chartjs
- Line ChartJS empty / null values doesn't break the line
- How to change the Y-axis values from numbers to strings in Chart.js?
- Why chart.js charts are not plotting data in Safari (works in Chrome)
More Query from same tag
- ChartJS - Help me custom tooltip
- Draw vertical line on horizontalBar at value 2.0
- How to add label square to Bar Chart using Chart.js
- How to change the z order of a chartjs polar chart
- Generate PDF from HTML page made with Bootstrap and ChartJS in Laravel
- Chart.js shaded regions
- How to use log scale with Chart Kick?
- Gradient colour in backgroundColor JS
- How to create a chart-js pie chart with PHP data variables?
- ChartJS showing old values when mouse over on Doughnut after updating values
- Draw Line Chart Using Chart.js
- How to apply data dynamically on initialisation for chart.js in angular?
- Angular 2 ng2-charts doughnut text in the middle disappears on mouse hover
- Chart.js: change title/legend positon to right
- chart.js label color change based on value
- Chart JS not showing all data
- chart.js how to make x-axis labels position top
- How to use same data / labels on two y axes in Chart.js
- How can i display my data in a chart using chart js
- Chart.JS, date issues when upgrading to v3
- Add Horizontal crosshairs using Chart.js
- 2 or more charts on same page?
- Passing text to a popup window opened in a JS function
- Chartjs line graph point hover animation buggy / jumpy
- How to show different tooltips on charts (in columns)?
- How to convert JSON data to object that contains other objects?
- Charts.js candlestick (Financial Charts) displays half the bar in the beginning and the end
- Chart.js - Uncaught ReferenceError: chart is not defined
- JS Chart: do not merge duplicate x axis labels
- How to add prefix to legend in ng charts using angular