org.eobjects.analyzer.beans.valuedist.ValueDistributionChartScriptHeadElement.scala Maven / Gradle / Ivy
package org.eobjects.analyzer.beans.valuedist
import scala.collection.JavaConversions.collectionAsScalaIterable
import org.eobjects.analyzer.result.html.HeadElement
import org.eobjects.analyzer.result.html.HtmlRenderingContext
import org.eobjects.analyzer.result.ValueCountingAnalyzerResult
import org.eobjects.analyzer.util.LabelUtils
import org.eobjects.analyzer.result.SingleValueFrequency
import org.eobjects.analyzer.result.ValueFrequency
import java.util.Collections
class ValueDistributionChartScriptHeadElement(result: ValueCountingAnalyzerResult, valueCounts: Iterable[ValueFrequency], chartElementId: String) extends HeadElement {
override def toHtml(context: HtmlRenderingContext): String = {
// will be used to plot the y-axis value. Descending/negative because we want them to go from top to bottom.
var negativeIndex = 0;
return """
"""
}
def getColor(vc: ValueFrequency): String = {
val name = vc.getName();
name match {
case LabelUtils.UNIQUE_LABEL => return "#ccc";
case LabelUtils.BLANK_LABEL => return "#eee";
case LabelUtils.UNEXPECTED_LABEL => return "#333";
case LabelUtils.NULL_LABEL => return "#111";
case _ => name.toLowerCase() match {
case "red" | "blue" | "green" | "yellow" | "orange" | "black" => return name.toLowerCase();
case "not_processed" => return "#333";
case "failure" => return "#000";
case _ => return null;
}
}
}
def escapeLabel(context: HtmlRenderingContext, name: String): String = {
val escaped = context.escapeJson(name)
return escaped.replaceAll("<", "<").replaceAll(">", ">");
}
}