Source language: Translate to:

[SOLVED] npPlot inquiry

Questions about NeoBook PlugIns

Moderator: Neosoft Support

[SOLVED] npPlot inquiry

Postby stu » Thu Jan 15, 2015 10:22 am

I'm trying to see if i can generate a graphic with the help of npPlot but I'm getting a weird result, maybe in my code and I can't see it...

Syntax: [ Download ] [ Hide ]
Using Neobook Syntax Highlighting
npPlotCreate "Graph" "[Result]"

npPlotTitleOptions "Graph" "Calls per year" "Tahoma|11|0,0,0" "[Result]"

npPlotAddSeries "Graph" "Calls" "skBar" "[Result]"

npPlotAxisXOptions "Graph" "Year" "1" "[Result]"
npPlotAxisYOptions "Graph" "Calls" "1" "[Result]"

npPlotBeginUpdate "Graph" "[Result]"

Setvar "[YearVar]" "[Year]"
StrDel "[YearVar]" "1" "2" "[YearShort]"
Setvar "[YearCount]" "0"

While "[YearCount]" "<=" "[YearShort]"

      if "[YearCount]" "<" "10"
         Setvar "[AddedZero]" "0"
      else
          Setvar "[AddedZero]" ""
      endif

      dbpQuery "FIRE" "tblIncidents" "IncidentDateTime BETWEEN #20[AddedZero][YearCount]-01-01# AND #20[AddedZero][YearCount]-12-31#"
      setvar "[Year20[AddedZero][YearCount]]" "[FIRE.tblIncidents.$RecCount]"

      npPlotAddXY "Graph" "Calls" "20[AddedZero][YearCount]" "[Year20[AddedZero][YearCount]]" "[Result]"

      Math "[YearCount]+1" "0" "[YearCount]"
     
endwhile

npPlotEndUpdate "Graph" "[Result]"

CustomWindow "Call's per year" "-1" "-1" "Graph" "ToolWindow"
Parsed in 0.009 seconds, using GeSHi 1.0.8.10


This code it's actually doing pretty much all what it's supposed to... except that the result its as follows:

Image

Any clues =)

EDIT: I realized I can put all in a single While...
Last edited by stu on Fri Jan 16, 2015 4:26 am, edited 2 times in total.
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: npPlot inquiry

Postby dec » Thu Jan 15, 2015 12:49 pm

Hello,

I think you mean the years appear in some extrange order: "2009", "20010", "20012", etc. If this correct? Really I never hear about a problem like that, then, I want to question, are you sure the numbers in which the chart are based are not "20010", "20012", etc? Since you get the data from a database, I can't test it without such database,... can you try to test (in order to replicate the problem) using some "fake" data that I can also try here?

Anyway sorry for the possible inconveniences stu.
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: npPlot inquiry

Postby dpayer » Thu Jan 15, 2015 1:31 pm

Yes, it is a bit odd that you go from 2009 to 20010. That is a 18,001 year gap. Maybe the app can't comprehend it! :shock:
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: npPlot inquiry

Postby dec » Thu Jan 15, 2015 1:36 pm

Hello,

dpayer wrote:Yes, it is a bit odd that you go from 2009 to 20010. That is a 18,001 year gap. Maybe the app can't comprehend it! :shock:


My idea (maybe wrong) is the data come "like that" from the database or something like that. In few words, the chart receive that value and then print out accordingly. Below we can see a sample publication, which do not take the data from any database, and, as we can see, the year gap do not happend:

Image
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: npPlot inquiry

Postby stu » Thu Jan 15, 2015 3:54 pm

Thanks for the replies!

I Guess I'll carry on tomorrow, but I got an update... I Changed the part of the code that adds or not a zero depending if the number is less than 10 and then it generates the years ok, but then the data keeps not making sense. So IMO its purely a code related issue.

As said, I'll keep trying tomorrow and let you know.
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: npPlot inquiry

Postby Gaev » Thu Jan 15, 2015 5:03 pm

stu:

Try this cide ...
Code: Select all
dbpQuery "FIRE" "tblIncidents" "IncidentDateTime BETWEEN #20[AddedZero][YearCount]-01-01# AND #20[AddedZero][YearCount]-12-31#"
setvar "[thisYearIncedents]" "[FIRE.tblIncidents.$RecCount]"

AlertBox "20[AddedZero][YearCount]" "[thisYearIncidents]"
npPlotAddXY "Graph" "Calls" "20[AddedZero][YearCount]" "[thisYearIncidents]" "[Result]"

That will confirm if the expected values are being passed to npPlotAddXY.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: npPlot inquiry

Postby stu » Fri Jan 16, 2015 4:17 am

Gaev wrote:stu:

Try this cide ...
Code: Select all
dbpQuery "FIRE" "tblIncidents" "IncidentDateTime BETWEEN #20[AddedZero][YearCount]-01-01# AND #20[AddedZero][YearCount]-12-31#"
setvar "[thisYearIncedents]" "[FIRE.tblIncidents.$RecCount]"

AlertBox "20[AddedZero][YearCount]" "[thisYearIncidents]"
npPlotAddXY "Graph" "Calls" "20[AddedZero][YearCount]" "[thisYearIncidents]" "[Result]"

That will confirm if the expected values are being passed to npPlotAddXY.


Oh yeah, i did test with alertboxes to check if the values being passed were ok, they were.

But take a look at this code, this works, makes all the requested years (2000 - 2015) display ok...

Syntax: [ Download ] [ Hide ]
Using Neobook Syntax Highlighting
npPlotCreate "Graph" "[Result]"

npPlotTitleOptions "Graph" "Calls per year" "Tahoma|11|0,0,0" "[Result]"

npPlotAddSeries "Graph" "Calls" "skBar" "[Result]"

npPlotAxisXOptions "Graph" "Year" "1" "[Result]"
npPlotAxisYOptions "Graph" "Calls" "1" "[Result]"

npPlotBeginUpdate "Graph" "[Result]"

Setvar "[YearVar]" "[Year]"
StrDel "[YearVar]" "1" "2" "[YearShort]"
Setvar "[YearCount]" "0"

While "[YearCount]" "<=" "[YearShort]"

      if "[YearCount]" "<" "10"
         Setvar "[AddedZero]" "00"
      else
          Setvar "[AddedZero]" ""
      endif

      dbpQuery "FIRE" "tblIncidents" "IncidentDateTime BETWEEN #2[AddedZero][YearCount]-01-01# AND #2[AddedZero][YearCount]-12-31#"
      setvar "[Year2[AddedZero][YearCount]]" "[FIRE.tblIncidents.$RecCount]"

      npPlotAddXY "Graph" "Calls" "2[AddedZero][YearCount]" "[Year2[AddedZero][YearCount]]" "[Result]"

      Math "[YearCount]+1" "0" "[YearCount]"

endwhile

npPlotEndUpdate "Graph" "[Result]"

CustomWindow "Call's per year" "-1" "-1" "Graph" "ToolWindow"
Parsed in 0.008 seconds, using GeSHi 1.0.8.10


(Pay no attention to the emergency line, that's part of another test)

Image

Now years show ok, but the data per year doesn't (?)

Funny thing

------------------ EDIT ------------------

Image

I got it! ok, so final code:

Syntax: [ Download ] [ Hide ]
Using Neobook Syntax Highlighting
npPlotCreate "Graph" "[Result]"

npPlotTitleOptions "Graph" "Calls per year" "Tahoma|11|0,0,0" "[Result]"

npPlotAddSeries "Graph" "Calls" "skBar" "[Result]"

npPlotAxisXOptions "Graph" "Year" "1" "[Result]"
npPlotAxisYOptions "Graph" "Calls" "1" "[Result]"

npPlotBeginUpdate "Graph" "[Result]"

Setvar "[YearVar]" "[Year]"
StrDel "[YearVar]" "1" "2" "[YearShort]"
Setvar "[YearCount]" "0"

While "[YearCount]" "<=" "[YearShort]"

      if "[YearCount]" "<" "10"
         Setvar "[AddedZero]" "00"
      else
          Setvar "[AddedZero]" "0"
      endif

      dbpQuery "FIRE" "tblIncidents" "IncidentDateTime BETWEEN #2[AddedZero][YearCount]-01-01# AND #2[AddedZero][YearCount]-12-31#"
      setvar "[Year2[AddedZero][YearCount]]" "[FIRE.tblIncidents.$RecCount]"

      npPlotAddXY "Graph" "Calls" "2[AddedZero][YearCount]" "[Year2[AddedZero][YearCount]]" "[Result]"

      Math "[YearCount]+1" "0" "[YearCount]"

endwhile

npPlotEndUpdate "Graph" "[Result]"

CustomWindow "Call's per year" "-1" "-1" "Graph" "ToolWindow"
Parsed in 0.008 seconds, using GeSHi 1.0.8.10


On line 19 double zero and on line 21 added a single zero.

I keep trying to add more data to the graph and see if I can get the result Im looking for. =)

Thanks for your replies!
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: [SOLVED] npPlot inquiry

Postby Gaev » Fri Jan 16, 2015 6:34 am

stu:

I think that ... although NeoBook does a great job with nested variable syntax (like [Year2[AddedZero][YearCount]]) ... it might be getting messed up when passed to the plugin.

Since both, the database and the plugin use year values 2000, 2001 ... 2014, 2015 ... why not just do this ...
Code: Select all
Setvar "[YearVar]" "[Year]"   ... <<-- 2015
Setvar "[thisYear]" "2000"

While "[thisYear]" "<=" "[Year]"

      dbpQuery "FIRE" "tblIncidents" "IncidentDateTime BETWEEN #[thisYear]-01-01# AND #[thisYear]-12-31#"
      setvar "[thisYearIncidents]" "[FIRE.tblIncidents.$RecCount]"

      npPlotAddXY "Graph" "Calls" "[thisYear]" "[thisYearIncidents]" "[Result]"

      Math "[thisYear]+1" "0" "[thisYear]"

endwhile


In other words, K.I.S.S (keep it simple, stu) :wink:

Added bonus ... easily converts to get data for years 19xx as well.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: [SOLVED] npPlot inquiry

Postby stu » Wed Jan 21, 2015 5:23 am

Gaev wrote:stu:

I think that ... although NeoBook does a great job with nested variable syntax (like [Year2[AddedZero][YearCount]]) ... it might be getting messed up when passed to the plugin.

Since both, the database and the plugin use year values 2000, 2001 ... 2014, 2015 ... why not just do this ...
Code: Select all
Setvar "[YearVar]" "[Year]"   ... <<-- 2015
Setvar "[thisYear]" "2000"

While "[thisYear]" "<=" "[Year]"

      dbpQuery "FIRE" "tblIncidents" "IncidentDateTime BETWEEN #[thisYear]-01-01# AND #[thisYear]-12-31#"
      setvar "[thisYearIncidents]" "[FIRE.tblIncidents.$RecCount]"

      npPlotAddXY "Graph" "Calls" "[thisYear]" "[thisYearIncidents]" "[Result]"

      Math "[thisYear]+1" "0" "[thisYear]"

endwhile


In other words, K.I.S.S (keep it simple, stu) :wink:

Added bonus ... easily converts to get data for years 19xx as well.


Sorry dude, I missed this post, thanks for this already proved it and works perfect :D
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am


Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 1 guest