Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Distance-based text in y-axis
boris256
I would like to create a transit stringline chart to show bus movements. The x-axis is time, and the y-axis is distance. But on the y-axis I would like to show the names of stations spaced proportionally to the actual distance between them. Is it possible to do that?
Conceptually I can think of creating two value series and relating them somehow, but I don't see a way to put text on the y-axis.
Find more posts tagged with
Comments
kclark
I've attached a report that shows what you're trying to do, it uses a scripted dataset for the time and distance. The x axis shows the time and the y value shows the distance which is spaced for the actual difference.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawAxisLabel( axis, label, icsc )
{
if(!axis.isCategoryAxis()){
oldValue = label.getCaption().getValue();
newValue = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(oldValue);
if(newValue == null){
label.getCaption().setValue("");
} else {
label.getCaption().setValue(newValue);
}
}
}
</pre>
brianlevin
Thanks kclark. I work with boris256 and this was very helpful. Would it be possible to develop a similar script that, instead of labeling the y-axis, instead creates markers along the y-axis at value equal to the distance and with the label of the station name. <br />
<br />
I've gotten the following to work, where 'val1' is the distance and the persistent global variable is set to:<br />
reportContext.setPersistentGlobalVariable(row["TotalMiles"].toString(),row["Stop"]);<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
new_ml = MarkerLineImpl.create(yAxis, NumberDataElementImpl.create(val1));
new_ml.setLabelAnchor(Anchor.NORTH_WEST_LITERAL);
new_ml.getLabel().getCaption().setValue(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(val1));
yAxis.getMarkerLines().add(new_ml);
</pre>
<br />
However, I somehow need to cycle through all of the values in the corresponding dataset to create all the necessary markers. Is there any way to do this?<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="112601" data-time="1355950234" data-date="19 December 2012 - 01:50 PM"><p>
I've attached a report that shows what you're trying to do, it uses a scripted dataset for the time and distance. The x axis shows the time and the y value shows the distance which is spaced for the actual difference.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawAxisLabel( axis, label, icsc )
{
if(!axis.isCategoryAxis()){
oldValue = label.getCaption().getValue();
newValue = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(oldValue);
if(newValue == null){
label.getCaption().setValue("");
} else {
label.getCaption().setValue(newValue);
}
}
}
</pre></p></blockquote>