"Exploring the Power of Logarithmic Slider with Vue and Quasar

I'm currently working on a project utilizing Vue 2 and Quasar 1, where I am attempting to develop a logarithmic slider. Initially, I managed to create a basic example using a native input slider in this code pen: https://codepen.io/tonycarpenter/pen/ZEVKWbr?editors=1111

function calculateLogarithmicSlider(min, max, sliderPosition) {
  const minimumSliderValue = Math.log(min);
  const maximumSliderValue = Math.log(max);
  const sliderScale = (maximumSliderValue-minimumSliderValue) / (100);
  return Math.exp(minimumSliderValue + sliderScale*(sliderPosition));
}

function calculateSliderValue (min, max, sliderPosition) {
    return Math.round(calculateLogarithmicSlider(min, max, sliderPosition));
}

const smartRange = {
    props: ['min', 'max'],
    template:
`
    <div>
        <label> MIN: {{ min }} MAX: {{ max }} <label>
        <input v-on:input='update($event)' type='range'>
    </div>
`,
    methods: {
        update(event) {
            const sliderPosition = parseInt(event.target.value)            
            const sliderValue = calculateSliderValue(this.min, this.max, sliderPosition)
            this.$emit('change', sliderValue)
        }
    }
}


const app = new Vue({
    el: document.querySelector('#app'),
    components: { smartRange },
    data: {
        value: 0
    },
    methods: {
        updateVal(newVal) { this.value = newVal }
    }
})

My current challenge involves binding this logic to a Quasar slider with an accompanying tooltip that reflects the exponential increase while sliding. I have provided a link to the specific Quasar slider implementation below: https://codepen.io/tonycarpenter/pen/bGOWXKG

While researching solutions online, I stumbled upon one that uses a Quasar range slider with Vue 3 and Quasar 2. However, I would appreciate further clarification as I am not well-versed in Vue 2 compared to Vue 3: https://codepen.io/pdanpdan/pen/XWYPZMq?editors=1111

Any assistance or guidance in this matter would be immensely valuable!

Answer №1

I've created a custom slider for you, feel free to check it out here:

https://codepen.io/prince_61/pen/ZEVyQBQ

<div id="q-app" style="min-height: 100vh;">
  <div class="q-pa-md">
    <q-badge color="secondary">
      Model: {{ redModel }} (0 to 100, step 100)
    </q-badge>
    <q-slider
      v-model="redModel"
      color="red"
      :step="1"
    ></q-slider>
  </div>
</div>
const { ref } = Vue

const app = Vue.createApp({
  setup () {
    return {
      redModel: ref(25),
    }
  }
})

app.use(Quasar, { config: {} })
app.mount('#q-app')

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

What is the purpose of using square brackets in the angular.module() function in AngularJS?

const myapp=angular.module('myApp',[]); As someone venturing into the realm of angularjs, I have a question. What is the significance of using [] in angular.module()? If anyone could shed some light on this, it would be greatly appreciated. ...

Creating an interactive map on WordPress: A step-by-step guide

I have successfully created a clickable image on Codepen <div style="width: 1000px; height: 993.73px;"> <img src="https://www.dyfedarchaeology.org.uk/wp/wp-content/uploads/Testmap.svg" alt=&q ...

Create a PDF document using a combination of charts and tables

When I try to create a PDF file with both the chart and table embedded, only the table is showing up. Can someone please provide me with some suggestions on how to resolve this issue? JSFIDDLE LINK ...

How can I extract a substring from a URL and then save it to the clipboard?

Hi there! I'm working on a project for my school and could really use your expertise. I need help extracting a substring from a URL, like this one: URL = https://www.example.com/blah/blah&code=12432 The substring is: 12432 I also want to display ...

Exploring the efficient incorporation of common scripts within VueJS components

I'm having an issue with a component (shown below) when trying to use a method from a JavaScript file. However, it doesn't seem to be working correctly. Can anyone advise on the correct way to execute this? <template> <div id="test"&g ...

Having trouble with d3 / svg layering when introducing new nodes overtime

Struggling with a frustrating issue on my d3 force directed map project. Initially, I render the necessary nodes and links, then periodically check for updates through AJAX. The problem arises when adding new nodes and links – they appear over existing c ...

Utilizing margins in CSS for various div elements

Update: I have included Javascript and Masonry tags in my project. Despite having modules of the same size, I am exploring how masonry can assist me. However, I find it a bit puzzling at the moment as I am not aiming to align elements of different sizes. I ...

Randomly retrieving Vue data from a JSON source

For my first venture into creating a quiz app with Vue and Tailwind, I want to ensure that the quiz's content appears different each time it is accessed. Currently, I have set up my Vue component to display data from a JSON file in the following manne ...

Learn the steps to retrieve a user's profile picture using the Microsoft Graph API and showcase it in a React application

I'm currently working on accessing the user's profile picture through Microsoft's Graph API. The code snippet below demonstrates how I am trying to obtain the profile image: export async function fetchProfilePhoto() { const accessToken = a ...

The callback information is not being properly identified

I need help with deleting an entire row when the Delete button is clicked using jQuery. Here is my current approach: UPDATE: I have made final adjustments to the click function: $(document).on('click', '.delete-assignment',function () ...

Is there a Webpack plugin available that can analyze the usage of a function exported in a static

Just to clarify, I am presenting this theoretical scenario on purpose, as it reflects a genuine issue that I need to solve and am uncertain if it's feasible. Imagine I have a JavaScript package named road-fetcher, containing a function called find wh ...

Is it not possible to use GLOB with JSHint on Windows operating systems?

Currently, I am experimenting with using NPM as a build tool (). My experience with NPM is limited, and at the moment I only have JSHint and Mocha installed. Attached is my package.json file. However, when I try to run "npm run lint" in the Windows 7 comma ...

Having trouble accessing a PDF file using gview

Having trouble opening a document I am unable to preview the documents and I'm not sure what I'm missing. I have read through various StackOverflow questions and answers related to this issue, but still no luck. url = http://192.168.0.6:8077/ ...

Tips on using the html() and toContain() functions in shallowMount in Vue to test a div that includes another component

I am encountering an issue with shallowMount in Vue. Here is my function: describe('ParentComponent.vue', () => { it('renders a ParentComponent', () => { const wrapper = shallowMount(ParentComponent, { propsData: { ...

Experimenting with Nuxtjs application using AVA and TypeScript

I'm in the process of developing a Nuxt application using TypeScript and intend to conduct unit testing with AVA. Nonetheless, upon attempting to run a test, I encounter the following error message: ✖ No test files were found The @nuxt/typescrip ...

Using AJAX to retrieve additional JavaScript code or functions from the server

It's common knowledge that AJAX is often utilized to request a web part in HTML format from the server. However, is it feasible to use AJAX to request a script that includes functions? ...

Delete a designated section from a URL with the power of jQuery

I have a URL like http://myurleg.com/ar/Message.html and I need to change ar to en in it when clicked on. For example, if my current URL is: http://myurleg.com/ar/Message.html After clicking, it should become: http://myurleg.com/en/Message.html I attemp ...

What is the process for adding a highlighted area beneath a curve on a high chart?

I am working on creating a high chart with Angular 4 and I have a specific requirement to highlight certain portions of the Highchart. For example, in the image: In the image above, if a data point value drops below a certain limit (such as 0), it shoul ...

The error message in React Hook Form states that the handleSubmit function is not recognized

I'm facing an issue with using react-hook-form for capturing user input. React keeps throwing an error that says "handleSubmit is not a function". Any suggestions on how to resolve this would be highly appreciated. Here's the code snippet I&apos ...

Establishing a global variable in Cypress through a function

My current workflow involves the following steps: 1) Extracting a field value from one page: var myID; cy.get('#MYID'). then(($txt) => { myID= $txt.text(); }) .should('not.equal', null); 2) Mo ...