Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 1 min read

Support

Motivation

You want to create a simple illustration of a concept using a dynamic graph. You want to use a range control to change in input and see the impact of that change on an output.

Screen Image

Supply and Demand Dynamic Graph (Image: The original uploader was Dmccreary at English Wikibooks ., CC BY-SA 3.0)

Sample Program

This is not working yet with the range control. I wrote it with just SVG and JavaScript and I am in the process of porting it to XForms. I also need to use CSS to clean up the markup.

Price and Demand

P

Q

Demand

Input: Price =
100

Output: Quantity =
100

Adjust price by moving the slider.
Note that as the input (price) changes.
the quantity sold also changes.
At high prices a low quantity is sold.
At low prices a high quantity is sold.

Note that as the input (price) moves, the quantity sold changes.
At high prices a low quantity is sold.
At low prices a high low quantity is sold.

0 && value < 200)
{
thumb.setAttribute("transform", "translate(" + (value) + " 0)");
SliderCallback(value);
}
}

function SliderClick(event)
{
var value = event.getClientX() - parseFloat(slider.getAttribute("xoffset")) - 4;
if (value > 0 && value < 200)
{
thumb.setAttribute("transform", "translate(" + (value) + " 0)");
SliderCallback(value);
}
}

function SliderCallback(val)
{
// this is where we change the values
newPrice.setAttribute("cy", val);
horizLine.setAttribute("y1", val);
horizLine.setAttribute("y2", val);
horizLine.setAttribute("x2", val);
vertLine.setAttribute("x1", val);
vertLine.setAttribute("x2", val);
vertLine.setAttribute("y1", val);
priceText.firstChild.nodeValue=(200-val);
quantityText.firstChild.nodeValue=(val);
//= Math.round((val*1000)/1000);
window.status = "price is " + (val);
}

function OnLoadEvent(event) // called, when svg file is loaded (s. onLoad=..) ..
{
var doc = event.getTarget() != null ? event.getTarget().getOwnerDocument() : null;
if (doc != null)
{
slider = doc.getElementById("slider");
thumb = doc.getElementById("thumb");
newPrice = doc.getElementById("newPrice");
priceText = doc.getElementById("priceText");
quantityText = doc.getElementById("quantityText");
vertLine = doc.getElementById("vertLine");
horizLine = doc.getElementById("horizLine");
slider.addEventListener("mousedown", SliderDown, false);
slider.addEventListener("mouseup", SliderUp, false);
slider.addEventListener("mousemove", SliderMove, false);
slider.addEventListener("click", SliderClick, false);
}
}
]]>

100

Price:

Price:

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
This is an example of a self-referential data structure. This is common when manipulating graphs. Workflow systems frequently use these structures. ## Link to Working Example [Graph Editor]( ## XML Schema Here is a sample XML Schema with a recursive data type (a data type that includes an instance o
CC BY-SA 4.0
Try this code instead: <html xmlns:xf=" xmlns:ev=" xmlns=" <head> <title>Demo of XForms Event Logging</title> <style type="text/css"> body {font-family: Helvetica, sans-serif;} #log { font-size: 8pt; color: SlateGray; background-color: lavender; border: 1px solid SlateGray; } </style> <xf:model> <xf
CC BY-SA 4.0
In the example above I used a test folder on the localhost: [ xquery version "1.0"; declare namespace exist = " declare namespace system=" declare namespace request=" declare option exist:serialize "method=xml media-type=text/xml indent=yes"; (: replace demo :) let $input := request:get-parameter('i
CC BY-SA 4.0
*/ .inspector xf|input > xf|label, .inspector xf|select > xf|label, .inspector xf|select1 > xf|label, .inspector xf|textarea > xf|label {text-align:right; padding-right:10px; width:200px; float:left; text-align:right;} /* This line ensures all the separate label controls in the inspector appear on t
CC BY-SA 4.0
This example assumes that the user wants to do these operations on a simple form and guides the user through a series of questions. A series of defaults is assumed but the user is allowed to override these defaults when the requirements differ from the standard. The phrase "convention over configura
CC BY-SA 4.0
In our example a dashboard may have up to 36 portlets, but best practices usually contain 7 portlets plus or minus one or two. ## Application Design Our dashboard layout will be one of three types: - row oriented where all portlets in a row have the same height - column oriented where all portlets i