logo
down
shadow

issue with data from array using vue.js


issue with data from array using vue.js

By : user3099832
Date : January 11 2021, 05:14 PM
I wish did fix the issue. I have a pie chart that shows data from my array. I also generated a new array from the data but it is not mapping correctly. How do I make the chart display either the people's jobs on it. The legend should possible be a list of set of jobs (Dentist, Teacher, etc) and the graph should show the amount that are dentist, the amount that are teachers, etc or another alternative is age. The legend show the 3 different ages and it maps to the persons name. An example of either of these scenarios would be great. ,
Use a data member to track 'Name' or 'Job'
code :
function groupBy(list, keyGetter) {
  const map = {};
  list.forEach((item) => {
    const key = keyGetter(item);
    const collection = map[key];
    if (!collection) {
      map[key] = [item];
    } else {
      collection.push(item);
    }
  });
  return map
}


new Vue({
  el: "#app",
  data: {
    field: 'Age',
    location: [],
    numbers: [2, 3, 4, 4, 2, 3],
    People: [{
      Name: "Adam",
      Age: "32",
      Job: "Dentist"
    }, {
      Name: "Bill",
      Age: "22",
      Job: "Teacher"
    }, {
      Name: "Peter",
      Age: "42",
      Job: "Dentist"
    }]
  },
  methods: {
    toggle: function() {
      this.field = this.field == 'Job' ? 'Age' : 'Job'
    }
  },
  computed: {
    rows() {
      let byGroup = groupBy(this.People, it => it[this.field])
      return Object.entries(byGroup).map(en => ([en[0], en[1].length]))
    }
  }
})
<script src="https://unpkg.com/chart.js@2.7.2/dist/Chart.bundle.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://unpkg.com/vue-chartkick@0.5.1"></script>
<div id="app">
  <h2>Function:</h2>
  <button @click='toggle'>Toggle</button>
  <h3>By {{field}}</h3>
  <span v-for='row of rows' style='margin:10px;'>{{row[0]}}:{{row[1]}}</span>
  <pie-chart :data="rows" legend="bottom"></pie-chart>
  <br>
</div>


Share : facebook icon twitter icon
array data using php issue

array data using php issue


By : user3440509
Date : March 29 2020, 07:55 AM
will help you When a parameter name ends with [...], that isn't part of the $_POST key, it causes that $_POST variable to be a sub-array. You need to access it with multi-dimensional array syntax. So $_POST['option[0]'] should be $_POST['option'][0], and similarly for all the other elements of that array.
OOP Issue Stopping PHP Functioning & MySQL Data Array Retrieval Issue

OOP Issue Stopping PHP Functioning & MySQL Data Array Retrieval Issue


By : user3707272
Date : March 29 2020, 07:55 AM
I hope this helps you . Now a very kind StackOverflow use has helped me out with a lot of my issues however there's two remaining probelms with my code before it's ready to go, any ideas would be great as i'm currently screaming at it: , This:
code :
<?php

function Widget($input) {
    $currentValue = $input; // Set internal variable from input (Think of this as an initial "remainder")
    $i = 0;
    $widgetBatches = [250, 500, 1000, 2000]; // Setup batch array

    while ($currentValue > 0) { // While the remainder is more than 0
        $i++;
        echo "Iteration " . $i . "<br/>";
        echo "Widget requested: " . $currentValue . "<br/>";
        $closest = GetClosest($widgetBatches, $currentValue); // Find the closest value from batch array
        echo "Closest: " . $closest . "<br/>";
        $currentValue = $currentValue - $closest; // Work out new remainder
        echo "Remainder: " . $currentValue . "<hr/>";
    }

    // Loop will exit when remainder is less than 0
    echo "The value is now below or equaling zero: " . $currentValue . "!";
}

function GetClosest($array, $value) {
    $result = null; // Innitialise the returned variable in case of failure
    foreach($array as $val) { // For every array value, unless stopped
        $result = $val; // Set result to current array value
        if($value <= $result) break; // Stop foreach loop if value is less than or equal to result
    }
    return $result; // Return last result from Foreach loop
}

Widget(9000);

?>
Having issue on loading complex attributes data into array of array

Having issue on loading complex attributes data into array of array


By : Raj Vasari
Date : March 29 2020, 07:55 AM
will be helpful for those in need You can surround the data-size attribute value in brackets, after which you can JSON.parse it to get an array of arrays from it. Then, flatten the array, and cast the size items to strings:
code :
const dataArray = [...$(".data")].map(({ dataset }) => {
  const { number, avaiable, brand, size, app } = dataset;
  const flattenedStringSize = JSON.parse('[' + size + ']')
    .flat()
    .map(String);
  return [number, avaiable, brand, ...flattenedStringSize, app];
});
console.log(dataArray);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="data" data-number="1" data-avaiable="true" data-brand="X1" data-size="[48, 14,139]" data-app="android"></div>
<div class="data" data-number="3" data-avaiable="false" data-brand="M200" data-size="[49,15,135],[51,15,140]" data-app="ios"></div>
<div class="data" data-number="5" data-avaiable="true" data-brand="T500" data-size="[49,800,135],[51,200,140],[52,16,141]" data-app="windows"></div>
const dataArray = [...document.querySelectorAll(".data")].map(({ dataset }) => {
  const { number, avaiable, brand, size, app } = dataset;
  const flattenedStringSize = JSON.parse('[' + size + ']')
    .flat()
    .map(String);
  return [number, avaiable, brand, ...flattenedStringSize, app];
});
console.log(dataArray);
<div class="data" data-number="1" data-avaiable="true" data-brand="X1" data-size="[48, 14,139]" data-app="android"></div>
<div class="data" data-number="3" data-avaiable="false" data-brand="M200" data-size="[49,15,135],[51,15,140]" data-app="ios"></div>
<div class="data" data-number="5" data-avaiable="true" data-brand="T500" data-size="[49,800,135],[51,200,140],[52,16,141]" data-app="windows"></div>
Issue passing data from an array to another array in codeigniter

Issue passing data from an array to another array in codeigniter


By : user3213571
Date : March 29 2020, 07:55 AM
Any of those help i have a problem on passing data result to another data request in a controller in codeigniter is there something i'm missing ? , Change your controller like this.
code :
public function index()
    {
        //sending $data array of variables to view's or to model's
        $data = array('header_title' => 'Nova Democracia - Eleições 2019 - Menu');

        $data['formData'] = $this->Crud_model->getProvinciaAndLocal($this->session->id_local);

        $data['locais'] = $this->Crud_model->getLocaisByIdLocal($data['formData']["id_distrito"]); // Notice the change here

        $this->load->view("form_menu/form_menu.php", $data);
    }
Issue with getting data from array

Issue with getting data from array


By : Daniel Yastishock
Date : March 29 2020, 07:55 AM
Does that help You are overwriting your array in the loop, casting it to a string when you add a string to it. You should use a different name for the string you are building.
Although you don't really need a loop for this, you can replace your code with just:
Related Posts Related Posts :
  • Vue-router: Using component method within the router
  • [Vue warn]: Property or method "Boston" is not defined on the instance but referenced during render
  • Vue npm run serve starts on random port
  • Why vue need to forceUpdate components when they include static slot
  • Vuex - mapGetters et al but mapping by parameter
  • Vuetify - tabs with vue components
  • How to use prismic group fields as items in a vuetify v-select element?
  • Vue does not update items in v-for from Vuex with dynamic component
  • What is this syntax `${k}` in vuejs's property?
  • How can i get an API response status code to highlight v-text-field
  • Check if object is undefined
  • How to pass data to a slot in vue2.6
  • Vuetify.js: How do I change color of v-btn component when clicked
  • Unhandled rejection Error When Building Vue.js Project
  • Problems with the work of preloader vue.js
  • Vuex and form handling using v-model
  • Show updated PWA created in Vue
  • How to extend a Vue component with pug in Nuxt?
  • How to pass dynamic image url in nuxt project
  • Vuejs 2 terminal directives or higher priority directives?
  • Exclude json file from being bundled in Vue
  • Why Vuex-persist doesn't store anything in localStorage?
  • How can I make Vuex store work with Storybook?
  • v-model and selected is not working at the same time... --vue.js
  • How to set $ref to child component elements from parent component in vuejs?
  • Is there anyway to set a different value for the "input" than the vue variable?
  • Next and Previous month watcher in Vue FullCalendar
  • How to make font size responsive using vuetify?
  • window is not defined vuejs and vuetify SSR
  • Vue-router appending the same URL
  • why custom delimiters {{{}}} dont work in vuejs?
  • VS code - formatting arrays in .vue files
  • What's the easiest way to implement routes in vue.js?
  • Export to excel on vuetify data table
  • Problem when importing js-cookies in Main.js
  • Vue initializing props to data for mutation but Error in data(): "TypeError: Cannot read property 'propsTitle' of u
  • How can I add an href to a q-table (Quasar Data Table)?
  • Vue nested routing does not including dynamic parameters
  • How to change Vuestic Admin theme favicon
  • Override Vuetify 2.0 sass variable $heading-font-family
  • $.parent vs emitting and listening events performance comparison
  • error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'Starscream')
  • How do I combine vue, i18n and markdown pages?
  • How do you dynamically create multiple bootstrap cards with Vue
  • Should I be storing all my Vue methods and data in one file?
  • How do I bind a style to my v-for loop in this example?
  • Why is Vue v-bind:class not updating?
  • Jest unable to load module vue-cookies
  • Embedding javascript into html in Vue
  • Why vuex-orm returns null in relationship field?
  • Nuxt.js - 'error not defined' when trying to throw 404 in failed await call within asyncData method
  • Deploying Vue.js App using azure devops release pipeline
  • Vue - how to recognize [__ob__: Observer]?
  • Is there a way to call a method with parameters in data on vue 2?
  • How to change style depend on key in v-for?
  • Vue-Owl-Carousel not working when using Loop
  • Vuex: Best Way To Handle actions
  • Vue.js: field values go back as soon as they lose focus
  • Wait until API fully loads before running next function -- async/await -- will this work?
  • bind an event listener to a newly rendered dynamic elements
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org