|
ruby local installation, logscale and font issues |
Posted by bterkuile on Nov-03-2008 18:23 |
|
I am testing ChartDirector to see if it fits my needs. I think it is the best candidate, but I had some issues getting it to work properly and think there are some bugs.
At first, installing in a location of own choosing. This can by adding the install directory to the RUBYLIB environment variable (.bashrc)
export RUBYLIB=/path/to/chartdirector:$RUBYLIB
but in a 64 bit kubuntu hardy installation rubycdapi.so cannot find rubycdapi.so which is in the same directory. Starting a ruby script like:
require "readline"
require "chartdirector"
will solve the problem. I don't know why, but readline adds something that fixes the ChartDirector search path or something like that.
At second, I had a lot of trouble getting greek characters to work, but finally discovered that the build in fonts were not used at all. The ugly solution of adding fonts to the chartdirector fonts folder works, but is not preferable I think. Setting the FONTPATH variable can help, but setting it to something like:
/usr/share/fonts
will not include the subdirectories, like /usr/share/fonts/truetype.
The third is plotting in logscale. I plot an XYchart, and use the logscale like:
c.yAxis.setLogScale(minvalue, ChartDirector::NoValue)
I expect the minvalue to be the starting value, but it seems that this value divided by five is the minimal value. If the minvalue is bigger than all the data, nothing is plotted (that is logical), but if the data is smaller than starting value on the yAxis the plot goes through the chart.
Can this be solved? Then I would like ChartDirector for plotting my thesis graphs
|
Re: ruby local installation, logscale and font issues |
Posted by Peter Kwan on Nov-03-2008 23:01 |
|
Hi bterkuile,
1) ChartDirector only does a basic "search" for "rubycdapi.so". It expects Ruby to search the "rubycdapi.so". The code in chartdierctor.rb that searches for the "rubycdapi.so" is just:
begin
require(File.join(File.dirname(__FILE__), "rubycdapi"))
rescue
require("rubycdapi")
The last line require("rubycdapi") is to ask Ruby to search for the file. We may need to trouble-shoot Ruby or the Ruby configuration to see why it cannot locate the file. The issue is unlikely to be related to ChartDirector, because ChartDirector is not even loaded when the error occurs.
2) For Greek or may other characters, note that you need to use a font that can display Greek. ChartDirector does not include font that can display all possible characters. It is expected the developer would provide the necessary fonts.
In Windows and Mac OS X, there are standard directories for fonts, and ChartDirector will use those fonts.
In Solaris, Linux, FreeBSD, there are no standard directory for fonts. In fact, many of these operating systems are installed without any font at all (especially for server usage, in which GUI is not needed). So ChartDirector uses its own fonts directory. This should be a more general solution, as it works in all cases (even in systems without a font directory). ChartDirector also supports using FONTPATH, but it will not search subdirectories.
You may consider to copy the fonts to the ChartDirector font subdirectory. In this way, you may copy your own Ruby application (with ChartDirector subdirectory) to another computer, and it still works. If you use a FONTPATH, your application may not work in a computers that do not have fonts.
For log scale, note that if incomplete information is specified (eg. no tick increment is specified), ChartDirector may adjust the scale to fit the other constrains. In particular, it may add a margin to the scale limits, and extend the scale to make sure the axis end points are at tick positions. For example, if the lower limit is set to 0.1914637914, ChartDirector may adjust it to 0.1.
If you do not want ChartDirector to adjust the axis end points, you may either provide full information on the axis scale (minValue, maxValue, tickInc), or you may use the following code to disable the margin and to disable ChartDirector from ensuring the axis ends points are at tick positions.
c.yAxis().setAutoScale(0, 0, 0)
c.yAxis().setRounding(false, true)
If you specify an axis scale, and the data exceed the scale, the default behaviour is to draw the line outside of the plot area. You may clip the line to within the plot area by using:
c.setClipping()
Hope this can help.
Regards
Peter Kwan |
|