diff --git a/public/main.js b/public/main.js index 14df36a950d4755a26f5cd1ebbb8177fc41bbfc0..6acaafd7bb38b02cf934761fdbcc1268d6ce9705 100644 --- a/public/main.js +++ b/public/main.js @@ -6319,7 +6319,7 @@ var $author$project$Main$init = function (_v0) { $gampleman$elm_visualization$Zoom$init( {height: $author$project$TreeView$h, width: $author$project$TreeView$w}))) }, - {input: '', modelID: '0'}, + {input1: '', input2: '', modelID1: '0', modelID2: '1019', nextChange: 2}, {parallelCoordinatesPlot: false, scatterPlot: true, starPlot: false, treeView: false}), $author$project$Main$fetchData); }; @@ -9208,7 +9208,13 @@ var $author$project$Main$update = F2( model, { plotVisible: {parallelCoordinatesPlot: false, scatterPlot: false, starPlot: true, treeView: false}, - starplotOption: {input: model.starplotOption.input, modelID: id} + starplotOption: { + input1: model.starplotOption.input1, + input2: model.starplotOption.input2, + modelID1: (model.starplotOption.nextChange === 1) ? id : model.starplotOption.modelID1, + modelID2: (model.starplotOption.nextChange === 2) ? id : model.starplotOption.modelID2, + nextChange: (model.starplotOption.nextChange === 1) ? 2 : 1 + } }), $elm$core$Platform$Cmd$none); } @@ -9257,7 +9263,13 @@ var $author$project$Main$update = F2( model, { plotVisible: {parallelCoordinatesPlot: false, scatterPlot: false, starPlot: true, treeView: false}, - starplotOption: {input: model.starplotOption.input, modelID: id} + starplotOption: { + input1: model.starplotOption.input1, + input2: model.starplotOption.input2, + modelID1: (model.starplotOption.nextChange === 1) ? id : model.starplotOption.modelID1, + modelID2: (model.starplotOption.nextChange === 2) ? id : model.starplotOption.modelID2, + nextChange: (model.starplotOption.nextChange === 1) ? 2 : 1 + } }), $elm$core$Platform$Cmd$none); } @@ -9277,22 +9289,52 @@ var $author$project$Main$update = F2( case 'Nothing1': var _v3 = msg.a; return _Utils_Tuple2(model, $elm$core$Platform$Cmd$none); - case 'InputChange': + case 'InputChange1': var id = msg.a.a; return _Utils_Tuple2( _Utils_update( model, { - starplotOption: {input: id, modelID: model.starplotOption.modelID} + starplotOption: {input1: id, input2: model.starplotOption.input2, modelID1: model.starplotOption.modelID1, modelID2: model.starplotOption.modelID2, nextChange: model.starplotOption.nextChange} }), $elm$core$Platform$Cmd$none); - default: + case 'InputChange2': + var id = msg.a.a; + return _Utils_Tuple2( + _Utils_update( + model, + { + starplotOption: {input1: model.starplotOption.input1, input2: id, modelID1: model.starplotOption.modelID1, modelID2: model.starplotOption.modelID2, nextChange: model.starplotOption.nextChange} + }), + $elm$core$Platform$Cmd$none); + case 'SubmitNumber1': var _v4 = msg.a; return _Utils_Tuple2( _Utils_update( model, { - starplotOption: {input: model.starplotOption.input, modelID: model.starplotOption.input} + starplotOption: { + input1: model.starplotOption.input1, + input2: model.starplotOption.input2, + modelID1: model.starplotOption.input1, + modelID2: model.starplotOption.modelID2, + nextChange: (model.starplotOption.nextChange === 1) ? 2 : 1 + } + }), + $elm$core$Platform$Cmd$none); + default: + var _v5 = msg.a; + return _Utils_Tuple2( + _Utils_update( + model, + { + starplotOption: { + input1: model.starplotOption.input1, + input2: model.starplotOption.input2, + modelID1: model.starplotOption.modelID1, + modelID2: model.starplotOption.input2, + nextChange: (model.starplotOption.nextChange === 1) ? 2 : 1 + } }), $elm$core$Platform$Cmd$none); } @@ -12100,11 +12142,15 @@ var $author$project$Scatterplot$viewScatterplot = function (model) { $author$project$Scatterplot$scatterplot(filteredSmartphoneData) ])); }; -var $author$project$Starplot$InputChange = function (a) { - return {$: 'InputChange', a: a}; +var $author$project$Starplot$InputChange1 = function (a) { + return {$: 'InputChange1', a: a}; +}; +var $author$project$Starplot$InputChange2 = function (a) { + return {$: 'InputChange2', a: a}; }; -var $author$project$Starplot$SubmitNumber = {$: 'SubmitNumber'}; -var $author$project$Starplot$starlength = 180; +var $author$project$Starplot$SubmitNumber1 = {$: 'SubmitNumber1'}; +var $author$project$Starplot$SubmitNumber2 = {$: 'SubmitNumber2'}; +var $author$project$Starplot$starlength = 300; var $author$project$Starplot$calculateStarValue = F3( function (smartphone, max, func) { if (smartphone.$ === 'Just') { @@ -12146,19 +12192,20 @@ var $author$project$Starplot$checkID = F2( A2($elm$core$Maybe$withDefault, 'NaN', smartphone.id), modelID); }); -var $author$project$Starplot$findSmartphoneById = function (model) { - return $elm$core$List$head( - A2( - $elm$core$List$filter, - $author$project$Starplot$checkID(model.starplotOption.modelID), - model.data)); -}; +var $author$project$Starplot$findSmartphoneById = F2( + function (model, id) { + return $elm$core$List$head( + A2( + $elm$core$List$filter, + $author$project$Starplot$checkID(id), + model.data)); + }); var $elm$html$Html$h3 = _VirtualDom_node('h3'); var $elm$html$Html$input = _VirtualDom_node('input'); var $elm$html$Html$Attributes$placeholder = $elm$html$Html$Attributes$stringProperty('placeholder'); var $avh4$elm_color$Color$black = A4($avh4$elm_color$Color$RgbaSpace, 0 / 255, 0 / 255, 0 / 255, 1.0); var $author$project$Starplot$midX = 450; -var $author$project$Starplot$midY = 225; +var $author$project$Starplot$midY = 360; var $author$project$Starplot$createAxis = function (axisPoint) { return A2( $gampleman$elm_visualization$Shape$line, @@ -12232,7 +12279,7 @@ var $author$project$Starplot$createLabels = F3( ])); }); var $avh4$elm_color$Color$darkGray = A4($avh4$elm_color$Color$RgbaSpace, 186 / 255, 189 / 255, 182 / 255, 1.0); -var $author$project$Starplot$h = 450; +var $author$project$Starplot$h = 700; var $avh4$elm_color$Color$red = A4($avh4$elm_color$Color$RgbaSpace, 204 / 255, 0 / 255, 0 / 255, 1.0); var $elm_community$typed_svg$TypedSvg$Attributes$InPx$strokeWidth = function (value) { return $elm_community$typed_svg$TypedSvg$Attributes$strokeWidth( @@ -12383,7 +12430,7 @@ var $author$project$Starplot$starplot = F4( [ A4($elm_community$typed_svg$TypedSvg$Attributes$viewBox, 0, 0, $author$project$Starplot$w, $author$project$Starplot$h), $elm_community$typed_svg$TypedSvg$Attributes$width( - $elm_community$typed_svg$TypedSvg$Types$Percent(100)), + $elm_community$typed_svg$TypedSvg$Types$Percent(50)), $elm_community$typed_svg$TypedSvg$Attributes$height( $elm_community$typed_svg$TypedSvg$Types$Percent(100)) ]), @@ -12395,7 +12442,7 @@ var $author$project$Starplot$starplot = F4( _List_Nil, _List_fromArray( [ - $elm_community$typed_svg$TypedSvg$Core$text('\r\n .valueLabel { display: none }\r\n .label:hover .valueLabel { display: inline; }\r\n .label:hover .starLabel { display: none; }\r\n ') + $elm_community$typed_svg$TypedSvg$Core$text('\r\n .valueLabel { display: none }\r\n .starLabel {font-size:30px;}\r\n .valueLabel {font-size:30px;}\r\n .label:hover .valueLabel { display: inline; }\r\n .label:hover .starLabel { display: none; }\r\n ') ])), A2( $elm_community$typed_svg$TypedSvg$circle, @@ -12459,42 +12506,97 @@ var $author$project$Starplot$starplot = F4( starAxisMax)))); }); var $author$project$Starplot$viewStarplot = function (model) { - var starplotViewHead = function (spd) { - return A2( - $elm$html$Html$div, - _List_Nil, - _List_fromArray( - [ - A2( - $elm$html$Html$h3, - _List_Nil, - _List_fromArray( - [ - $elm$html$Html$text( - ('ID:' + A2($elm$core$Maybe$withDefault, 'NaN', spd.id)) + (' | ' + A2($elm$core$Maybe$withDefault, 'NaN', spd.model))) - ])), - $elm$html$Html$text('ID auswaehlen: '), - A2( - $elm$html$Html$input, - _List_fromArray( - [ - $elm$html$Html$Attributes$placeholder('Enter a number'), - $elm$html$Html$Events$onInput($author$project$Starplot$InputChange) - ]), - _List_Nil), - A2( - $elm$html$Html$button, - _List_fromArray( - [ - $elm$html$Html$Events$onClick($author$project$Starplot$SubmitNumber) - ]), - _List_fromArray( - [ - $elm$html$Html$text('Submit') - ])) - ])); - }; - var starplotData = $author$project$Starplot$findSmartphoneById(model); + var starplotViewHead = F2( + function (spd1, spd2) { + return A2( + $elm$html$Html$div, + _List_Nil, + _List_fromArray( + [ + function () { + if (spd1.$ === 'Just') { + var spd = spd1.a; + return A2( + $elm$html$Html$h3, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text( + ('Starplot1 | ID:' + A2($elm$core$Maybe$withDefault, 'NaN', spd.id)) + (' | ' + A2($elm$core$Maybe$withDefault, 'NaN', spd.model))) + ])); + } else { + return A2( + $elm$html$Html$h3, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text(('Starplot1 | ID:' + 'NaN') + (' | ' + 'NaN')) + ])); + } + }(), + function () { + if (spd2.$ === 'Just') { + var spd = spd2.a; + return A2( + $elm$html$Html$h3, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text( + ('Starplot2 | ID:' + A2($elm$core$Maybe$withDefault, 'NaN', spd.id)) + (' | ' + A2($elm$core$Maybe$withDefault, 'NaN', spd.model))) + ])); + } else { + return A2( + $elm$html$Html$h3, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text(('Starplot2 | ID:' + 'NaN') + (' | ' + 'NaN')) + ])); + } + }(), + $elm$html$Html$text('ID1 auswaehlen: '), + A2( + $elm$html$Html$input, + _List_fromArray( + [ + $elm$html$Html$Attributes$placeholder('Enter a number'), + $elm$html$Html$Events$onInput($author$project$Starplot$InputChange1) + ]), + _List_Nil), + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Events$onClick($author$project$Starplot$SubmitNumber1) + ]), + _List_fromArray( + [ + $elm$html$Html$text('Submit for SP1') + ])), + $elm$html$Html$text(' ID2 auswaehlen: '), + A2( + $elm$html$Html$input, + _List_fromArray( + [ + $elm$html$Html$Attributes$placeholder('Enter a number'), + $elm$html$Html$Events$onInput($author$project$Starplot$InputChange2) + ]), + _List_Nil), + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Events$onClick($author$project$Starplot$SubmitNumber2) + ]), + _List_fromArray( + [ + $elm$html$Html$text('Submit for SP2') + ])) + ])); + }); + var starplotData2 = A2($author$project$Starplot$findSmartphoneById, model, model.starplotOption.modelID2); + var starplotData1 = A2($author$project$Starplot$findSmartphoneById, model, model.starplotOption.modelID1); var smartphoneFunctions = _List_fromArray( [ function ($) { @@ -12532,34 +12634,53 @@ var $author$project$Starplot$viewStarplot = function (model) { $elm$core$List$map, $author$project$Starplot$findMaxValue(model), smartphoneFunctions); - var starValues = A3( + var starValues1 = A3( $elm$core$List$map2, - $author$project$Starplot$calculateStarValue(starplotData), + $author$project$Starplot$calculateStarValue(starplotData1), + maxValues, + smartphoneFunctions); + var starValues2 = A3( + $elm$core$List$map2, + $author$project$Starplot$calculateStarValue(starplotData2), maxValues, smartphoneFunctions); var labels = _List_fromArray( ['Price', 'Rating', 'NumCores', 'Processor Speed', 'Battery', 'Fast Charging', 'Memory', 'RAM', 'Screen Size', 'Refresh Rate']); - if (starplotData.$ === 'Just') { - var spd = starplotData.a; - return A2( - $elm$html$Html$div, - _List_Nil, - _List_fromArray( - [ - starplotViewHead(spd), - A4($author$project$Starplot$starplot, spd, starValues, labels, smartphoneFunctions) - ])); - } else { - return A2( - $elm$html$Html$div, - _List_Nil, - _List_fromArray( - [ - starplotViewHead( - {id: $elm$core$Maybe$Nothing, model: $elm$core$Maybe$Nothing}), - $elm$html$Html$text('Error: Starplot kann nicht dargestellt werden, da zu dieser ID (' + (model.starplotOption.modelID + ') keine Data vorliegen Probiere Sie eine andere ID aus. Die ID muss eine Nummer sein.')) - ])); - } + return A2( + $elm$html$Html$div, + _List_Nil, + _List_fromArray( + [ + A2(starplotViewHead, starplotData1, starplotData2), + function () { + if (starplotData1.$ === 'Just') { + var spd1 = starplotData1.a; + return A4($author$project$Starplot$starplot, spd1, starValues1, labels, smartphoneFunctions); + } else { + return A2( + $elm$html$Html$div, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text('Error: Starplot1 kann nicht dargestellt werden, da zu dieser ID (' + (model.starplotOption.modelID1 + ') keine Data vorliegen Probiere Sie eine andere ID aus. Die ID muss eine Nummer sein.')) + ])); + } + }(), + function () { + if (starplotData2.$ === 'Just') { + var spd2 = starplotData2.a; + return A4($author$project$Starplot$starplot, spd2, starValues2, labels, smartphoneFunctions); + } else { + return A2( + $elm$html$Html$div, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text('Error: Starplot2 kann nicht dargestellt werden, da zu dieser ID (' + (model.starplotOption.modelID2 + ') keine Data vorliegen Probiere Sie eine andere ID aus. Die ID muss eine Nummer sein.')) + ])); + } + }() + ])); }; var $author$project$TreeView$ZoomMsg = function (a) { return {$: 'ZoomMsg', a: a}; diff --git a/src/Main.elm b/src/Main.elm index cf17dbafa7b87647df44d3b5d06bf2263e5d65d7..5502ff685e158b711de9fb9b0efae31ff9263491 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -60,8 +60,11 @@ init _ = |> Zoom.scaleExtent 1 100 |> Zoom.translateExtent ( ( 0, 0 ), ( TreeView.w, TreeView.h ) ) } - { modelID = "0" - , input = "" + { modelID1 = "0" + , modelID2 = "1019" + , input1 = "" + , input2 = "" + , nextChange = 2 } { scatterPlot = True , parallelCoordinatesPlot = False @@ -138,8 +141,26 @@ update msg model = ScatterplotMsg (SetStarPlot id) -> ( { model | starplotOption = - { modelID = id - , input = model.starplotOption.input + { modelID1 = + if model.starplotOption.nextChange == 1 then + id + + else + model.starplotOption.modelID1 + , modelID2 = + if model.starplotOption.nextChange == 2 then + id + + else + model.starplotOption.modelID2 + , input1 = model.starplotOption.input1 + , input2 = model.starplotOption.input2 + , nextChange = + if model.starplotOption.nextChange == 1 then + 2 + + else + 1 } , plotVisible = { scatterPlot = False, parallelCoordinatesPlot = False, treeView = False, starPlot = True } } @@ -165,8 +186,26 @@ update msg model = TreeViewMsg (SetStarPlotFromTree id) -> ( { model | starplotOption = - { modelID = id - , input = model.starplotOption.input + { modelID1 = + if model.starplotOption.nextChange == 1 then + id + + else + model.starplotOption.modelID1 + , modelID2 = + if model.starplotOption.nextChange == 2 then + id + + else + model.starplotOption.modelID2 + , input1 = model.starplotOption.input1 + , input2 = model.starplotOption.input2 + , nextChange = + if model.starplotOption.nextChange == 1 then + 2 + + else + 1 } , plotVisible = { scatterPlot = False, parallelCoordinatesPlot = False, treeView = False, starPlot = True } } @@ -181,21 +220,63 @@ update msg model = , Cmd.none ) - StarplotMsg (InputChange id) -> + StarplotMsg (InputChange1 id) -> ( { model | starplotOption = - { modelID = model.starplotOption.modelID - , input = id + { modelID1 = model.starplotOption.modelID1 + , modelID2 = model.starplotOption.modelID2 + , input1 = id + , input2 = model.starplotOption.input2 + , nextChange = model.starplotOption.nextChange } } , Cmd.none ) - StarplotMsg SubmitNumber -> + StarplotMsg (InputChange2 id) -> ( { model | starplotOption = - { modelID = model.starplotOption.input - , input = model.starplotOption.input + { modelID1 = model.starplotOption.modelID1 + , modelID2 = model.starplotOption.modelID2 + , input1 = model.starplotOption.input1 + , input2 = id + , nextChange = model.starplotOption.nextChange + } + } + , Cmd.none + ) + + StarplotMsg SubmitNumber1 -> + ( { model + | starplotOption = + { modelID1 = model.starplotOption.input1 + , modelID2 = model.starplotOption.modelID2 + , input1 = model.starplotOption.input1 + , input2 = model.starplotOption.input2 + , nextChange = + if model.starplotOption.nextChange == 1 then + 2 + + else + 1 + } + } + , Cmd.none + ) + + StarplotMsg SubmitNumber2 -> + ( { model + | starplotOption = + { modelID1 = model.starplotOption.modelID1 + , modelID2 = model.starplotOption.input2 + , input1 = model.starplotOption.input1 + , input2 = model.starplotOption.input2 + , nextChange = + if model.starplotOption.nextChange == 1 then + 2 + + else + 1 } } , Cmd.none diff --git a/src/Model.elm b/src/Model.elm index eba3607eed019b7b58688eab6e133fe776f4700a..6018ef540e0cd11d2d9aa6258e1838c6639325b7 100644 --- a/src/Model.elm +++ b/src/Model.elm @@ -41,6 +41,9 @@ type alias TreeOption = type alias StarPlotOption = - { modelID : String - , input : String + { modelID1 : String + , modelID2 : String + , input1 : String + , input2 : String + , nextChange : Int } diff --git a/src/Starplot.elm b/src/Starplot.elm index 5d4a51613738f998064d87e5fd34a768ba3f2400..15d41defebbe3c1e5c0c02c2a1b4636672a21657 100644 --- a/src/Starplot.elm +++ b/src/Starplot.elm @@ -24,7 +24,7 @@ w = h : Float h = - 450 + 700 midX : Float @@ -34,23 +34,25 @@ midX = midY : Float midY = - 225 + 360 padding : Float padding = - 30 + 50 starlength : Float starlength = - 180 + 300 type Msg = Nothing1 - | InputChange String - | SubmitNumber + | InputChange1 String + | SubmitNumber1 + | InputChange2 String + | SubmitNumber2 starplot : Smartphone -> List Float -> List String -> List (Smartphone -> Maybe Float) -> Svg msg @@ -177,11 +179,13 @@ starplot smartphone starValues labels func = in svg [ viewBox 0 0 w h - , TypedSvg.Attributes.width <| TypedSvg.Types.Percent 100 + , TypedSvg.Attributes.width <| TypedSvg.Types.Percent 50 , TypedSvg.Attributes.height <| TypedSvg.Types.Percent 100 ] ([ TypedSvg.style [] [ TypedSvg.Core.text """ .valueLabel { display: none } + .starLabel {font-size:30px;} + .valueLabel {font-size:30px;} .label:hover .valueLabel { display: inline; } .label:hover .starLabel { display: none; } """ ] @@ -253,10 +257,10 @@ createLabels label vlabel labelPoint = -} -findSmartphoneById : Model -> Maybe Smartphone -findSmartphoneById model = +findSmartphoneById : Model -> String -> Maybe Smartphone +findSmartphoneById model id = List.head <| - List.filter (checkID model.starplotOption.modelID) model.data + List.filter (checkID id) model.data findMaxValue : Model -> (Smartphone -> Maybe Float) -> Maybe Float @@ -318,35 +322,64 @@ viewStarplot model = , "Refresh Rate" ] - starplotData = - findSmartphoneById model + starplotData1 = + findSmartphoneById model model.starplotOption.modelID1 + + starplotData2 = + findSmartphoneById model model.starplotOption.modelID2 maxValues = List.map (findMaxValue model) smartphoneFunctions - starValues = - List.map2 (calculateStarValue starplotData) + starValues1 = + List.map2 (calculateStarValue starplotData1) maxValues smartphoneFunctions - starplotViewHead spd = - div [] - [ h3 [] [ text <| ("ID:" ++ Maybe.withDefault "NaN" spd.id) ++ (" | " ++ Maybe.withDefault "NaN" spd.model) ] - , text "ID auswaehlen: " - , input [ placeholder "Enter a number", onInput InputChange ] [] - , button [ onClick SubmitNumber ] [ text "Submit" ] - ] - in - case starplotData of - Just spd -> - div [] - [ starplotViewHead spd - , starplot spd starValues labels smartphoneFunctions - ] + starValues2 = + List.map2 (calculateStarValue starplotData2) + maxValues + smartphoneFunctions - Nothing -> + starplotViewHead spd1 spd2 = div [] - [ starplotViewHead { id = Nothing, model = Nothing } - , text <| "Error: Starplot kann nicht dargestellt werden, da zu dieser ID (" ++ model.starplotOption.modelID ++ ") keine Data vorliegen Probiere Sie eine andere ID aus. Die ID muss eine Nummer sein." + [ case spd1 of + Just spd -> + h3 [] [ text <| ("Starplot1 | ID:" ++ Maybe.withDefault "NaN" spd.id) ++ (" | " ++ Maybe.withDefault "NaN" spd.model) ] + + Nothing -> + h3 [] [ text <| ("Starplot1 | ID:" ++ "NaN") ++ (" | " ++ "NaN") ] + , case spd2 of + Just spd -> + h3 [] [ text <| ("Starplot2 | ID:" ++ Maybe.withDefault "NaN" spd.id) ++ (" | " ++ Maybe.withDefault "NaN" spd.model) ] + + Nothing -> + h3 [] [ text <| ("Starplot2 | ID:" ++ "NaN") ++ (" | " ++ "NaN") ] + , text "ID1 auswaehlen: " + , input [ placeholder "Enter a number", onInput InputChange1 ] [] + , button [ onClick SubmitNumber1 ] [ text "Submit for SP1" ] + , text " ID2 auswaehlen: " + , input [ placeholder "Enter a number", onInput InputChange2 ] [] + , button [ onClick SubmitNumber2 ] [ text "Submit for SP2" ] ] + in + div [] + [ starplotViewHead starplotData1 starplotData2 + , case starplotData1 of + Just spd1 -> + starplot spd1 starValues1 labels smartphoneFunctions + + Nothing -> + div [] + [ text <| "Error: Starplot1 kann nicht dargestellt werden, da zu dieser ID (" ++ model.starplotOption.modelID1 ++ ") keine Data vorliegen Probiere Sie eine andere ID aus. Die ID muss eine Nummer sein." + ] + , case starplotData2 of + Just spd2 -> + starplot spd2 starValues2 labels smartphoneFunctions + + Nothing -> + div [] + [ text <| "Error: Starplot2 kann nicht dargestellt werden, da zu dieser ID (" ++ model.starplotOption.modelID2 ++ ") keine Data vorliegen Probiere Sie eine andere ID aus. Die ID muss eine Nummer sein." + ] + ]