Month: November 2015

  • Updating sparklines in OriginC

    Ever wondered how to tell OriginLab to update the sparklines after a custom import-filter (or whatever data-manipulating script) has been called?

    Well, you can call the “sparklines” X-Function. The documentation is, as usual for OriginC, not the best and calling X-Functions with the wrong parameter will simply crash OriginLab, but it’s worth it…

    Code:

    bool call_UpdateSparklines_XF(Worksheet &wks)
    {
        // Create an instance of XFBase using the X-Function name.
        XFBase xf("sparklines");
        if (!xf)
            return false;
     
        // Set the 'iw' argument. A worksheet for XFBase is referenced using a Pointer (not the name...)
        if (!xf.SetArg("iw", wks))
            return false;
     
        // Set the 'sel' argument.
        if (!xf.SetArg("sel", 0))
            return false;
     
        // Set the 'c1' argument, the first row to update. Counter starts at 1.
        if (!xf.SetArg("c1", 1))
            return false;
     
        // Set the 'sel' argument.
        if (!xf.SetArg("c2", wks.GetNumCols()))
            return false;
     
        // Call XFBase's 'Evaluate' method to execute the X-Function
        if (!xf.Evaluate())
            return false;
     
        return true;
    }

    You might also find this Forum-Entry useful, where some different possibilities are given: OriginC-Forum / Sparklines