Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing to use models instead of observables #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions Samples/Visualization/Charting/BarChart.ux
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
<ChartPage Title="Vertical orientation bar chart" File="BarChart" ux:Class="BarChart" xmlns:c="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")
function Item( x, y ) {
this.x = x
this.y = y
this.label = "" + x
}

function gauss( x ) {
var sigma = Math.sqrt(15)
var a = 1 / (sigma * Math.sqrt(2 * Math.PI))
var b = 0
var c = sigma
return a * Math.pow( Math.E, -(x - b)*(x-b) / (2*c*c) )
}
exports.data = Observable()
exports.data2 = Observable()
for (var i=-15; i <= 15; ++i ) {
var item = new Item(i, gauss(i));
exports.data.add( item )
exports.data2.add( Math.max(0, item.y + (Math.random()-0.3)*0.04) )
}

exports.offset = Observable(0)
exports.incrOffset = function() {
exports.offset.value += 1
}
exports.decrOffset = function() {
exports.offset.value -= 1
}
</JavaScript>
<ChartPage Title="Vertical orientation bar chart" File="BarChart" ux:Class="BarChart" xmlns:c="Fuse.Charting" Model="BarChart">
<AttractorConfig Unit="Normalized" Easing="SinusoidalInOut"
Duration="0.3" DurationExp="0" ux:Global="plotAttract"/>

Expand Down
3 changes: 2 additions & 1 deletion Samples/Visualization/Charting/Charting.unoproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Fuse.Charting",
],
"Includes": [
"*"
"*",
"*.js:FuseJS",
]
}
35 changes: 1 addition & 34 deletions Samples/Visualization/Charting/DoubleBarChart.ux
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
<ChartPage Title="2-series with side-by-side bars" File="DoubeBarChart" ux:Class="DoubleBarChart" xmlns:c="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")
function Item( x, y ) {
this.x = x
this.y = y
}

function gauss( x, u ) {
var sigma = Math.sqrt(u)
var a = 1 / (sigma * Math.sqrt(2 * Math.PI))
var b = 0
var c = sigma
return a * Math.pow( Math.E, -(x - b)*(x-b) / (2*c*c) )
}

function gaussItems( o, u, f ) {
var items = []
for (var i=-7; i <= 7; ++i ) {
items.push( new Item(i, gauss(i + o, u)*f ) )
}
return items
}

exports.data1 = Observable()
exports.data2 = Observable()
exports.data1.replaceAll( gaussItems( 0, 7, 1 ) )
exports.data2.replaceAll( gaussItems( 5, 15, 0.5 ) )

exports.random = function() {
exports.data1.replaceAll( gaussItems( Math.random() * 6 - 3, Math.random() * 6 + 4, 1 ) )
exports.data2.replaceAll( gaussItems( Math.random() * 6 + 1, Math.random() * 8 + 11, 0.5 ) )
}
</JavaScript>
<ChartPage Title="2-series with side-by-side bars" File="DoubeBarChart" ux:Class="DoubleBarChart" xmlns:c="Fuse.Charting" Model="DoubleBarChart">
<c:Plot Margin="5,20,20,10">
<c:DataSeries Data="{data1}" ux:Name="series0"/>
<c:DataSeries Data="{data2}" ux:Name="series1"/>
Expand Down
19 changes: 1 addition & 18 deletions Samples/Visualization/Charting/FullBarChart.ux
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
<ChartPage ux:Class="FullBarChart" File="FullBarChart" Title="Selectable full height bars" xmlns:c="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")

function Item( value, label ) {
this.value = value
this.label = label
}
exports.data = Observable(
new Item(7, "2007"),
new Item(20, "2008"),
new Item(13, "2009"),
new Item(27, "2010"),
new Item(15, "2011"),
new Item(5, "2012"),
new Item(50, "2013")
);
</JavaScript>
<ChartPage ux:Class="FullBarChart" File="FullBarChart" Title="Selectable full height bars" xmlns:c="Fuse.Charting" Model="FullBarChart">
<c:Plot YRange="0,60" YAxisSteps="6" Margin="20,10,50,10" ux:Name="plot">
<Selection/>
<c:DataSeries Data="{data}"/>
Expand Down
10 changes: 2 additions & 8 deletions Samples/Visualization/Charting/GroupLine.ux
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
<ChartPage ux:Class="GroupLine" File="GroupLine" Title="Lots of data in groups" xmlns:c="Fuse.Charting">
<ChartPage ux:Class="GroupLine" File="GroupLine" Title="Lots of data in groups" xmlns:c="Fuse.Charting" Model="GroupLine">
<JavaScript>
var Observable = require("FuseJS/Observable")

exports.items = Observable()
for (var i=0; i < 500; ++i) {
exports.items.add( Math.sin(i / 20.0) * Math.cos(i/40) )
}

//the very small step values are to show the offseting/scrolling of groups in detail
exports.incrOffset = function() {
plot.stepOffset(1)
}

exports.decrOffset = function() {
plot.stepOffset(-1)
}
Expand Down
23 changes: 2 additions & 21 deletions Samples/Visualization/Charting/HorzLine.ux
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
<ChartPage ux:Class="HorzLine" File="HorzLine" Title="Decorated line chart" xmlns:c="Fuse.Charting">
<ChartPage ux:Class="HorzLine" File="HorzLine" Title="Decorated line chart" xmlns:c="Fuse.Charting" Model="HorzLine">
<JavaScript>
var Observable = require("FuseJS/Observable")

function Item( value, label ) {
this.value = value
this.label = label
}
exports.data = Observable(
new Item(7, "2007"),
new Item(20, "2008"),
new Item(13, "2009"),
new Item(27, "2010"),
new Item(15, "2011"),
new Item(5, "2012"),
new Item(50, "2013"),
new Item(20, "2014"),
new Item(30, "2015"),
new Item(35, "2016"),
new Item(15, "2017")
);

exports.incrOffset = function() {
plot.stepOffset(1)
}

exports.decrOffset = function() {
plot.stepOffset(-1)
}
Expand Down
14 changes: 1 addition & 13 deletions Samples/Visualization/Charting/MixHorzLine.ux
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
<ChartPage Title="Extruded line to base" File="MixHorzLine" ux:Class="MixHorzLine" xmlns:c="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")
exports.points = Observable( -10, 50,-20, 30, -35 )

exports.random = function() {
var items = []
for (var i =0; i < 5; ++i) {
items.push( (Math.random() - 0.5) * 100 )
}
exports.points.replaceAll(items)
}
</JavaScript>
<ChartPage Title="Extruded line to base" File="MixHorzLine" ux:Class="MixHorzLine" xmlns:c="Fuse.Charting" Model="MixHorzLine">
<c:Plot XAxisMetric="Count" RangePadding="0.1" ux:Name="plot">
<c:DataSeries Data="{points}"/>

Expand Down
24 changes: 1 addition & 23 deletions Samples/Visualization/Charting/MixedBarChart.ux
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
<ChartPage Title="Multi-series with pos/neg styling" File="MixedBarChart" ux:Class="MixedBarChart" xmlns:c="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")
function Item( y, label ) {
this.y = y
this.label = label
}

exports.data1 = Observable()
exports.data2 = Observable()

exports.random = function() {
exports.data1.clear()
exports.data2.clear()
for (var i=0; i <= 10; ++i ) {
var y = (Math.random() + 0.2) * 100 * (Math.random() > 0.5 ? -1 : 1)
exports.data1.add( new Item( y, "#" + i ) )
exports.data2.add( { y: y * (Math.random() * 0.8 + 0.2) } )
}
}

exports.random()
</JavaScript>
<ChartPage Title="Multi-series with pos/neg styling" File="MixedBarChart" ux:Class="MixedBarChart" xmlns:c="Fuse.Charting" Model="MixedBarChart">
<c:Plot Margin="5,20,20,10" YAxisSteps="8">
<c:DataSeries Data="{data1}"/>
<c:DataSeries Data="{data2}"/>
Expand Down
20 changes: 1 addition & 19 deletions Samples/Visualization/Charting/NegHorzLine.ux
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
<ChartPage Title="Negative values with in-plot ticks" File="NegHorzLine" ux:Class="NegHorzLine" xmlns:c="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")
exports.pointsA = Observable( -10, -50,-20, -30, -35 )
exports.pointsB = Observable( -5, -40,-30, -20, -45 )

function randomItems() {
var items = []
for (var i =0; i < 5; ++i) {
items.push( -Math.random() * 50 )
}
return items
}

exports.random = function() {
exports.pointsA.replaceAll( randomItems() )
exports.pointsB.replaceAll( randomItems() )
}
</JavaScript>
<ChartPage Title="Negative values with in-plot ticks" File="NegHorzLine" ux:Class="NegHorzLine" xmlns:c="Fuse.Charting" Model="NegHorzLine">
<AttractorConfig Unit="Normalized" Easing="CubicInOut" Duration="0.3" ux:Global="plotAttract"/>
<c:Plot XAxisMetric="Count" RangePadding="0.1">
<c:DataSeries Data="{pointsA}"/>
Expand Down
30 changes: 1 addition & 29 deletions Samples/Visualization/Charting/PieChart.ux
Original file line number Diff line number Diff line change
@@ -1,32 +1,4 @@
<ChartPage Title="Pie chart" File="PieChart" ux:Class="PieChart" xmlns:c="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")
function Item( y, z, label, color ) {
this.y = y
this.z = z
this.label = label
this.color = color
}

var names = [ "Vebjørn", "Annbjørg", "Øystein", "Åslaug", "Tormod", "Borghild" ]
var colors = [ "#DEF", "#DFE", "#FDE", "#EDF", "#EFD", "#FED" ]
exports.data1 = Observable()

function create() {
var list = []
for (var i=0; i < names.length; ++i ) {
var c = Math.random() * 100 + 10
list.push( new Item( c, Math.random(), names[i], colors[i] ) )
}
return list
}

exports.random = function() {
exports.data1.replaceAll( create() )
}

exports.random()
</JavaScript>
<ChartPage Title="Pie chart" File="PieChart" ux:Class="PieChart" xmlns:c="Fuse.Charting" Model="PieChart">
<AttractorConfig Unit="Normalized" Type="Elastic" ux:Global="pieAttract"/>
<ChartButton Alignment="TopRight" Margin="5" Clicked="{random}" Label="✧"/>
<c:Plot Margin="5,20,20,10">
Expand Down
27 changes: 3 additions & 24 deletions Samples/Visualization/Charting/QuarterGroups.ux
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
<ChartPage ux:Class="QuarterGroups" File="QuarterGroups"
Title="Monthly data grouped into Quarters" xmlns:c="Fuse.Charting">
<ChartPage ux:Class="QuarterGroups" File="QuarterGroups(plot)"
Title="Monthly data grouped into Quarters" xmlns:c="Fuse.Charting" Model="QuarterGroups">
<JavaScript>
var Observable = require("FuseJS/Observable")

function Item( value, quarter, month ) {
this.value = value
this.label = quarter
}
exports.data = Observable(
new Item(7, "Q1", "January"),
new Item(20, "Q1", "February"),
new Item(13, "Q1", "March"),
new Item(27, "Q2", "April"),
new Item(15, "Q2", "May"),
new Item(5, "Q2", "June"),
new Item(50, "Q3", "July"),
new Item(20, "Q3", "August"),
new Item(30, "Q3", "September"),
new Item(35, "Q4", "October"),
new Item(15, "Q4", "November"),
new Item(20, "Q4", "December"),
new Item(21, "Q1", "January")
);

exports.incrOffset = function() {
plot.stepOffset(1)
}

exports.decrOffset = function() {
plot.stepOffset(-1)
}
Expand Down
35 changes: 2 additions & 33 deletions Samples/Visualization/Charting/ScatterPlot.ux
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
<ChartPage Title="4-d scatter plot" File="ScatterPlot" ux:Class="ScatterPlot" xmlns:p="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")

function Item(x,y,z,w) {
this.x = x
this.y = y
this.z = z
this.w = w
}
exports.items = Observable()

function genRandom() {
var items = []
var count = 25
for (var i=0; i < count; ++i) {
if (Math.random() > 0.5) {
continue
}

var base = i / count
items.push( new Item( Math.random() * 10 + base * 90, Math.random() * 300 + base*700,
Math.random(), Math.random() ) )
}
return items
}

exports.random = function() {
exports.items.replaceAll( genRandom() )
}

exports.random()
</JavaScript>
<ChartPage Title="4-d scatter plot" File="ScatterPlot" ux:Class="ScatterPlot" xmlns:p="Fuse.Charting"
Model="ScatterPlot">
<p:Plot Margin="10" ux:Name="p" XAxisMetric="Range">
<p:DataSeries Data="{items}"/>
<!-- Adjust the number of divisions based on the available space -->
Expand Down
40 changes: 1 addition & 39 deletions Samples/Visualization/Charting/SpiderChart.ux
Original file line number Diff line number Diff line change
@@ -1,42 +1,4 @@
<ChartPage Title="Spider chart" File="SpiderChart" ux:Class="SpiderChart" xmlns:c="Fuse.Charting">
<JavaScript>
var Observable = require("FuseJS/Observable")

var data = [ {
label: "Attention",
value: 54,
}, {
label: "Care",
value: 15,
}, {
label: "Fight",
value: 68,
}, {
label: "Performance",
value: 74,
}, {
label: "Avoid bad experiences",
value: 51,
}, {
label: "Under- standing",
value: 90,
}, {
label: "Approval",
value: 58,
}, {
label: "Sense of Duty",
value: 80,
}, {
label: "Dominance",
value: 80,
}, {
label: "Autonomy",
value: 51,
} ]

exports.data = Observable()
exports.data.replaceAll( data )
</JavaScript>
<ChartPage Title="Spider chart" File="SpiderChart" ux:Class="SpiderChart" xmlns:c="Fuse.Charting" Model="SpiderChart">
<c:Plot Margin="40,20" YRange="0,100">
<c:DataSeries Data="{data}"/>

Expand Down
Loading