|
|
|
|||||||||||||||||||||||||
|
To demonstrate what you would need to do to adapt one of these templates to your own purposes, we'll start with a simple one and then do a more complex one.
Modifying an XML file for a standard 1D histogramIn this example We're going to change the data source of the plot, the title, the color the plot is drawn in, and type of y axis it uses. We'll use the XML file for the above '1D Logarithmic with Stats (square)' example as out template. The full xml file for this plot is available here. To change the Data Source:To change what histogram the plot displays, we need to change the <class> section of the XML file. It currently reads
<class name="jas.bean.TreeDataSourceProvider"
param="Histograms/test/Reference/1D Gaussian (sigma=4)"/>
The 'param' attribute is the path to the histogram in the jas tree. We need to change this to point a different histogram. If you are converting from an HTML file, this path will be the same as the 'value' parameter specified for the histogram in your old HTML file. Please note: The path parameter is no longer case-sensitive, meaning that the following path parameters
param="Histograms/test/Reference/1D Gaussian (sigma=4)"
param="HISTOGRAMS/TEST/REFERENCE/1D GAUSSIAN (SIGMA=4)"
param="HistoGRAMS/test/REFERENCE/1D Gaussian (SIGMA=4)"
are all equivalent. This is particularly relevant in the case of using reference
servers that read HBOOK files. The directory structure for the reference histograms
will likely be identical to that of the live histograms, but the capitalization
of the folder names in the Jas tree may not be (the reference server folders
will have names in all capital letters). We highly recommend that when specifying the path
to a reference histogram with XML, you follow the same capitalization pattern as in the
path to the live data. In other words, if you are displaying a histogram and it's reference
on your html page, the path parameter for the reference should be identical to that of the
live histogram except for the name of the top-level folder the histograms are stored in.
To change the title:
We need to work with the <title> section of the XML file. It currently reads
<title>
<border type="None"/>
<label text="1D Logarithmic with stats (square)">
<font face="SansSerif" points="14" style="BOLD"/>
</label>
</title>
We see from this that the 'text' attribute of the title tag must be what we need to change. Change "1D logarithmic ..." to 'Our Changed Histogram'. To change the plot color: We need to work with the <style1d> section of the XML file. It currently reads
<style1d histogramBarsFilled="false" histogramBarColor="Green"
errorBarColor="Black" dataPointColor="Black"
dataPointStyle="box" dataPointSize="6"
lineColor="Red" showHistogramBars="true"
showErrorBars="false" showDataPoints="false"
showLinesBetweenPoints="false"/>
Change the 'histogramBarColor' tag from 'Green' to 'Red'.
To change the axis type: We need to work with the <axis> section of the xml file for the y axis. Since we only have one, this is the axis section with location specified to be 'y0'. A second y axis would have it's own axis section of the xml file, with location equal to 'y1'. The y0 axis section currently reads:
<axis location="y0" type="double" showOverflows="false"
logarithmic="true" allowSuppressedZero="true">
<font face="Dialog" points="12" style="PLAIN"/>
</axis>
Change 'logarithmic' from true to false, and the axis will now
be a regular, non-logarithmic axis.
Using the 'Save as XML' feature in JASAnother way to create an XML file is to manipulate a histogram in Jas, then save it as an XML file. Here's what you need to do:
<class name="???" param="???"/>
You need to replace the ??? in 'name' to 'jas.bean.TreeDataSourceProvider', and the param to be the path to your histogram in the Jas tree. A valid example for my own test server would be:
<class name="jas.bean.TreeDataSourceProvider"
param="Histograms/test/Reference/1D Gaussian (sigma=4)"/>
The path to your histogram will be different.
NOTE: The path parameter is no longer case-sensitive. Please refer to the note above for what exactly this means when using reference histograms. That's all there is to it! Now we just have to set our HTML file up correctly, and we're done. Setting up the HTML fileThis is the easiest part of the lesson. For each XML plot you have on your page, you must put a corresponding <Object> tag in your HTML. The form of the tag looks like this:
<object classid="hep.babar.JasExtensions.BabarXMLPlot">
<PARAM name = "xmlURL" value="relative/path/to/your/xml/file">
</object>
The path to the xml file is relative to the directory from which the HTML page resides in. So, for example, if I wanted to show a plot on my page that needed an xml file in the 'xml' subdirectory of my main HTML directory, my HTML tags would look like this:
<object classid="hep.babar.JasExtensions.BabarXMLPlot">
<PARAM name = "xmlURL" value="xml/my_file.xml">
</object>
|