2.1.14.1.19 okutil_get_ocolor_by_col


Description

Get the color value to make data plot colors follow the specified column value from the same worksheet

Syntax

BOOL okutil_get_ocolor_by_col( OQCOLOR * poqColor, int nModifiedColIndex, int nMainColIndex, int nColType )

Parameters

poqColor
[output] pointer to receive 64bit OQCOLOR value
nModifiedColIndex
[input] the color reference column index
nMainColIndex
[input] data plot's worksheet Y( Z if 3D plot ) column index
nColType
[input] reference type, COLTYPE_COLOR_INDEX, etc

Return

FALSE if nColType is invalid, otherwise TRUE

Examples

EX1

#include <..\originlab\okThemeID.h>

//Before run this sample code, please import "\\Samples\Graphing\Group.DAT" into active worksheet

//set nColorCol to -1, 0, 1, 2, 3 to see the different color setting
void plot_color_abd_shape_ex(int nColorCol)
{
    Worksheet wks = Project.ActiveLayer();    
    GraphPage gp;
    gp.Create("origin");
    if(!wks || !gp)
        return;
    
    int nXCol = 0, nYCol = 1;
    int nShapeCol = 3;
    
    Curve cc(wks, nXCol, nYCol);
    GraphLayer lay = gp.Layers(0);
    int nPlot = lay.AddPlot(cc, IDM_PLOT_SCATTER);
    lay.Rescale();
    if(nPlot < 0)
        return;
    
    DataPlot dp = lay.DataPlots(nPlot);
    TreeNode tr = dp.GetFormat(FPB_ALL, FOB_ALL, TRUE, TRUE);
    TreeNode trSymbolEdgeColor = tree_get_node_by_nodeid(tr, OTID_CURVE_SYMBOL_EDGE_COLOR, 3);
    if(trSymbolEdgeColor)
    {
        if(nColorCol >= 0)
        {
            OQCOLOR oqColor;
            okutil_get_ocolor_by_col(&oqColor, nColorCol, nYCol, COLTYPE_COLOR_INDEX);
            trSymbolEdgeColor.nVal = oqColor;
        }
        else
        {
            OCOLOR oColor;
            okutil_get_increment_ocolor(&oColor, 1);//increase from the second color in color list
            trSymbolEdgeColor.nVal = oColor;
        }
    }
    
    TreeNode trSymbolShape = tree_get_node_by_nodeid(tr, OTID_CURVE_SYMBOL_SHAPE, 3);
    TreeNode trSymbolConstructiong = tree_get_node_by_nodeid(tr, OTID_CURVE_SYMBOL_CONSTRUCTION_SHOW, 3);
    if(trSymbolShape && trSymbolConstructiong)
    {
        trSymbolConstructiong.nVal = 1;
        int nInternalIndex;
        okutil_get_internal_index_by_col(&nInternalIndex, nShapeCol, nYCol);
        trSymbolShape.nVal = nInternalIndex;
    }        
    
    dp.ApplyFormat(tr, true, true);
    dp.CheckMakeDependenciesCategorical();
}

Remark

See Also

okutil_get_col_by_ocolor, okutil_get_increment_ocolor

Header to Included

origin.h

Reference