Jump to content

TUniChart add null value


JohnySK

Recommended Posts

Hello,

Just a question it is possible to achieve that I can send null values to Unichart?

To achieve that records will be empty like picture bellow? Some parameter which will allow to do this?

afChartReview.uChart.SeriesList.Series[i].Add(null,'');   For sure with this I got exception that it can not be converted to double.

Thank you for help.

image.png.d6f31a1abb0ced262602143e159200c9.png

 

With regards,

Jan R.

Link to comment
Share on other sites

3 hours ago, JohnySK said:

Just a question it is possible to achieve that I can send null values to Unichart?

To achieve that records will be empty like picture bellow? Some parameter which will allow to do this?

Hello,

Need to analyze.

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...
23 hours ago, VojkoCendak said:

We saw at Ext 7 Sencha fiddle, that if you add null instead of number, chart skips drawing point.

just change value let's say 17 -> null ! voila

Would that be hard to implement ?

Regards,

Vojko

 

Hello For now please use below workaround.

UniChart.pas  Line 1819

 

          1 :
            begin
              if VarIsNull(ValuesList[1].Value[I]) then
                Result[I] := 'null'
              else
              begin
                fVal := ValuesList[1].Value[I];
                Val := fVal2Float(fVal);
                Result[I] := Val;
              end;
            end;

 

and you can add null values like below

Series1.Add(null, '2000')

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Better whole function also for TDataSource:

 

function TUniCustomChart.ChartDataToStr(AChartSeries: TUniChartSeries; ADim: Integer): TUniStringArray;
var
  I, xCount : Integer;
  Ds : TDataSet;
  S, Val : string;
  fVal : Double;
begin
  // ADim
  // 0 = Text Data,
  // 1 = Numeric Data

  with AChartSeries do
  begin
    if Assigned(FDataSource) then
    begin
      if Assigned(FDataSource.DataSet) and FDataSource.DataSet.Active then
      begin
        Ds := FDataSource.DataSet;
        xCount := Ds.RecordCount;
        if FYValues.FValueSource <> '' then
        begin
          DS.DisableControls;
          try
            Ds.First;

            SetLength(Result, xCount);
            for I := 0 to xCount - 1 do
            begin
              case ADim of
                0 :
                  begin
                    if FXLabelsSource <> '' then
                    begin
                      if Ds.FieldByName(FXLabelsSource) is TNumericField then
                        Result[I] := fVal2Float(Ds.FieldByName(FXLabelsSource).AsFloat)
                      else
                        Result[I] := StrToJS(Ds.FieldByName(FXLabelsSource).AsString)
                    end
                    else
                      Result[I] := StrToJS(IntToStr(I));
                  end;

                1 :
                  begin
                    if Ds.FieldByName(FYValues.FValueSource).IsNull then  // new null ***
                      Result[I] := 'null'
                    else
                    begin
                      fVal := Ds.FieldByName(FYValues.FValueSource).AsFloat;
                      Val := fVal2Float(fVal);
                      Result[I] := Val;
                    end;

                  end;
              end;
              Ds.Next;
            end;
          finally
            Ds.EnableControls;
          end;
        end;
      end
    end
    else
    begin
      SetLength(Result, ValuesList[0].Count);
      for I := 0 to ValuesList[0].Count - 1 do
      begin
        case ADim of
          0 :
            begin
              S := XLabel[I];
              if (S = '') or (S = '""') then // in case no label is provided
                S := StrToJS(IntToStr(Trunc(ValuesList[0].Value[I])));
              Result[I] := S;

            end;

          1 :
            begin
              if VarIsNull(ValuesList[1].Value[I]) then  // new null ***
                Result[I] := 'null'
              else

              begin
                fVal := ValuesList[1].Value[I];
                Val := fVal2Float(fVal);
                Result[I] := Val;
              end;
          end;

        end;
      end;
    end;
  end;
end;

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...