简体   繁体   English

cube.js playground 没有正确绘制数据

[英]cube.js playground not plotting data correctly

I am using cube.js to compare the change in data over the time by plotting it as a line graph .我正在使用 cube.js 通过将数据绘制为折线图来比较数据随时间的变化。

Step 1 : After generating cube.js schema successfully , data looks like this:第 1 步:成功生成cube.js 模式后,数据如下所示:

在此处输入图片说明

Step 2 :第2步 :

Now, while I am trying to check the line graph, it's showing the line as below .现在,当我尝试检查折线图时,它显示的线如下所示。 No line is formatted.没有格式化行。 Unfortunately, it's not working for the bar graph also .不幸的是,它也不适用于条形图。

在此处输入图片说明

Moreover, in SQL the data type for the value is : float(10,10) and timestamp此外,在 SQL 中,值的数据类型是:float(10,10) 和时间戳

Apart from that, cube.js console has not error trace , rather its working fine :除此之外,cube.js 控制台没有错误跟踪,而是工作正常:

Performing query: scheduler-0070c129-f83a-45db-ae09-aac6f9858200
Executing SQL: scheduler-0070c129-f83a-45db-ae09-aac6f9858200
--
  SELECT FLOOR((UNIX_TIMESTAMP()) / 10) as refresh_key

Moreover , I tried as below : [all time ,w/o grouping and pivot settings as I need ] , yet no luck ,此外,我尝试如下:[所有时间,没有我需要的分组和枢轴设置],但没有运气, 在此处输入图片说明

However, If I add measure count , the count is plotting the lie not the expected y-axis data as I configured in pivot settings.但是,如果我添加了 measure count ,则计数将绘制谎言而不是我在数据透视设置中配置的预期 y 轴数据。

在此处输入图片说明

My question is : what's going wrong ?我的问题是:出了什么问题?

In the parameters you have specified the timeRange : 'Last 7 Days' and the Grouping to 'Day' .在您已指定 timeRange 的参数中: 'Last 7 Days'和 Grouping to 'Day' this takes all the records of the same day and groups them so the chart you are viewing is a daily chart.这需要同一天的所有记录并将它们分组,因此您正在查看的图表是日线图。 However, to view non-grouped data you can change the grouping to w/o grouping as you did in the first chart.但是,要看到非分组数据可以分组更改为W / O分组,你的第一个图表一样。

My goal was to generate a line graph for the change of a numerical value over time:我的目标是生成一个数值随时间变化的折线图:

x-axis: date/time. x 轴:日期/时间。 y-axis: my numerical value. y 轴:我的数值。

Cube.js Generated the following schema for my data. Cube.js 为我的数据生成了以下架构。 The problem with this schema was that String Type was assigned to the age dimension(clearly should be a Number).这个模式的问题是字符串类型被分配给年龄维度(显然应该是一个数字)。 Moreover ,there are no measures for filed age ,which I am trying to plot.此外,没有针对归档年龄的措施,我正在尝试绘制这些措施

cube(`ConceptDrifts`, {
  sql: `SELECT * FROM cube.concept_drifts`,
  preAggregations: {
  },
  joins: {
    
  },
  measures: {
    count: {
      type: `count`,
      drillMembers: [date]
    },
    testCount: {
      sql: `test_count`,
      type: `sum`
    }
  },
  dimensions: {
    age: {
      sql: `age`,
      type: `string`
    },
    maxAge: {
      sql: `max_age`,
      type: `string`
    },
    sex: {
      sql: `sex`,
      type: `string`
    },
    sexSd: {
      sql: `sex_sd`,
      type: `string`
    },
    date: {
      sql: `date`,
      type: `time`
    }
  },
  dataSource: `default`
});

Therefore, I changed the schema at /cube/conf/schema# manually因此,我手动更改了/cube/conf/schema# 中的架构

Added new measures a:增加了新措施a:

   ag :{
     type : `number`,
     sql : `age`,       
     drillMembers : [age]           
    }   

And, changed the type (as number ) in dimensions :并且,更改了维度中的类型(如number ):

 dimensions: {
    age: {
      sql: `age`,
      type: `number`
    },
    
    maxAge: {
      sql: `max_age`,
      type: `number`
    },
    
    sex: {
      sql: `sex`,
      type: `number`
    },
    
    sexSd: {
      sql: `sex_sd`,
      type: `number`
    },
    
    date: {
      sql: `date`,
      type: `time`
    }
  },
  
  dataSource: `default`
});

As a result, the graph looks like below :结果,图表如下所示:

在此处输入图片说明

More reference :更多参考:

Data Schema Concepts数据模式概念
Drilldowns 钻取

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM