Browse Source

barY plot implemented #3

makro_datasrc
Daniel Quathamer 3 years ago
parent
commit
d9e276ea6a
  1. 51
      superx/xml/js/d3/viz_functions.js
  2. 1
      superx/xml/viz_html_chart.xsl

51
superx/xml/js/d3/viz_functions.js vendored

@ -83,6 +83,9 @@ function prepareChartProperties(chartType) @@ -83,6 +83,9 @@ function prepareChartProperties(chartType)
case "bar_x":
chartProperties=prepareBarXForm();
break;
case "rect_y":
chartProperties=prepareRectYForm();
break;
case "line":
chartProperties=prepareLineForm();
break;
@ -107,6 +110,18 @@ function prepareBarXForm() @@ -107,6 +110,18 @@ function prepareBarXForm()
return chartProperties;
}
function prepareRectYForm()
{
var chartProperties=[];
var propertyCounter=0;
var myProp= new chartProperty("viz_category_dim","Kategorie-Dimension",true,false,false,null,null,true);
chartProperties[0]=myProp;
var myProp= new chartProperty("viz_measure_dim","Maß",true,true,false,null,null,true);
chartProperties[1]=myProp;
return chartProperties;
}
function prepareLineForm()
{
var chartProperties=[];
@ -324,8 +339,11 @@ switch (chartType) @@ -324,8 +339,11 @@ switch (chartType)
{
case "bar_x":
makeBarX(svg,data);
//makeBarY(svg,data);
break;
case "rect_y":
makeRectY(svg,data);
break;
case "line":
makeLine(svg,data);
break;
@ -429,6 +447,37 @@ var options = { @@ -429,6 +447,37 @@ var options = {
document.getElementById("chartDiv").appendChild(Plot.plot(options));
}
function makeRectY(svg,data) {
var xLabel=rsMetaData[document.getElementById("viz_category_dim").value-1].colcaption;
var yLabel=rsMetaData[document.getElementById("viz_measure_dim").value-1].colcaption;
var fontSize=getCommonChartProperty("fontSize");
var maxLenName=d3.max(data, d => d.name.length);
var maxLenNamePx=maxLenName*fontSize/1.5;
var marginLeftPx=xLabel.length*fontSize;
var options = {
marginBottom:maxLenNamePx,
marginLeft:marginLeftPx,
x: {
tickRotate: -45
},
// set y axis options
y: {
grid:true,
label: yLabel
},
sort: "nr",
marks: [
Plot.barY(data,{
x: "name",
y: "value"
})
]
}
document.getElementById("chartDiv").appendChild(Plot.plot(options));
}
function makeBarY(svg,data) {
var options = {
marginBottom:100,

1
superx/xml/viz_html_chart.xsl

@ -1171,6 +1171,7 @@ rs[</xsl:text><xsl:value-of select="$rownr"/><xsl:text>][</xsl:text><xsl:value-o @@ -1171,6 +1171,7 @@ rs[</xsl:text><xsl:value-of select="$rownr"/><xsl:text>][</xsl:text><xsl:value-o
<td><select class="maskinputPflicht" id="viz_chart_type" NAME="viz_chart_type" tabindex="200" onChange="prepareChartProperties(this.value)" >
<option class="maskinput" value="">Bitte wählen</option>
<option class="maskinput" value="bar_x">Balkendiagramm horizontal (einfach)</option>
<option class="maskinput" value="rect_y">Balkendiagramm vertikal (einfach)</option>
<option class="maskinput" value="line">Liniendiagramm vertikal (einfach)</option>
</select>
</td>

Loading…
Cancel
Save