ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  splitting guage scale
Posted by csharpcorner on Dec-28-2010 00:21
Hi,

Is it possible to split guage scale 0 to 50(0,50) and 50 to 100(50,60,70,80,90,100) in Round guage. Please advice.

Thanks

  Re: splitting guage scale
Posted by Peter Kwan on Dec-28-2010 01:50
Hi csharpcorner,

I am not exactly sure the exact scale you would like to see. Do you mean you want to see the labels on the guage to be 0, 50, 60, 70, 80, 90, 100, where all the labels are evenly spaced (that is, the spacing between 0 and 50 is the same as the spacing between 50 and 60)?

The labels on the guage are just names and can be anything you like. You can certainly use 0, 50, 60, 70, 80, 90, 100. For example, in C#:

m.setScale2(0, 6, new string[] {"0", "50", "60", "70", "80", "90", "100"});

Now when you set the pointer, you just need to inform ChartDirector where should the pointer points to, like:

double meterValue;
if (dataValue <= 50)
    meterValue = dataValue / 50;
else
    meterValue = (dataValue - 50) / 50 * 5 + 1;

m.addPointer(meterValue , 0xffff00);

Hope this can help.

Regards
Peter Kwan

  Re: splitting guage scale
Posted by csharpcorner on Dec-28-2010 03:01
Hi Peter,

Thanks for your reply, this is what exactly i need. Is there any chance i can have it in Classic ASP.

  Re: splitting guage scale
Posted by Peter Kwan on Dec-29-2010 01:52
Hi csharpcorner,

It is:

Call m.setScale2(0, 6, Array("0", "50", "60", "70", "80", "90", "100"))

If dataValue <= 50 Then
    meterValue = dataValue / 50
Else
    meterValue = (dataValue - 50) / 50 * 5 + 1
End If

Call m.addPointer(meterValue , &Hffff00)

Hope this can help.

Regards
Peter Kwan

  Re: splitting guage scale
Posted by CSharpCorner on Jan-11-2011 02:35
Hi Peter,

I am not able to get the pointer correctly for its value in the chart.

Here is my code,

<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")

value = request.QueryString("value")
benchvalue = request.QueryString("benchvalue")
label= request.QueryString("label")

Set m = cd.AngularMeter(150, 150, cd.silverColor(), &H0, -2)
Call m.setMeter(65, 65, 60, -130, 130)
Call m.setScale2(0, 100, Array(0, 50, 60, 70, 80, 90, 100))
Call m.setLineWidth(0, 2, 1)
Call m.addRing(0, 65, cd.metalColor(&H9999dd))
Call m.addRing(65, 67, &H6666ff)

Call m.addZone(0, 80, &Hff3333)
Call m.addZone(80, 90, &Hffff00)
Call m.addZone(90, 100, &H99ff99)

Call m.addText(75, 125, label, "arialbd.ttf", 10, cd.TextColor, cd.Center)

Call m.addText(75, 105, m.formatValue(value, "1"), "Arial", 8, &Hffffff, _
    cd.Center).setBackground(&H0, &H0, -1)
if len(request.QueryString("benchvalue"))>0 then
Call m.addText(130, 140, m.formatValue(benchvalue, "1"), "Arial", 8, &Hffffff, _
    cd.Center).setBackground(&H0, &H0, -1)
end if

Dim meterValue

if (value <= 50) then
    meterValue = dataValue / 50
else
    meterValue = (dataValue - 50) / 50 * 50 + 1
End if

Call m.addPointer(meterValue , &H40333399)

if len(request.QueryString("benchvalue"))>0 then
Call m.addPointer(benchvalue, &H40cdcdcd)
end if

Response.ContentType = "image/png"
Response.BinaryWrite m.makeChart2(cd.PNG)
Response.End
%>

Please advice.

Thanks

  Re: splitting guage scale
Posted by Peter Kwan on Jan-12-2011 00:51
Hi CSharpCorner,

There are several errors in your own code. To solve the problem, you may use the code I suggested in my previous email. (You may modify my code of course. To do this, make sure you understand how my original code works. If you modify the code without understand it, your modified version may not work.)

I have changed your code to use the code I suggested in my previous email, and it should now work correctly.

<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")

value = CDBl(request.QueryString("value"))
benchvalue = request.QueryString("benchvalue")
label= request.QueryString("label")

Set m = cd.AngularMeter(150, 150, cd.silverColor(), &H0, -2)
Call m.setMeter(65, 65, 60, -130, 130)
Call m.setScale2(0, 6, Array("0", "50", "60", "70", "80", "90", "100"))
Call m.setLineWidth(0, 2, 1)
Call m.addRing(0, 65, cd.metalColor(&H9999dd))
Call m.addRing(65, 67, &H6666ff)

Call m.addZone(0, 4, &Hff3333)
Call m.addZone(4, 5, &Hffff00)
Call m.addZone(5, 6, &H99ff99)

Call m.addText(75, 125, label, "arialbd.ttf", 10, cd.TextColor, cd.Center)

Call m.addText(75, 105, m.formatValue(value, "1"), "Arial", 8, &Hffffff, _
    cd.Center).setBackground(&H0, &H0, -1)
if len(request.QueryString("benchvalue"))>0 then
Call m.addText(130, 140, m.formatValue(benchvalue, "1"), "Arial", 8, &Hffffff, _
    cd.Center).setBackground(&H0, &H0, -1)
end if

Dim meterValue

if (value <= 50) then
    meterValue = value / 50
else
    meterValue = (value - 50) / 50 * 5 + 1
End if

Call m.addPointer(meterValue , &H40333399)

if len(request.QueryString("benchvalue"))>0 then
    if (benchvalue <= 50) then
        meterValue = benchvalue / 50
    else
        meterValue = (benchvalue - 50) / 50 * 5 + 1
    End if
    Call m.addPointer(meterValue, &H40cdcdcd)
end if

Response.ContentType = "image/png"
Response.BinaryWrite m.makeChart2(cd.PNG)
Response.End
%>

Hope this can help.

Regards
Peter Kwan

  Re: splitting guage scale
Posted by CsharpCorner on Jan-12-2011 05:14

Thank you so much, i got it as it want to be.