@ -16,9 +16,9 @@ function chartModel(id,name,renderer,datasources)
@@ -16,9 +16,9 @@ function chartModel(id,name,renderer,datasources)
}
function possibleVizType ( nr , value , name , explanation , isDefault )
function possibleVizType ( elemID , value , name , explanation , isDefault )
{
this . nr = nr ;
this . elemID = elemID ;
this . value = value ;
this . name = name ;
this . explanation = explanation ;
@ -26,9 +26,9 @@ this.isDefault=isDefault;
@@ -26,9 +26,9 @@ this.isDefault=isDefault;
}
function usedVizType ( nr , vizTypeUniquename , caption , datasource )
function usedVizType ( elemID , vizTypeUniquename , caption , datasource )
{
this . nr = nr ;
this . elemID = elemID ;
this . vizTypeUniquename = vizTypeUniquename ;
this . caption = caption ;
this . datasource = datasource ;
@ -383,7 +383,19 @@ function createChartElementConfig1Form(renderer,elemID)
@@ -383,7 +383,19 @@ function createChartElementConfig1Form(renderer,elemID)
while ( formChartElementConfig1 . firstChild ) {
formChartElementConfig1 . removeChild ( formChartElementConfig1 . firstChild ) ;
}
var formChartElementConfig2 = document . getElementById ( "ChartElementConfig2Div" ) ;
while ( formChartElementConfig2 . firstChild ) {
formChartElementConfig2 . removeChild ( formChartElementConfig2 . firstChild ) ;
}
//reset ElemID:
document . getElementById ( "chartElementID" ) . value = elemID ;
//any previous values?
var myChartElem = null ;
if ( myChartModel . chartElements && elemID != "" )
{
var filtered = myChartModel . chartElements . filter ( obj => obj . elemID == elemID ) ;
var myChartElem = filtered [ 0 ] ;
}
//First Datasource:
const elementDatasourceDiv = document . createElement ( "div" ) ;
const fieldDatasourceElem = document . createElement ( "div" ) ;
@ -403,10 +415,10 @@ function createChartElementConfig1Form(renderer,elemID)
@@ -403,10 +415,10 @@ function createChartElementConfig1Form(renderer,elemID)
labelDatasource . appendChild ( textnode ) ;
labelDatasourceElem . appendChild ( labelDatasource ) ;
fieldDatasourceElem . appendChild ( labelDatasourceElem ) ;
const inpElemId = document . createElement ( "input" ) ;
/ * c o n s t i n p E l e m I d = d o c u m e n t . c r e a t e E l e m e n t ( " i n p u t " ) ;
inpElemId . name = "chartElementID" ;
inpElemId . id = "chartElementID" ;
inpElemId . type = "hidden" ;
inpElemId . type = "text" ; * /
const selDatasourceElem = document . createElement ( "select" ) ;
@ -418,9 +430,9 @@ function createChartElementConfig1Form(renderer,elemID)
@@ -418,9 +430,9 @@ function createChartElementConfig1Form(renderer,elemID)
selDatasourceElem . onchange = function ( ) {
createChartElementsConfig2Form ( renderer ) ;
} ;
fillSelectOptions ( selDatasourceElem , rsTableMetaData , true ) ;
fillSelectOptions ( selDatasourceElem , rsTableMetaData , true , ( myChartElem != null ? myChartElem . datasource : null ) ) ;
fieldDatasourceElem . appendChild ( selDatasourceElem ) ;
fieldDatasourceElem . appendChild ( inpElemId ) ;
//fieldDatasourceElem.appendChild(inpElemId);
elementDatasourceDiv . appendChild ( fieldDatasourceElem ) ;
formChartElementConfig1 . appendChild ( elementDatasourceDiv ) ;
@ -453,14 +465,17 @@ function createChartElementConfig1Form(renderer,elemID)
@@ -453,14 +465,17 @@ function createChartElementConfig1Form(renderer,elemID)
selVizTypeElem . onchange = function ( ) {
createChartElementsConfig2Form ( renderer ) ;
} ;
fillSelectOptions ( selVizTypeElem , getPossibleVizTypes ( renderer ) , false ) ;
fillSelectOptions ( selVizTypeElem , getPossibleVizTypes ( renderer ) , false , ( myChartElem != null ? myChartElem . vizTypeUniquename : null ) ) ;
fieldVizTypeElem . appendChild ( selVizTypeElem ) ;
elementVizTypeDiv . appendChild ( fieldVizTypeElem ) ;
formChartElementConfig1 . appendChild ( elementVizTypeDiv ) ;
//display Element if already saved:
if ( elemID != "" )
createChartElementsConfig2Form ( renderer , elemID ) ;
}
function createChartElementsConfig2Form ( renderer )
function createChartElementsConfig2Form ( renderer , elemID )
{
var dataSource = document . getElementById ( "chartElementDatasource" ) . value ;
var vizType = document . getElementById ( "chartElementVizType" ) . value ;
@ -469,6 +484,8 @@ function createChartElementsConfig2Form(renderer)
@@ -469,6 +484,8 @@ function createChartElementsConfig2Form(renderer)
while ( formChartElementConfig2Div . firstChild ) {
formChartElementConfig2Div . removeChild ( formChartElementConfig2Div . firstChild ) ;
}
//any previous values?
const elementDivBox = document . createElement ( "div" ) ;
//first only Dimensions and measures:
@ -479,8 +496,39 @@ function createChartElementsConfig2Form(renderer)
@@ -479,8 +496,39 @@ function createChartElementsConfig2Form(renderer)
|| vizTypeProperties [ k ] . groupUniquename == "MEASURE"
)
)
elementDivBox . appendChild ( renderDimensionField ( vizTypeProperties [ k ] , dataSource ) ) ;
{
var selectedValue = getChartElementPropertyValue ( elemID , vizTypeProperties [ k ] . propUniquename ) ;
elementDivBox . appendChild ( renderDimensionField ( vizTypeProperties [ k ] , dataSource , selectedValue ) ) ;
}
}
//chartElement-specific properties:
//without Dimensions and measures:
for ( var k = 0 ; k < vizTypeProperties . length ; k ++ )
{
if ( vizType == vizTypeProperties [ k ] . typeUniquename
&& vizTypeProperties [ k ] . groupUniquename != "CATEGORY"
&& vizTypeProperties [ k ] . groupUniquename != "MEASURE"
) {
var currentCommonChartProperties = commonChartProperties . filter ( obj => obj . name == vizTypeProperties [ k ] . propUniquename ) ;
if ( currentCommonChartProperties . length > 0 )
{
//var selectedValue=getChartElementPropertyValue(elemID,currentCommonChartProperties[0].propUniquename);
elementDivBox . appendChild ( renderChartPropertyField ( elemID , currentCommonChartProperties [ 0 ] , false ) ) ;
}
else
{
const unknownFieldDiv = document . createElement ( "div" ) ;
const unknownField = document . createTextNode ( "Unbekanntes Feld " + vizTypeProperties [ k ] . propUniquename ) ;
unknownFieldDiv . appendChild ( unknownField ) ;
elementDivBox . appendChild ( unknownFieldDiv ) ;
}
}
}
const saveBtnDiv = document . createElement ( "div" ) ;
const saveBtn = document . createElement ( "input" ) ;
saveBtn . type = "BUTTON" ;
@ -496,35 +544,60 @@ function createChartElementsConfig2Form(renderer)
@@ -496,35 +544,60 @@ function createChartElementsConfig2Form(renderer)
formChartElementConfig2Div . appendChild ( elementDivBox ) ;
/ * c o l u m n s D i v . a p p e n d C h i l d ( c o l u m n D i v ) ;
//title
const columnDivTitle = document . createElement ( "div" ) ;
columnDivTitle . classList . add ( "column" ) ;
columnDivTitle . classList . add ( "is-narrow" ) ;
const columnDivBoxTitle = document . createElement ( "div" ) ;
columnDivBoxTitle . classList . add ( "box" ) ;
columnDivBoxTitle . style = "width: 500px" ;
for ( var k = 0 ; k < myCommonChartProperties . length ; k ++ )
}
function getChartElementPropertyValue ( elemID , propUniquename )
{
var retVal = null ;
var myChartElem = null ;
if ( myChartModel . chartElements && elemID != null )
{
var filtered = myChartModel . chartElements . filter ( obj => obj . elemID == elemID ) ;
var myChartElem = filtered [ 0 ] ;
if ( myChartElem . elementTypeProperties && myChartElem . elementTypeProperties . length )
{
for ( var k = 0 ; k < myChartElem . elementTypeProperties . length ; k ++ )
{
myVizTypeProperty = myChartElem . elementTypeProperties [ k ] ;
if ( myVizTypeProperty . vizTypePropertyUniquename == propUniquename )
{
if ( myCommonChartProperties [ k ] . name == "caption" )
columnDivBoxTitle . appendChild ( renderChartPropertyField ( myCommonChartProperties [ k ] ) ) ;
retVal = myVizTypeProperty . propertyValue ;
}
}
}
}
return retVal ;
}
function loadChartElementConfig ( myElem )
{
var elemID = myElem . value ;
if ( elemID == "" )
alert ( "Kein Grafikelement gefunden" ) ;
else
{
var renderer = document . getElementById ( "fldVizRenderer" ) . value ;
var myVizType = myChartModel . chartElements [ elemID ] ;
createChartElementConfig1Form ( renderer , elemID ) ;
//document.getElementById("chartElementVizType").value=myVizType.vizTypeUniquename;
//document.getElementById("chartElementDatasource").value=myVizType.datasource;
}
columnDivTitle . appendChild ( columnDivBoxTitle ) ;
columnsDiv . appendChild ( columnDivTitle ) ;
myForm . appendChild ( columnsDiv ) ;
* /
}
function saveChartElementConfig ( )
{
var elemID = document . getElementById ( "chartElementID" ) . value ;
var vizTypeUniquename = document . getElementById ( "chartElementVizType" ) . value ;
var datasource = document . getElementById ( "chartElementDatasource" ) . value ;
var nextElemID = parseInt ( document . getElementById ( "vizElementCounter" ) . value ) + 1 ;
var mode = "update" ;
if ( elemID == "" )
elemID = 0 ;
{
//insert mode:
mode = "insert" ;
if ( myChartModel . chartElements )
elemID = myChartModel . chartElements . length + 1 ;
else
elemID = "0" ;
}
var myVizType = new usedVizType ( elemID , vizTypeUniquename , vizTypeUniquename , datasource ) ; //nr,vizTypeUniquename,caption,datasource
var propertyCounter = 0 ;
for ( var k = 0 ; k < vizTypeProperties . length ; k ++ )
@ -533,22 +606,27 @@ function saveChartElementConfig()
@@ -533,22 +606,27 @@ function saveChartElementConfig()
&& document . getElementById ( vizTypeProperties [ k ] . propUniquename )
&& document . getElementById ( vizTypeProperties [ k ] . propUniquename ) . value != "" )
{
var myUsedVizTypeProperty = new usedVizTypeProperty ( propertyCounter , vizTypeProperties [ k ] . propUniquename , vizTypeProperties [ k ] . caption , document . getElementById ( vizTypeProperties [ k ] . propUniquename ) . value ) ; //))nr,vizTypePropertyUniquename,caption,propertyValue )
var myUsedVizTypeProperty = new usedVizTypeProperty ( elemID , vizTypeProperties [ k ] . propUniquename , vizTypeProperties [ k ] . caption , document . getElementById ( vizTypeProperties [ k ] . propUniquename ) . value ) ; //))nr,vizTypePropertyUniquename,caption,propertyValue )
myVizType . elementTypeProperties . push ( myUsedVizTypeProperty ) ;
}
}
//myVizType.elementTypeProperties=null;
//TODO: Existenz abfangen, hier wird einfach hinzugefügt:
myChartModel . chartElements . push ( myVizType ) ;
//Reset Elements Form
elemID ++ ;
document . getElementById ( "chartElementID" ) . value = elemID ;
document . getElementById ( "chartElementVizType" ) . value = "" ;
var formChartElementConfig2Div = document . getElementById ( "ChartElementConfig2Div" ) ;
while ( formChartElementConfig2Div . firstChild ) {
formChartElementConfig2Div . removeChild ( formChartElementConfig2Div . firstChild ) ;
if ( mode == "update" )
{
for ( var k = 0 ; k < myChartModel . chartElements . length ; k ++ )
{
if ( myChartModel . chartElements [ k ] . elemID == elemID )
myChartModel . chartElements [ k ] = myVizType ;
}
document . getElementById ( "vizElementCounter" ) . value = myChartModel . chartElements . length ;
}
else
myChartModel . chartElements . push ( myVizType ) ;
const chartElementListSelect = document . getElementById ( "chartElementID" ) ;
chartElementListSelect . style = "display:inline;" ;
fillChartElementListSelect ( chartElementListSelect , elemID ) ;
//document.getElementById("vizElementCounter").value=myChartModel.chartElements.length;
renderChart ( 'chartDiv' , myChartModel ) ;
/ * v a r m a r k s A r r a y = n e w A r r a y ( ) ;
@ -565,20 +643,58 @@ function saveChartElementConfig()
@@ -565,20 +643,58 @@ function saveChartElementConfig()
function removeChartElementConfig ( )
{
var propertyCounter = myChartModel . chartElements . length ;
if ( propertyCounter > 0 )
var elemID = document . getElementById ( "chartElementID" ) . value ;
if ( elemID != "" )
{
var renderer = document . getElementById ( "fldVizRenderer" ) . value ;
var filtered = myChartModel . chartElements . filter ( obj => obj . elemID != elemID ) ;
myChartModel . chartElements = filtered ;
//myChartModel.chartElements.pop();
//elemID--;
//if(document.getElementById("chartElementID"))
// document.getElementById("chartElementID").value=elemID;
document . getElementById ( "vizElementCounter" ) . value = myChartModel . chartElements . length ;
const chartElementListSelect = document . getElementById ( "chartElementID" ) ;
fillChartElementListSelect ( chartElementListSelect ) ;
createChartElementConfig1Form ( renderer , null ) ;
renderChart ( 'chartDiv' , myChartModel ) ;
}
}
function fillChartElementListSelect ( mySelectElem , selectedValue )
{
var chartElementListSelectOptionArray = new Array ( ) ;
if ( myChartModel . chartElements . length > 0 )
{
var elemID = myChartModel . chartElements [ propertyCounter - 1 ] . nr ;
/ * v a r f i l t e r e d = m y C h a r t M o d e l . c h a r t E l e m e n t s . f i l t e r ( o b j = > o b j . n r ! = = p r o p e r t y C o u n t e r - 1 ) ;
myChartModel . chartElements = filtered ; * /
myChartModel . chartElements . pop ( ) ;
elemID -- ;
if ( document . getElementById ( "chartElementID" ) )
for ( var k = 0 ; k < myChartModel . chartElements . length ; k ++ )
{
var myOptionValue = new possibleVizType ( myChartModel . chartElements [ k ] . elemID ,
myChartModel . chartElements [ k ] . elemID ,
myChartModel . chartElements [ k ] . vizTypeUniquename + "-" + myChartModel . chartElements [ k ] . datasource ,
"" , //explanation
( myChartModel . chartElements [ k ] . elemID == selectedValue ? true : false ) //isDefault
) ;
chartElementListSelectOptionArray . push ( myOptionValue ) ;
}
}
fillSelectOptions ( mySelectElem , chartElementListSelectOptionArray , false , selectedValue ) ;
}
function showChartElementsBodyForm ( elemID )
{
//Reset Elements Form
//elemID++;
var filtered = myChartModel . chartElements . filter ( obj => obj . elemID == elemID ) ;
document . getElementById ( "chartElementID" ) . value = elemID ;
document . getElementById ( "vizElementCounter" ) . value = myChartModel . chartElements . length ;
renderChart ( 'chartDiv' , myChartModel ) ;
document . getElementById ( "chartElementVizType" ) . value = filtered [ 0 ] . vizTypeUniquename ;
var formChartElementConfig2Div = document . getElementById ( "ChartElementConfig2Div" ) ;
while ( formChartElementConfig2Div . firstChild ) {
formChartElementConfig2Div . removeChild ( formChartElementConfig2Div . firstChild ) ;
}
}
function resetChartPropertiesForm ( chosenRenderer )
@ -621,13 +737,16 @@ function fillDimensionProperty(vizTypeProperty,datasource)
@@ -621,13 +737,16 @@ function fillDimensionProperty(vizTypeProperty,datasource)
}
function showChartPropertiesFormDiv ( formDiv , formElementsDiv , renderer )
{
if ( myChartModel != null )
{
var myDiv = document . getElementById ( formDiv ) ;
switch ( formDiv )
{
case "generalChartPropertiesFormDiv" :
renderGeneralChartPropertiesForm ( formElementsDiv , commonChartProperties , renderer ) ;
renderGeneralChartPropertiesForm ( formElementsDiv , commonChartProperties , myChartModel . renderer ) ;
break ;
case "ChartElementDiv" :
case "ChartElementsDiv" :
createChartElementConfig1Form ( myChartModel . renderer , null ) ;
break ;
default :
//do nothing
@ -639,7 +758,7 @@ function showChartPropertiesFormDiv(formDiv,formElementsDiv,renderer)
@@ -639,7 +758,7 @@ function showChartPropertiesFormDiv(formDiv,formElementsDiv,renderer)
myDiv . style . display = "none" ;
else
myDiv . style . display = "block" ;
}
}
function showSaveChartFormDiv ( formDiv , renderer )
@ -1012,7 +1131,7 @@ function fillSelectionResult(selectionRsMetaData)
@@ -1012,7 +1131,7 @@ function fillSelectionResult(selectionRsMetaData)
}
function renderDimensionField ( vizTypeProperty , datasource )
function renderDimensionField ( vizTypeProperty , datasource , selectedValue )
{
const fieldElem = document . createElement ( "div" ) ;
fieldElem . classList . add ( "field" ) ;
@ -1047,7 +1166,7 @@ function renderDimensionField(vizTypeProperty,datasource)
@@ -1047,7 +1166,7 @@ function renderDimensionField(vizTypeProperty,datasource)
renderChart ( 'chartDiv' ) ;
} ; * /
var dimensionProperty = fillDimensionProperty ( vizTypeProperty , datasource ) ;
fillSelectOptions ( selElem , dimensionProperty . getValueResultset ( ) , dimensionProperty . isMandatory ) ;
fillSelectOptions ( selElem , dimensionProperty . getValueResultset ( ) , dimensionProperty . isMandatory , selectedValue ) ;
inputSelectElem . appendChild ( selElem ) ;
inputFieldElem . appendChild ( inputSelectElem ) ;
fieldElem . appendChild ( inputFieldElem ) ;
@ -1071,7 +1190,7 @@ function renderGeneralChartPropertiesForm(formDiv,myCommonChartProperties,render
@@ -1071,7 +1190,7 @@ function renderGeneralChartPropertiesForm(formDiv,myCommonChartProperties,render
if ( groupUniquename != ""
&& groupUniquename != previousGroup
&& myCommonChartProperties [ k ] . groupVariableName != ""
&& isChartPropertyValidForChartelements ( myCommonChartProperties [ k ] )
//&& isChartPropertyValidForChartelements(myCommonChartProperties[k])
)
{
var newcommonChartPropertyGroup = new commonChartPropertyGroup ( myCommonChartProperties [ k ] . groupCaption , groupUniquename , "" ) ;
@ -1086,7 +1205,7 @@ function renderGeneralChartPropertiesForm(formDiv,myCommonChartProperties,render
@@ -1086,7 +1205,7 @@ function renderGeneralChartPropertiesForm(formDiv,myCommonChartProperties,render
const columnGroupDiv = document . createElement ( "div" ) ;
columnGroupDiv . id = commonChartPropertyGroups [ i ] . groupUniquename ;
columnGroupDiv . classList . add ( "box " ) ;
columnGroupDiv . classList . add ( "block " ) ;
const columnGroupHeaderDiv = document . createElement ( "div" ) ;
const colHeader = document . createTextNode ( commonChartPropertyGroups [ i ] . caption ) ;
@ -1117,33 +1236,20 @@ function renderGeneralChartPropertiesForm(formDiv,myCommonChartProperties,render
@@ -1117,33 +1236,20 @@ function renderGeneralChartPropertiesForm(formDiv,myCommonChartProperties,render
{
if ( myCommonChartProperties [ k ] . groupUniquename == commonChartPropertyGroups [ i ] . groupUniquename
&& myCommonChartProperties [ k ] . variableName != ""
&& isChartPropertyValidForChartelements ( myCommonChartProperties [ k ] ) )
columnGroupBodyDiv . appendChild ( renderChartPropertyField ( myCommonChartProperties [ k ] ) ) ;
//&& isChartPropertyValidForChartelements(myCommonChartProperties[k])
)
columnGroupBodyDiv . appendChild ( renderChartPropertyField ( null , myCommonChartProperties [ k ] , true ) ) ;
}
columnGroupDiv . appendChild ( columnGroupBodyDiv ) ;
columnDiv . appendChild ( columnGroupDiv ) ;
}
myForm . appendChild ( columnDiv ) ;
/ * a l t e L i s t e f l a c h :
const divBox = document . createElement ( "div" ) ;
for ( var k = 0 ; k < myCommonChartProperties . length ; k ++ )
{
if ( ( myCommonChartProperties [ k ] . groupVariableName == "layout"
|| myCommonChartProperties [ k ] . groupVariableName == "style"
|| myCommonChartProperties [ k ] . groupVariableName == "x"
|| myCommonChartProperties [ k ] . groupVariableName == "y"
|| myCommonChartProperties [ k ] . groupVariableName == "color"
)
&& myCommonChartProperties [ k ] . rendererUniquename == renderer )
divBox . appendChild ( renderChartPropertyField ( myCommonChartProperties [ k ] ) ) ;
}
myForm . appendChild ( divBox ) ;
* /
}
function isChartPropertyValidForChartelements ( prop )
{
var propValid = false ;
@ -1175,15 +1281,24 @@ function toggleGroupBodyDiv(groupBodyDiv)
@@ -1175,15 +1281,24 @@ function toggleGroupBodyDiv(groupBodyDiv)
}
function renderChartPropertyField ( commonChartProperty )
function renderChartPropertyField ( elemID , chartProperty , isCommon )
{
//Wenn im chartModel schon ein Wert vorhanden ist, wird er vorbelegt: if(commonC hartProperty)
//Wenn im chartModel schon ein Wert vorhanden ist, wird er vorbelegt: if(chartProperty)
var propValue = "" ;
if ( myChartModel && myChartModel . chartPropertiesUsed . length > 0 )
if ( myChartModel && isCommon && myChartModel . chartPropertiesUsed . length > 0 )
{
propValue = getCommonC hartPropertyFromModel ( myChartModel . chartPropertiesUsed , commonC hartProperty . name ) ;
propValue = getChartPropertyFromModel ( myChartModel . chartPropertiesUsed , chartProperty . name , isCommon ) ;
}
if ( myChartModel && ! isCommon && myChartModel . chartElements . length > 0 )
{
var filtered = myChartModel . chartElements . filter ( obj => obj . elemID == elemID ) ;
var myChartElem = filtered [ 0 ] ;
if ( myChartElem && myChartElem . elementTypeProperties && myChartElem . elementTypeProperties . length )
{
propValue = getChartPropertyFromModel ( myChartElem . elementTypeProperties , chartProperty . name , isCommon ) ;
}
}
const fieldElem = document . createElement ( "div" ) ;
fieldElem . classList . add ( "field" ) ;
fieldElem . classList . add ( "is-grouped" ) ;
@ -1195,31 +1310,31 @@ function renderChartPropertyField(commonChartProperty)
@@ -1195,31 +1310,31 @@ function renderChartPropertyField(commonChartProperty)
label . classList . add ( "is-required" ) ;
label . classList . add ( "is-small" ) ;
label . classList . add ( "has-tooltip-right" ) ;
label . setAttribute ( "data-tooltip" , commonC hartProperty . explanation ) ;
label . setAttribute ( "data-tooltip" , chartProperty . explanation ) ;
const textnode = document . createTextNode ( commonC hartProperty . caption ) ;
const textnode = document . createTextNode ( chartProperty . caption ) ;
label . appendChild ( textnode ) ;
labelElem . appendChild ( label ) ;
fieldElem . appendChild ( labelElem ) ;
//input:
const inputControlElem = document . createElement ( "div" ) ;
inputControlElem . classList . add ( "control-new" ) ;
const inputFieldElem = document . createElement ( "div" ) ;
inputFieldElem . classList . add ( "field" ) ;
const inputParaElem = document . createElement ( "p" ) ;
inputParaElem . classList . add ( "control-new" ) ;
const inputElem = document . createElement ( "div" ) ;
inputElem . classList . add ( "is-small" ) ;
//inputElem.classList.add("is-fullwidth");
switch ( commonC hartProperty . inputType ) {
switch ( chartProperty . inputType ) {
case "SELECT" :
//select input:
inputElem . classList . add ( "select" ) ;
inputElem . classList . add ( "is-small" ) ;
const selElem = document . createElement ( "select" ) ;
selElem . name = commonC hartProperty . name ;
selElem . id = commonC hartProperty . name ;
selElem . name = chartProperty . name ;
selElem . id = chartProperty . name ;
//selElem.style="width:50px";
if ( commonC hartProperty . variableName == "" )
if ( chartProperty . variableName == "" )
{
selElem . disabled = "disabled" ;
selElem . readonly = "readonly" ;
@ -1229,10 +1344,10 @@ function renderChartPropertyField(commonChartProperty)
@@ -1229,10 +1344,10 @@ function renderChartPropertyField(commonChartProperty)
updateChartModel ( ) ;
renderChart ( 'chartDiv' , myChartModel ) ;
} ;
fillSelectOptions ( selElem , commonC hartProperty . getValueResultset ( ) , commonC hartProperty . isMandatory ) ;
selElem . value = ( propValue == "" ) ? commonC hartProperty . defaultValue : propValue ;
fillSelectOptions ( selElem , chartProperty . getValueResultset ( ) , chartProperty . isMandatory , propValue ) ;
selElem . value = ( propValue == "" ) ? chartProperty . defaultValue : propValue ;
inputElem . appendChild ( selElem ) ;
inputPara Elem . appendChild ( inputElem ) ;
inputField Elem . appendChild ( inputElem ) ;
break ;
case "TEXTAREA" :
@ -1240,20 +1355,20 @@ function renderChartPropertyField(commonChartProperty)
@@ -1240,20 +1355,20 @@ function renderChartPropertyField(commonChartProperty)
const textAreaElem = document . createElement ( "textarea" ) ;
textAreaElem . cols = "20" ;
textAreaElem . rows = 3 ;
if ( commonC hartProperty . variableName == "" )
if ( chartProperty . variableName == "" )
{
textAreaElem . disabled = "disabled" ;
textAreaElem . readonly = "readonly" ;
}
textAreaElem . name = commonC hartProperty . name ;
textAreaElem . id = commonC hartProperty . name ;
textAreaElem . value = ( propValue == "" ) ? commonC hartProperty . defaultValue : propValue ;
textAreaElem . name = chartProperty . name ;
textAreaElem . id = chartProperty . name ;
textAreaElem . value = ( propValue == "" ) ? chartProperty . defaultValue : propValue ;
textAreaElem . onchange = function ( ) {
updateChartModel ( ) ;
renderChart ( 'chartDiv' , myChartModel ) ;
} ;
inputElem . appendChild ( textAreaElem ) ;
inputPara Elem . appendChild ( inputElem ) ;
inputField Elem . appendChild ( inputElem ) ;
break ;
case "RANGE" :
@ -1262,7 +1377,7 @@ function renderChartPropertyField(commonChartProperty)
@@ -1262,7 +1377,7 @@ function renderChartPropertyField(commonChartProperty)
const rangeElem = document . createElement ( "input" ) ;
rangeElem . type = "NUMBER" ;
rangeElem . size = 5 ;
if ( commonC hartProperty . variableName == "" )
if ( chartProperty . variableName == "" )
{
rangeElem . disabled = "disabled" ;
rangeElem . readonly = "readonly" ;
@ -1270,58 +1385,58 @@ function renderChartPropertyField(commonChartProperty)
@@ -1270,58 +1385,58 @@ function renderChartPropertyField(commonChartProperty)
/ * k l a p p t n o c h n i c h t :
rangeElem . type = "RANGE" ;
rangeElem . min = commonC hartProperty . range _from ;
rangeElem . max = commonC hartProperty . range _to ;
rangeElem . min = chartProperty . range _from ;
rangeElem . max = chartProperty . range _to ;
rangeElem . step = 50 ;
* /
rangeElem . name = commonC hartProperty . name ;
rangeElem . id = commonC hartProperty . name ;
rangeElem . value = ( propValue == "" ) ? commonC hartProperty . defaultValue : propValue ;
rangeElem . name = chartProperty . name ;
rangeElem . id = chartProperty . name ;
rangeElem . value = ( propValue == "" ) ? chartProperty . defaultValue : propValue ;
rangeElem . onchange = function ( ) {
updateChartModel ( ) ;
renderChart ( 'chartDiv' , myChartModel ) ;
} ;
inputElem . appendChild ( rangeElem ) ;
inputPara Elem . appendChild ( inputElem ) ;
inputField Elem . appendChild ( inputElem ) ;
break ;
default :
//Einfaches Texteingabefeld:
const inpElem = document . createElement ( "input" ) ;
inpElem . type = "TEXT" ;
if ( commonC hartProperty . propValueType == "integer" )
if ( chartProperty . propValueType == "integer" )
inpElem . type = "NUMBER" ;
if ( commonC hartProperty . inputType == "COLOR" )
if ( chartProperty . inputType == "COLOR" )
inpElem . type = "color" ;
inpElem . size = 5 ;
if ( commonC hartProperty . variableName == "" )
if ( chartProperty . variableName == "" )
{
inpElem . disabled = "disabled" ;
inpElem . readonly = "readonly" ;
}
inpElem . name = commonC hartProperty . name ;
inpElem . id = commonC hartProperty . name ;
inpElem . value = ( propValue == "" ) ? commonC hartProperty . defaultValue : propValue ;
inpElem . name = chartProperty . name ;
inpElem . id = chartProperty . name ;
inpElem . value = ( propValue == "" ) ? chartProperty . defaultValue : propValue ;
inpElem . onchange = function ( ) {
updateChartModel ( ) ;
renderChart ( 'chartDiv' , myChartModel ) ;
} ;
inputElem . appendChild ( inpElem ) ;
inputPara Elem . appendChild ( inputElem ) ;
inputField Elem . appendChild ( inputElem ) ;
break ;
}
inputField Elem . appendChild ( inputPara Elem ) ;
fieldElem . appendChild ( inputField Elem ) ;
inputControl Elem . appendChild ( inputField Elem ) ;
fieldElem . appendChild ( inputControl Elem ) ;
return fieldElem ;
}
function fillSelectOptions ( myCombo , myValues , isMandatory )
function fillSelectOptions ( myCombo , myValues , isMandatory , selectedValue )
{
var optionCounter = 0 ;
var selectedOption = null ;
@ -1339,8 +1454,10 @@ if(!isMandatory)
@@ -1339,8 +1454,10 @@ if(!isMandatory)
}
for ( var j = 0 ; j < myValues . length ; j ++ )
{
if ( myValues [ j ] . isDefault )
selectedOption = optionCounter ;
if ( myValues [ j ] . value == selectedValue )
selectedOption = j + ( isMandatory ? 0 : 1 ) ;
if ( selectedOption == null && myValues [ j ] . isDefault )
selectedOption = j + ( isMandatory ? 0 : 1 ) ;
var o = new Option ( myValues [ j ] . name , myValues [ j ] . value , null , null ) ;
myCombo . options [ optionCounter ] = o ;
@ -1684,8 +1801,8 @@ function renderChartElementWithD3(currentChartModel,chartElemNr,targetDiv)
@@ -1684,8 +1801,8 @@ function renderChartElementWithD3(currentChartModel,chartElemNr,targetDiv)
// append the svg canvas to the page
var margin = { top : 10 , right : 10 , bottom : 10 , left : 10 } ,
//var margin = { top: 0, right: 50, bottom: 0, left: 0 },
width = getCommonC hartPropertyFromModel ( currentChartModel . chartPropertiesUsed , "width" ) - margin . left - margin . right ,
height = getCommonC hartPropertyFromModel ( currentChartModel . chartPropertiesUsed , "height" ) - margin . top - margin . bottom ;
width = getChartPropertyFromModel ( currentChartModel . chartPropertiesUsed , "width" ) - margin . left - margin . right ,
height = getChartPropertyFromModel ( currentChartModel . chartPropertiesUsed , "height" ) - margin . top - margin . bottom ;
var clearCanvas = document . getElementById ( targetDiv ) ;
while ( clearCanvas . firstChild ) {
@ -2086,17 +2203,20 @@ function getChartPropertyValue(propArray,propName)
@@ -2086,17 +2203,20 @@ function getChartPropertyValue(propArray,propName)
}
return propertyValue ;
}
function getCommonC hartPropertyFromModel ( myCommonC hartProperties , name )
function getChartPropertyFromModel ( myChartProperties , name , isCommon )
{
var propertyValue = "" ;
if ( myCommonC hartProperties && myCommon ChartProperties . length > 0 )
if ( myChartProperties && myChartProperties . length > 0 )
{
let prop = myCommonChartProperties . find ( o => o . name === name ) ;
let prop = myChartProperties . find ( o => o . name === name ) ;
if ( ! prop )
prop = myChartProperties . find ( o => o . vizTypePropertyUniquename == name ) ;
if ( prop )
propertyValue = prop . propertyValue ;
}
//if no value is set from model, retrieve the default value:
if ( propertyValue == "" )
if ( propertyValue == "" && isCommon )
propertyValue = getCommonChartProperty ( name ) ;
@ -2247,13 +2367,14 @@ if(myJsonString!="")
@@ -2247,13 +2367,14 @@ if(myJsonString!="")
if ( myChartModel )
{
document . getElementById ( "vizElementCounter" ) . value = myChartModel . chartElements . length ;
renderChart ( chartDiv , myChartModel )
renderChart ( chartDiv , myChartModel ) ;
fillChartElementListSelect ( document . getElementById ( "chartElementID" ) , null ) ;
}
}
}
}
function copySrcCode ( mydiv )
{
var ergtabelle = document . getElementById ( mydiv ) ;
@ -2402,7 +2523,7 @@ for (let i = 1; i < 4; i++) {
@@ -2402,7 +2523,7 @@ for (let i = 1; i < 4; i++) {
function makeWorldmapD3 ( myCommonChartProperties , mySvg , data , metaData , chartElem )
{
// load the data
var captionEmptyTarget = getCommonC hartPropertyFromModel ( myCommonChartProperties , "null_value_mask" ) ;
var captionEmptyTarget = getChartPropertyFromModel ( myCommonChartProperties , "null_value_mask" ) ;
renderWorldMap ( myCommonChartProperties , mySvg , data ) ;
}
@ -2484,7 +2605,7 @@ return myData;
@@ -2484,7 +2605,7 @@ return myData;
function makeSankeyD3 ( myCommonChartProperties , mySvg , data , metaData , chartElem )
{
// load the data
var captionEmptyTarget = getCommonC hartPropertyFromModel ( myCommonChartProperties , "null_value_mask" ) ;
var captionEmptyTarget = getChartPropertyFromModel ( myCommonChartProperties , "null_value_mask" ) ;
if ( captionEmptyTarget == "" )
captionEmptyTarget = "Leer" ;
var sNodes = getSankeyNodes ( data , captionEmptyTarget ) ; //graph.nodes;
@ -2602,19 +2723,19 @@ function renderSankey(myCommonChartProperties,svg,sNodes,sLinks)
@@ -2602,19 +2723,19 @@ function renderSankey(myCommonChartProperties,svg,sNodes,sLinks)
// set the dimensions and margins of the graph
var margin = { top : 10 , right : 10 , bottom : 10 , left : 10 } ,
//var margin = { top: 0, right: 50, bottom: 0, left: 0 },
width = getCommonC hartPropertyFromModel ( myCommonChartProperties , "width" ) - margin . left - margin . right ,
height = getCommonC hartPropertyFromModel ( myCommonChartProperties , "height" ) - margin . top - margin . bottom ;
width = getChartPropertyFromModel ( myCommonChartProperties , "width" ) - margin . left - margin . right ,
height = getChartPropertyFromModel ( myCommonChartProperties , "height" ) - margin . top - margin . bottom ;
// format variables
var formatNumber = d3 . format ( ",.0f" ) , // zero decimal places
format = function ( d ) { return formatNumber ( d ) ; } ,
color = d3 . scaleOrdinal ( ) . range ( [ "#002060ff" , "#164490ff" , "#4d75bcff" , "#98b3e6ff" , "#d5e2feff" , "#008cb0ff" ] ) ;
var textColor = getCommonC hartPropertyFromModel ( myCommonChartProperties , "color" ) ;
var textColor = getChartPropertyFromModel ( myCommonChartProperties , "color" ) ;
if ( textColor == "" )
textColor = "#3f3f3f" ;
var fontSize = getCommonC hartPropertyFromModel ( myCommonChartProperties , "fontSize" ) ;
var fontSize = getChartPropertyFromModel ( myCommonChartProperties , "fontSize" ) ;
if ( fontSize == "" )
fontSize = "12pt" ;
var fontFamily = getCommonC hartPropertyFromModel ( myCommonChartProperties , "fontFamily" ) ;
var fontFamily = getChartPropertyFromModel ( myCommonChartProperties , "fontFamily" ) ;
if ( fontFamily == "" )
fontFamily = "sans-serif" ;
// append the svg object to the body of the page