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
- Chart.js: Legend doesn't update on first call to chart.update()
- Resize pie chart from chart.js
- how can i add value on bar in the charts in chart.js vs 3.x
- Displaying multiple line graphs on one page
- Chart.js - Hover labels to display data for all data points on x-axis
- Is it possible to create different stepsize for different yAxis intervals on chartJs?
- How do I place 2 <div>s side by side
- How can I change the background colors of a bar chart after it has been created?
- Displaying dataset labels in Chart.js line graph
- Chart.js v2: How to make tooltips always appear on pie chart?
- Scatter plot not showing anything chartjs needs some debugging
- How to get labels on ChartJS Pie chart segments
- Different styles in ticks on ChartJS
- ChartJS - Injecting data from the server-side
- Order and hide items of legend by value with Chartjs Angular
- Chart.js glitches and reverts to previous dataset on hover
- How to push datasets dynamically for chart.js (bar chart)?
- Chart.js dynamic dataset and tooltip on stacked bar
- Django integration with Charts.js, I'm unable to find the syntax for passing the data to the template
- Chartjs - keeping 2 graphs aligned side by side
- Is it possible to add a custom font to chart js?
- Chart.js custom charts
- How to add conditional fill color in Chart.js area chart?
- chartJS doesn't show graphs on iphone/ipad
- Chart.js v2 overwrite draw function
- Chart Js Change Label orientation on x-Axis for Line Charts
- Angular 4:PrimeNg DoughnutChart dynamic data issue.
- Type can not be assigned in react-chartjs-2
- Customize Pie Chart Legend in chart.js
- How to assign variables to data passed through a WEB API in Angular?