I would like to ask some help on displaying my datasource’s clientname at the bottom of my stacked bar chart. It seems from all the examples that I researched, the bottom chart axis label is set "automatically" by TeeChart looking at the datasource. However I cant seem to get it to work. Below is a picture of what I am trying to achieve.
Picture of what I am trying to achieve
I have three series' which I use to build the stacked chart. I have included a picture of each datasource I use for each query.
Datasources for three series' queries
From my research it seems I can also use the DBChart1GetAxisLabel()
to custom set the labels. But I am struggling to understand how to ensure that the correct custom label name is associated with the correct "clientname" from my queries.
Here is a code sample of how I build the charts:
procedure TfrmSupplierAnalytics.btnOKClick(Sender: TObject); var S,NewTypeStr, test, clientSql : string; var seriasNormalOrders:TBarSeries; var seriasCreditNoteOrders:TBarSeries; var seriasPartialOrders:TBarSeries; N, i : integer; begin qCreditNoteOrders.Close; qNormalOrders.Close; qPartialOrders.Close; qGetClientIdFromName.Close; qClients.Close; DBChart1.CleanupInstance; DBChart1.ClearChart; try for N := 0 to clbClients.Items.Count-1 do if clbClients.State[N] = cbChecked then begin test := string(clbClients.Items[N]); NewTypeStr := NewTypeStr + '(E.clientid = '+ IntToStr(FindClientID(test)) + ')'; clientSql := clientSql + NewTypeStr; NewTypeStr := ' or '; end; except on E : Exception do ShowMessage(E.ClassName+' error raised, with message : '+E.Message); end; OpenQueryCreditNoteOrders(clientSql); OpenQueryPartialOrders(clientSql); OpenQueryNormalOrders(clientSql); seriasNormalOrders :=TBarSeries.Create(self); DBChart1.AddSeries(seriasNormalOrders); seriasCreditNoteOrders :=TBarSeries.Create(self); DBChart1.AddSeries(seriasCreditNoteOrders); seriasPartialOrders :=TBarSeries.Create(self); DBChart1.AddSeries(seriasPartialOrders); seriasNormalOrders.MultiBar := mbStacked; seriasCreditNoteOrders.MultiBar := mbStacked; seriasPartialOrders.MultiBar := mbStacked; seriasNormalOrders.Marks.Visible := true; seriasNormalOrders.MarksLocation:= mlCenter; seriasNormalOrders.MarksOnBar := True; seriasNormalOrders.YValues.ValueSource := 'NormalOrders'; seriasNormalOrders.DataSource := qNormalOrders; seriasNormalOrders.Title := 'Correct Orders'; seriasNormalOrders.Marks.Visible := True; seriasNormalOrders.Marks.AutoPosition := true; seriasCreditNoteOrders.YValues.ValueSource := 'CreditNoteOrders'; seriasCreditNoteOrders.DataSource := qCreditNoteOrders; seriasCreditNoteOrders.Title := 'Credit Note Orders'; seriasPartialOrders.YValues.ValueSource := 'PartialOrders'; seriasPartialOrders.DataSource := qPartialOrders; seriasPartialOrders.Title := 'Short Orders'; seriasNormalOrders.CheckDataSource; seriasCreditNoteOrders.CheckDataSource; seriasPartialOrders.CheckDataSource; end;
So, just to sum up, is there some setting in my code which I am missing that would show the "clientname" below each stacked bar, or must I use custom labels?
If I must use custom labels, I would appreciate some direction on how to ensure that I replace the correct "clientname" from the datasource to the correct ValueIndex
in the DBChart1GetAxisLabel
?
Thanks in advance.