Scriptaculous slider price range slider with two handle - prototypejs

I'm using Scriptaculous to create a price range slider with two handles says minimum and maximum values. How can I store minimum and maximum values in separate hidden field.
Current script as follows,
<div id="price-range" class="filter-track">
<span id="price-min" class="filter-handle" title="Scroll to set your minimum value">>></span>
<span id="price-max" class="filter-handle" title="Scroll to set your maximum value"><<</span>
</div>
<input type="hidden" name="price" id="beds" value="0,100"/>
var loadPriceSlider = function () {
var handles = [$('price-min'), $('price-max')];
// horizontal slider control with preset values
new Control.Slider(handles, 'price-range', {
range:$R(0, 5000, false),
sliderValue: [0, 3000],
values: [0, 100, 200, 300],
restricted: true,
onChange: function(v){
$('price').value = v;
}
});
};
It will store comma separated (min,max) values in price field. but i would like to store this in separate field. How to do this? Any help please?

Your code tries to refer to $('price') but you the input with the name 'price' has the 'id' of 'beds'.
Here's corrected HTML which has the price field, and an additional field:
<div id="price-range" class="filter-track">
<span id="price-min" class="filter-handle"
title="Scroll to set your minimum value">>></span>
<span id="price-max" class="filter-handle"
title="Scroll to set your maximum value"><<</span>
</div>
<ul>
<li>price: <input type="text" name="price" id="price" value="0,100"/></li>
<li>myRange <input type="text" name="myRange" id="myRange" value="0,100"/></li>
</ul>
And the JavaScript:
var handles = [$('price-min'), $('price-max')];
// horizontal slider control with preset values
new Control.Slider(handles, 'price-range', {
range: $R(0, 5000, false),
sliderValue: [0, 3000],
values: [0, 100, 200, 300],
restricted: true,
onChange: function(val){
$('price').value = val;
$('myRange').value = val;
}
});
This works, loading these JavaScript:
<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js?load=slider"></script>

Related

How can I create a number range filter in react table v7?

How can I create a number range filter in react table v7? Here is my relevant column definition, and filter function.
// The Filter function
import { Box, Input } from '#mui/material';
const NumberFilter = ({ column, data }) => {
const { filterValue = [], setFilter } = column;
console.log('filterValue: ' + filterValue);
return (
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
<Input
placeholder="Min"
value={filterValue[0] || ''}
type="number"
onChange={(e) => {
setFilter([e.target.value || undefined, filterValue[1]]);
}}
/>
<Input
placeholder="Max"
value={filterValue[1] || ''}
type="number"
onChange={(e) => {
setFilter([filterValue[0], e.target.value || undefined]);
}}
/>{' '}
</Box>
);
};
export default NumberFilter;
// The column definition...
{
Header: 'Pant Size',
accessor: 'pant-size',
Filter: NumberFilter,
filter: 'isNumberRange',
filterValue: [0, 10],
Cell: ({ value}) => value);
}
This does not work. Instead of filtering all rows that have a value within the range of min and max, the column seems to be doing text matching, which is the default.
I think my issue is that there are various options for the filter parameter. For example, 'text' and 'exact'. I read somewhere that there is an option for numeric ranges and it was "isNumberRange". This clearly is incorrect. Is there another option? Does anyone know where this documentation lives?

Google column chart y axis start reverse

As you see in picture: https://imgur.com/kDBu95D column that has 0 data is higher than column with value of 1 and 2. And y axis starting reverse, 0 is on the top instead on bottom. This happened when I use laravel eloquent.
Here is my code:
#extends('layouts.app')
#section('content')
<div class="container">
<script type="text/javascript">
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['User', 'Added'],
#if ($users)
#foreach ($users as $user)
['{{$user->name}}', '{{$user->members->count()}}'],
#endforeach
#endif
]);
var options = {
chart: {
title: 'Users',
},
vAxis: {
format: 'decimal',
},
};
var chart = new google.charts.Bar(document.getElementById('columnchart_material'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
</script>
<div id="columnchart_material" style="width: 'auto'; height: 500px;"></div>
</div>
#endsection
I tried to add this:
vAxis: { minValue: 0 },
and this:
vAxis: { direction: -1, },
but nothing helps...
looks like the values for the y-axis are strings instead of numbers...
remove the single quotes from the second array value...
change --> ['{{$user->name}}', '{{$user->members->count()}}'],
to --> ['{{$user->name}}', {{$user->members->count()}}],

kendo ui using slider with a template

I'm using a slider inside of Kendo UI Template.
<script type="text/x-kendo-template" id="template3">
<div>
<b> Grades: </b> <br />
<input id="slider" class="temperature" value="#= temper #" data-bind="value:temper"/>
</div>
</script>
The template is called by edit function on the grid.
var grid = $("#grid").kendoGrid({
editable: {
mode:"popup",
template:kendo.template($("#template3").html())
},
...
I created the JS slider
var slider = $("#slider").kendoSlider({
increaseButtonTitle: "Right",
decreaseButtonTitle: "Left",
min: 0,
max: 5,
smallStep: 1,
largeStep: 2
}).data("kendoSlider");
The problem is that the Slider is not displayed on the popup editor. Only is displayed the value. Could anybody please help me?
Your slider element isn't initially available thus $("#slider") returns nothing. You should call this code once the grid initializes its editor template. Use the edit event of the grid for that:
var grid = $("#grid").kendoGrid({
editable: {
mode:"popup",
template:kendo.template($("#template3").html())
},
edit: function() {
$("#slider").kendoSlider({
increaseButtonTitle: "Right",
decreaseButtonTitle: "Left",
min: 0,
max: 5,
smallStep: 1,
largeStep: 2
})
}
Alternatively you can set the data-role attribute:
<script type="text/x-kendo-template" id="template3">
<div>
<b> Grades: </b> <br />
<input data-role="slider"
data-min="0"
data-max="0"
data-small-step="1"
data-large-step="2"
class="temperature"
data-bind="value:temper"
/>
</div>
</script>

Rickshaw Log scale graphs and slider scaling

I've been trying to understand how the sliders in Rickshaw/D3 interact with the scaling of a graph. It seems that when I use both together for a dynamic graph which displays a subset of the data selected by the slider, the log scale is not correct. Is there something I'm not doing right? Here is a jsfiddle and a subset of the code is here.
The HTML used to initialise the graphs:
<div id="time">
<div id="yearindicator"></div>
<div id="slider-range"></div>
</div>
<div id="charts" class="clearfix">
<div class="chart">
<h3>Total</h3>
<div id="y_axis"></div>
<div id="chart_one"></div>
</div>
</div>
And a subset of the javascript is
logScale = d3.scale.log().domain([1, 1000]).range([0, 1]);
var data = [ {.... data not shown }];
var graph_one = new Rickshaw.Graph({
element: document.querySelector("#chart_one"),
height: 400,
width: 400,
renderer: 'scatterplot',
series: data
});
new Rickshaw.Graph.Axis.X({
graph: graph_one
});
new Rickshaw.Graph.Axis.Y.Scaled({
graph: graph_one,
orientation: 'left',
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
element: document.getElementById('y_axis'),
scale: logScale
});
graph_one.render();
var slider_one = new Rickshaw.Graph.RangeSlider({
element: document.querySelector('#slider-range'),
graph: graph_one
});
var y_ticks = new Rickshaw.Graph.Axis.Y.Scaled({
graph: graph_1,
orientation: 'left',
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
element: document.getElementById('y_axis'),
scale: logScale
});

Persisting the default value of the numeric text after deleting entered value

Have a look at the sample here.
The problem I have is that I need to have 0.00 value remain in the numerictextbox even though the value is deleted in the control. At the moment it appears as empty on the UI. Can anyone advise the cleanest solutions for problem?
You can achieve your goal wiring the change event of the widget and modify its value and the model's one when it is triggered.
<div id="view">
<div data-template="containertpl" data-bind="source: People"></div>
<button data-bind="click: AddNew">Add</button>
</div>
<script id="containertpl" type="text/x-kendo-template">
<div>
<label for="FirstName#:id#">Name</label>
<input name="FirstName#:id#" type="text" data-bind="value: FirstName"/>
<input data-role="numerictextbox" data-bind="value: Income, events: { change: numericChange }"/>
</div>
</script>
var viewModel = kendo.observable({
People: [
{id: 1, FirstName: "", Income: "0.00" },
{id: 2, FirstName: "", Income: "0.00" },
{id: 3, FirstName: "", Income: "0.00" }
],
numericChange: function(args) {
var numeric = args.sender;
if (numeric.value() === null) {
numeric.value(0);
args.data.set("Income", 0);
}
}
});
viewModel.AddNew = function(){
viewModel.People.push({id: viewModel.People.length + 1, FirstName: "Generated", Income: "0.00"});
};
$(document).ready(function(){
kendo.bind($("#view"), viewModel);
});

Resources