Get the color value to make data plot colors(Color Mapping, Indexing, Direct RGB) follow the specified column value from the same worksheet
BOOL okutil_get_ocolor_by_col( OQCOLOR * poqColor, int nModifiedColIndex, int nMainColIndex, int nColType )
FALSE if nColType is invalid, otherwise TRUE
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(); }
origin.h