|
Need a help on converting yaxis values from bytes to mb |
Posted by ram on Dec-23-2015 07:18 |
|
Hi ,
I have 3 graph in single report.In that, graph 2 values needs to be converted.how to make
changes to specific Graph values.
Thanks |
Re: Need a help on converting yaxis values from bytes to mb |
Posted by Peter Kwan on Dec-23-2015 23:42 |
|
Hi ram,
The suggested method to use a certain visible unit (unit that is used in labels) is to
directly use that unit in your data. For example, if you want to use MB as the unit, simply
use MB as the unit for your data.
For MB as unit, some people define 1MB = 1000000 bytes, while some defines 1MB =
1048576 bytes. Suppose you want to use 1MB = 1048576 bytes, you can use, and your
data in your database table is using bytes, there are two methods:
(a) Change your SQL so that it returns MB instead of bytes. For example, instead of
"SELECT myData, ....", use "SELECT myData/1000000, .....".
(b) If your data do not come from a database and cannot be manipulated with SQL, you
can use code to change the data. For example:
for (int i = 0; i < myData.Length; ++i) myData[i] /= 1000000;
You can always insert any text in the axis labels or axis title so that the user knows the
numbers are in MB. For example:
c.yAxis().setTitle("My Data (in MB)");
or
c.yAxis().setLabelFormat("{value}MB");
If you must pass the data in bytes units to ChartDirector, and want ChartDirector to
automatically determine the axis scale, and then want to express the labels in special
units, it may work well if the units are decimal units. It is because the labels generated
by ChartDirector assumes decimal units. For example, ChartDirector may create labels like
100, 200, 300, which are nice numbers in decimal units, and not something like 64, 128,
192.....
For your case, to ask ChartDirector to format the labels in MB units, where 1MB =
1000000 bytes, the code is:
c.yAxis().setLabelFormat("{={value}/1000000}MB");
Hope this can help.
Regards
Peter Kwan |
Re: Need a help on converting yaxis values from bytes to mb |
Posted by ram on Dec-24-2015 00:15 |
|
Peter Kwan wrote:
Hi ram,
The suggested method to use a certain visible unit (unit that is used in labels) is to
directly use that unit in your data. For example, if you want to use MB as the unit,
simply
use MB as the unit for your data.
For MB as unit, some people define 1MB = 1000000 bytes, while some defines 1MB =
1048576 bytes. Suppose you want to use 1MB = 1048576 bytes, you can use, and your
data in your database table is using bytes, there are two methods:
(a) Change your SQL so that it returns MB instead of bytes. For example, instead of
"SELECT myData, ....", use "SELECT myData/1000000, .....".
(b) If your data do not come from a database and cannot be manipulated with SQL, you
can use code to change the data. For example:
for (int i = 0; i < myData.Length; ++i) myData[i] /= 1000000;
You can always insert any text in the axis labels or axis title so that the user knows the
numbers are in MB. For example:
c.yAxis().setTitle("My Data (in MB)");
or
c.yAxis().setLabelFormat("{value}MB");
If you must pass the data in bytes units to ChartDirector, and want ChartDirector to
automatically determine the axis scale, and then want to express the labels in special
units, it may work well if the units are decimal units. It is because the labels generated
by ChartDirector assumes decimal units. For example, ChartDirector may create labels
like
100, 200, 300, which are nice numbers in decimal units, and not something like 64, 128,
192.....
For your case, to ask ChartDirector to format the labels in MB units, where 1MB =
1000000 bytes, the code is:
c.yAxis().setLabelFormat("{={value}/1000000}MB");
Hope this can help.
Regards
Peter Kwan
Thanks Peter but If I make this change c.yAxis().setLabelFormat("{=
{value}/1000000}MB"); ,then y-axis all other graph in Same page is getting impacted .I
need only to convert on 2nd graph .How can i achieve this. |
Re: Need a help on converting yaxis values from bytes to mb |
Posted by Peter Kwan on Dec-25-2015 00:07 |
|
Hi ram,
I am not sure how you create multiple charts in the same page. If you are using 3 separate
functions, like "createFirstChart(.....)", "createSecondChart(.....)", and
"createThirdChart(....)", then you just need to modify the code in "createSecondChart". In
this way, only one chart is affected.
If you are using the same function to draw all the charts in your web page, there must be
called with different parameters so that your subroutine can draw different charts. For
example, it may be like "createChart(1, ...)", "createChart(2, ...." and "createChart(3, ...)".
If for some reason, there is not already a parameter, you can add one to your function.
Then in the code, you just need to apply the change if it is drawing chart 2.
if (currentChart == 2)
c.yAxis().setLabelFormat("{={value}/1000000}MB");
If the above still does not solve the problem, would you mind to inform me of your code to
draw multiple charts so that I can know how to apply the setLabelFormat for only one of
the charts.
Regards
Peter Kwan |
|