Woutero Posted February 17 Share Posted February 17 Sir I'm using UniGUI Complete Professional V1.90.0.1560 in RAD C++ Builder 10.4 Update 2. I'm getting an Ajax error when trying to assign a new title to a stream of a UniChart. I have the following procedure: void __fastcall TMainForm::SetNewTitle(TUniChart *ThisChart, int StreamNo) { UnicodeString NewTitle; NewTitle = "New Title"; if (StreamNo==0) ThisChart->JSInterface->JSCall((UnicodeString)L"chart.series[0].setTitle",ARRAYOFCONST((NewTitle))); if (StreamNo==1) ThisChart->JSInterface->JSCall((UnicodeString)L"chart.series[1].setTitle",ARRAYOFCONST((NewTitle))); if (StreamNo==2) ThisChart->JSInterface->JSCall((UnicodeString)L"chart.series[2].setTitle",ARRAYOFCONST((NewTitle))); } As long as the UniChart has 3 UniLineSeries, everything works fine when I call SetNewTitle(UniChart,0); SetNewTitle(UniChart,1); SetNewTitle(UniChart,2); But as soon as I use 3 UniBarSeries, UniAreaSeries or any other series on the UniChart, then calling SetNewTitle for all 3 series gives an Ajax error: "Cannot read properties of undefined (reading 'SetTitle')" The easiest fix would be to allow us to set the Title property for each Series in the SeriesList: UniChart->SeriesList->Series[0]->Title = "New Title"; UniChart->SeriesList->Series[1]->Title = "New Title"; UniChart->SeriesList->Series[2]->Title = "New Title"; Then we don't even have to use the JSCall which is not working for UniBarSeries, UniAreaSeries and other series in C++Builder. By the way, I have to tell you that the uniGUI framework is most amazing. I only have the greatest respect for your work, you are a genius!! If only we could fix this bug then I will be a vey happy customer… 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 17 Share Posted February 17 Hello, We will check. Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 17 Author Share Posted February 17 Much appreciated, thanks! Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 19 Author Share Posted February 19 Sherzod I also tried "chart.getSeries()[0].setTitle"... which gave the error: Cannot read properties of undefined (reading 'setTitle') and "chart.series.getAt(0).setTitle"... gave the error: chart.series.getAt is not a function Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 19 Share Posted February 19 Hello @Woutero Can you test this in Delphi? Do you have the opportunity? Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 19 Author Share Posted February 19 Sherzod I tested in Delphi 10.4.2 ThisChart.JSInterface.JSCall('chart.series[0].setTitle',[NewTitle]); gives runtime error: Cannot read properties of undefined (reading 'setTitle') ThisChart.JSInterface.JSCall('chart.getSeries()[0].setTitle',[NewTitle]); gives same error. ThisChart.JSInterface.JSCall('chart.series.getAt(0).setTitle',[NewTitle]); gives runtime error: chart.series.getAt is not a function Delphi also does not allow UniChart1.SeriesList.Series[0].Title := 'New Title'; giving compiling error: Cannot access protected symbol TUniChartSeries Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 19 Share Posted February 19 Ok I will try to check. Once again, what Series do you use? Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 19 Author Share Posted February 19 I inserted 3 x UniBarSeries on a UniChart. So its UniBarSeries1, UniBarSeries2, UniBarSeries3 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 19 Share Posted February 19 3 minutes ago, Woutero said: So its UniBarSeries1, UniBarSeries2, UniBarSeries3 Thanks. Ok I will check and let you know. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 19 Share Posted February 19 @Woutero Please try this approach for now: Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 19 Author Share Posted February 19 Sherzod Yes, the SetTitle() procedure works in Delphi, but I cannot get the SetTitle procedure to work in C++. This is the code that I have used: #pragma link "uniStrUtils" void __fastcall TMainForm::SetTitle(TUniBarSeries *AUniBarSeries, UnicodeString ATitle) { int I; UnicodeString Titles; Titles = ""; if ((ATitle!="") && (AUniBarSeries->Title!=ATitle)) { AUniBarSeries->Title = ATitle; for (I=0; I<AUniBarSeries->Parent->SeriesList->Count; I++) Titles = Titles + """ + ((TUniBarSeries)AUniBarSeries->Parent->SeriesList[I])->Title + "","; Titles = RemoveTrailingChar(Titles, ','); AUniBarSeries->Parent->JSInterface->JSCall("chart.series[0].setTitle",ARRAYOFCONST((Titles))); } } By the way, I have added the line Titles = "" because Titles was never initialized before the loop. I tried both String and UnicodeString. How should we change SetTitle() to work in C++? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 19 Share Posted February 19 Can you try this code?: void __fastcall TMainForm::SetTitle(TUniBarSeries *AUniSeries, UnicodeString ATitle) { int I; UnicodeString Titles = ""; if (ATitle != "" && AUniSeries->Title != ATitle) { AUniSeries->Title = ATitle; for (I = 0; I < AUniSeries->Parent->SeriesList->Count; ++I) { TUniBarSeries *Series = dynamic_cast<TUniBarSeries *>(AUniSeries->Parent->SeriesList->Items[I]); if (Series) Titles = Titles + "\"" + Series->Title + "\","; } Titles = RemoveTrailingChar(Titles, ','); TJSArray *JSArrayResult = AUniSeries->Parent->JSInterface->JSArray(Titles); AUniSeries->Parent->JSInterface->JSCall("chart.series[0].setTitle", JSArrayResult); } } Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 19 Author Share Posted February 19 Sherzod Thanks! Which units should I include to compile? C++ Builder 10.4 (target Windows 64bit) throws error at dynamic_cast: 'void' is not a class Also does not recognize TJSArray when I include "System.JSON.hpp" Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 20 Share Posted February 20 11 hours ago, Woutero said: Which units should I include to compile? C++ Builder 10.4 (target Windows 64bit) throws error at dynamic_cast: 'void' is not a class Also does not recognize TJSArray when I include "System.JSON.hpp" Hello, Sorry, I'm not good at C++Builder. I asked a question to chatGPT 🙂 and I don't have a way to test the code at the moment. Try also this code: void __fastcall TMainForm::SetTitle(TUniBarSeries *AUniSeries, UnicodeString ATitle) { int I; UnicodeString Titles = ""; if (ATitle != "" && AUniSeries->Title != ATitle) { AUniSeries->Title = ATitle; for (I = 0; I < AUniSeries->Parent->SeriesList->Count; ++I) { TUniBarSeries *Series = AUniSeries->Parent->SeriesList->Items[I]; TUniBarSeries *BarSeries = (TUniBarSeries*)Series; // Explicit casting, Make sure all types are the same... Titles = Titles + "\"" + BarSeries->Title + "\","; } Titles = RemoveTrailingChar(Titles, ','); AUniSeries->Parent->JSInterface->JSCall("chart.series[0].setTitle", AUniSeries->Parent->JSInterface->JSArray(Titles)); } } Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 20 Author Share Posted February 20 Sorry, still not compiling. TUniBarSeries *Series = AUniSeries->Parent->SeriesList->Items[I]; throws error: cannot initialize a variable of type 'Unichart::TUniBarSeries *' with an rvalue of type 'void *' AUniSeries->Parent->JSInterface->JSCall("chart.series[0].setTitle", AUniSeries->Parent->JSInterface->JSArray(Titles)); throws error: no matching member function for call to 'JSCall' Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 20 Author Share Posted February 20 Anyone else with suggestions? We need to translate the following line of Delphi code to C++: for I := 0 to AUniBarSeries.Parent.SeriesList.Count-1 do Titles := Titles + '"' + (AUniBarSeries.Parent.SeriesList[I] as TUniBarSeries).Title + '",'; Currently we have for (I = 0; I < AUniSeries->Parent->SeriesList->Count; ++I) { TUniBarSeries *Series = AUniSeries->Parent->SeriesList->Items[I]; TUniBarSeries *BarSeries = (TUniBarSeries*)Series; // Explicit casting, Make sure all types are the same... Titles = Titles + "\"" + BarSeries->Title + "\","; } which throws na error: cannot initialize a variable of type 'Unichart::TUniBarSeries *' with an rvalue of type 'void *' Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 20 Share Posted February 20 8 minutes ago, Woutero said: Sorry, still not compiling. Ok, We can use a different approach by creating a client-side JS function. Can you get a string like "Title1", "Title2" from the Series list? Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 20 Author Share Posted February 20 Sherzod, I don't understand your question? Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 20 Author Share Posted February 20 Did you mean: Title1 = UniChart->SeriesList->Series[0]->Title; Title2 = UniChart->SeriesList->Series[1]->Title; Title3 = UniChart->SeriesList->Series[2]->Title; This is not allowed, gives error: 'Title' is a protected member of 'UniChart::TUniChartSeries' Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 20 Author Share Posted February 20 Though the following is allowed: Title1 = UniBarSeries1->Title; Title2 = UniBarSeries2->Title; Title3 = UniBarSeries3->Title; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 20 Share Posted February 20 I'm looking for another solution... Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 20 Share Posted February 20 This is not a solution, but can you use parameter passing like this for now? UniChart1.JSInterface.JSCall('there will be some client side function', [Title1, Title2, Title3]); Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 20 Author Share Posted February 20 Sherzod I believe it should work. The following C++ code works perfectly for UniLineSeries, but does not work for UniBarSeries, UniAreaSeries and other series: UnicodeString NewTitle; NewTitle = "New Title"; if (StreamNo==0) ThisChart->JSInterface->JSCall((UnicodeString)L"chart.series[0].setTitle",ARRAYOFCONST((NewTitle))); if (StreamNo==1) ThisChart->JSInterface->JSCall((UnicodeString)L"chart.series[1].setTitle",ARRAYOFCONST((NewTitle))); if (StreamNo==2) ThisChart->JSInterface->JSCall((UnicodeString)L"chart.series[2].setTitle",ARRAYOFCONST((NewTitle))); When the same code is run on UniBarSeries and UniAreaSeries then it generates an Ajax error: Cannot read properties of undefined (reading 'setTitle') Why can't UniGUI simply allow: UniChart->SeriesList->Series[0]->Title = "New Title"; UniChart->SeriesList->Series[1]->Title = "New Title"; UniChart->SeriesList->Series[2]->Title = "New Title"; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 20 Share Posted February 20 33 minutes ago, Woutero said: When the same code is run on UniBarSeries Because for them there is only one series... 35 minutes ago, Woutero said: Why can't UniGUI simply allow: UniChart->SeriesList->Series[0]->Title = "New Title"; UniChart->SeriesList->Series[1]->Title = "New Title"; UniChart->SeriesList->Series[2]->Title = "New Title"; We will try to add this in future versions. Quote Link to comment Share on other sites More sharing options...
Woutero Posted February 20 Author Share Posted February 20 31 minutes ago, Sherzod said: Because for them there is only one series... We will try to add this in future versions. On my side I was using 3 x UniLineSeries and 3 x UniBarSeries, so its strange that it worked with UniLineSeries. Thanks for trying to add support for UniChart->SeriesList->Series[0]->Title = "New Title"; Much appreciated! It's a pity though that we can't get SetTitle() to work for C++ as an interim solution. Not being able to change the title for a series is a showstopper for me right now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.