Chart.js不使用setState作为数据支持传递的状态进行渲染

时间:2019-01-16 03:37:05

标签: reactjs setstate chart.js2

我正在使用React-chart2.js输出Dought图表

当我将所有内容连接起来时,我的应用将使用针对每种收入/支出类型计算的百分比,然后进行渲染。

现在,我正在尝试在正确的代码块中设置setState更改,但是未呈现我的甜甜圈图。我有一个console.log设置,以查看this.state.chartData ....是否正在更新。

任何想法我在做什么错了:

控制状态的父组件:

vector<wstring> StartArgs;
map<wstring, wstring> argsMaps;
void GetArgMap() {
    for (int i = 1; i < StartArgs.size(); ++i) {
        wstring argStr = StartArgs[i];
        vector<wstring> argVec;
        split(argStr, L':', argVec);
        if (argVec.size() >= 2) {
            wstring k = argVec[0];
            wstring v = argVec[1];
            argsMaps.insert(map<wstring, wstring>::value_type(k,v));
        }
    }
}

wstring GetArgForKey(wstring key) {

    wstring ret = argsMaps[key];
    if (lstrcmpW(ret.c_str(), L"")) {
        return ret;
    }
    else {
        return L"null";
    }
}

bool CheckParamAvialble(wstring param) {
    if (lstrcmpW(param.c_str(), L"null")) {
        return true;
    }
    else {
        return false;
    }
}

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine,
    int nCmdShow)
{   

    ShowMessageBox(L"this is test alert!", L"WARNING");
    int argCount = 0;
    LPWSTR cmdline = GetCommandLine();
    //cmdline is  [m:1 h:0 a:500000 n:xxx c:xxx u:usera o:TOKEN]
    LPWSTR* szArgList = CommandLineToArgvW(cmdline, &argCount);
    for (int i = 0; i < argCount; ++i) {
        wstring a = szArgList[i];
        StartArgs.push_back(a);
    }

    if (argCount >= 7) {
        wstring mString = GetArgForKey(L"m");
        if (!CheckParamAvialble(mString))
        {
            ShowMessageBox(L"arg m is wrong!", L"Error");
            return 0;
        }
        /*
            do something with other args
        */
            CPaintManagerUI::SetInstance(hInstance);
            InitResource();
            HRESULT Hr = ::CoInitialize(NULL);
            if (FAILED(Hr)) return 0;
            CefMainArgs args(hInstance);
            CefRefPtr<SimpleApp> app(new SimpleApp);
            int exitCode = CefExecuteProcess(args, app, NULL);
            if (exitCode >= 0)
            {
                return exitCode;
            }
            CefSettings settings;
            CefInitialize(args, settings, app.get(), NULL);
            CefRefPtr<CefCommandLine> command_line;
            command_line = CefCommandLine::CreateCommandLine();
            command_line->AppendSwitch("no-proxy-server");
            MainForm *pFrame = new MainForm(_T("Forms\\MA_MainForm.xml"));
            if (pFrame == NULL) return 0;
            pFrame->Create(NULL, _T("MainForm"), UI_WNDSTYLE_FRAME, WS_EX_STATICEDGE | WS_EX_APPWINDOW, 0, 0, 600, 800);//when progrom go here,i got 2nd MessageBox[this is test alert!]
            pFrame->CenterWindow();
            CefRunMessageLoop();
            CefShutdown();
            return 0;
    }
    else 
    {
        ShowMessageBox(L"something wrong and exit", L"Error");
        return 0;
    }
}

0 个答案:

没有答案