Subscribe Bookmark RSS Feed

Validate Graph output is not blank before saving

senatorx

Community Trekker

Joined:

Jun 12, 2012

Hey,

I am creating graphs with multiple "Where" conditions that can result in no output, depending on the contents of the data file.

Where(:Column 1 == "string1" & :Column 2 == "string2" & :Column 3 == "string3")

If I then try to save a graph that is blank, the script crashes:

GraphName <<  /*###*/save picture( SaveString, png ) /*###*/;

How can I validate that the Graph contains data prior to attempting to save it?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

I would use something like:

dt << clear row states;

selected_rows = dt << get rows where(:Column 1 == "string1" &

                                     :Column 2 == "string2" &

                                     :Column 3 == "string3");

if (nrows(selected_rows) > 0,

    dt << select rows(selected_rows) << invert row selection

       << exclude << clear select;

   

    .

    .

//    Create your graph here

    .

    .

);

3 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Do you mean that the graph does not exist or that you have a graph but no data points (i.e. only missing values)?

Anyway, I would use a conditional statement that that is proactive, i.e. all "where" conditions that has too few data are ignored and never graphed. That's seems simpler and more efficient than to identify blank graphs in retrospect.

senatorx

Community Trekker

Joined:

Jun 12, 2012

I am doing this:

New Window("chart name",

CC = Control Chart(

  Chart Options...

      );

);

So a new window gets created but some windows have no charts because there are no matching data points for all the where conditions.

Yeah, I think validating the data up-front before graphing is the way to go.

Thanks.

Solution

I would use something like:

dt << clear row states;

selected_rows = dt << get rows where(:Column 1 == "string1" &

                                     :Column 2 == "string2" &

                                     :Column 3 == "string3");

if (nrows(selected_rows) > 0,

    dt << select rows(selected_rows) << invert row selection

       << exclude << clear select;

   

    .

    .

//    Create your graph here

    .

    .

);