Pie-chart not working - grafana 7.0.3 plugin 1.5.0

Hello All,

I can not get the pie-chart plugin working. Strange is, I have no context menu in the frame too. It will display the “Panel Title” but now context menu. I have tried different version of grafana but same result.
How can I debug the pie-chart ? Anybody an idea what went wrong ?

Thanks

Frank

1 Like

I’m not sure what datasource you are using, but i’m using a custom datasource and the simplest data that I can return from query function for pie chart plugin to consumes is

async query(options: DataQueryRequest<MyQuery>): Promise<DataQueryResponse> {
   const { range } = options;
   const from = range!.from.valueOf();
   const to = range!.to.valueOf();
   const mid = (from + to)/2;
   return {data: [ 
      {
        target: 'val1',
        datapoints: [
          [2, from],
          [4, to]
        ]
      },
      {
        target: 'val2',
        datapoints: [
          [3, mid],
          [5, to]
        ]
       } 
   ]};
}

Note: Pie Chart plugin consumes TimeSeries data. TimeSeries is defined inside data.d.ts as

export declare type TimeSeriesValue = number | null;
export declare type TimeSeriesPoints = TimeSeriesValue[][];    
export interface TimeSeries extends QueryResultBase {
    target: string;
    title?: string;
    datapoints: TimeSeriesPoints;
    unit?: string;
    tags?: Labels;
}

I think this is a better data format for Pie Chart plugin to consume

async query(options: DataQueryRequest<MyQuery>): Promise<DataQueryResponse> {
    const { range } = options;
    const from = range!.from.valueOf();
    const to = range!.to.valueOf();
    const mid = (from + to)/2;
    const data = [
      {
        fields: [
          {name: 'time', type: FieldType.time, values: [from, to]},
          {name: 'val1', type: FieldType.number, values: [2, 4]}
        ]
      },
      {
        fields: [
          {name: 'time', type: FieldType.time, values: [mid, to]},
          {name: 'val2', type: FieldType.number, values: [3, 5]}
        ]
      }
    ];
    return {data};
}

This is helpful link for time series Data Frames