当前位置:网站首页>Bizchart+slider to realize grouping histogram
Bizchart+slider to realize grouping histogram
2022-07-04 21:52:00 【Understanding the initial state】
Use bizchart Achieve grouping histogram , With slider selection . The renderings are as follows :

Environmental Science
be based on bizchart3.x
npm install [email protected]
npm install [email protected]
Chart-Slider Component encapsulation
Chart and Slider yes 2 A component , For ease of use , We are encapsulated together , Return with a function .
import DataSet from '@antv/data-set';
import {
Axis, Chart, Geom, Legend, Tooltip } from "bizcharts";
import Slider from "bizcharts-plugin-slider";
import React, {
Component } from 'react';
function getGroupChartWithSliderComponent(data) {
const ds = new DataSet({
state: {
start: data[0] ? data[0].timestamp : '',
end: data[0] ? data[data.length - 1].timestamp : '$'
}
});
const dv = ds.createView('origin').source(data);
dv.transform({
type: 'filter',
callback(item) {
const r = item.timestamp;
return r >= ds.state.start && r <= ds.state.end;
}
});
class GroupChartWithSlider extends React.Component {
handleTimeSliderChange(e) {
const {
startValue, endValue } = e;
ds.setState('start', startValue);
ds.setState('end', endValue);
}
render() {
const chartScale = {
'timestamp': {
alias: ' Time '
},
'count': {
alias: ' frequency '
}
};
return (
<div>
<Chart height={
200} data={
dv} forceFit padding='auto' scale={
chartScale}>
<Legend position="top-center" />
<Axis name="timestamp" />
<Axis name="count" />
<Tooltip />
<Geom
type="interval"
position="timestamp*count"
color={
["tag"]}
// color={["tag", ["#f5222d", "#ec6740", "#ffa39e"]]}
adjust={
[
{
type: "dodge",
marginRatio: 1 / 32
}]}
style={
{
stroke: "#fff",
lineWidth: 1
}}
/>
</Chart>
<Slider data={
data} padding={
10} xAxis="timestamp" yAxis="count"
scales={
{
// Do not display text
timestamp: {
formatter: () => ''
}
}}
onChange={
this.handleTimeSliderChange.bind(this)} />
</div>
);
}
}
return GroupChartWithSlider;
}
Use
To generate a grouping histogram , Just the same one X There are multiple values for the axis Y value , below X The axis is timestamp, Y The axis is count.
class MyApp extends Component {
state = {
// Aggregate group histogram data
groupErrorData: [/* { "timestamp": '2022-6-22T11:43', "count": 15, "tag": " egg ", }, { "timestamp": '2022-6-22T11:43', "count": 3, "tag": " Banana ", }, { "timestamp": '2022-6-22T11:43', "count": 19, "tag": " pumpkin ", }, { "timestamp": '2022-6-22T11:43', "count": 5, "tag": " Southwest flower ", }, { "timestamp": '2022-6-22T11:45', "count": 6, "tag": " Wax gourd ", }, { "timestamp": '2022-6-22T11:45', "count": 20, "tag": " celery ", }], }; render() { const GroupChartWithSlider = getGroupChartWithSliderComponent(this.state.groupErrorData); return ( <div> <GroupChartWithSlider /> </div > ); } } export default MyApp; Slider effect
Slider You can drag , Show the trend of the data .
边栏推荐
- Le module minidom écrit et analyse XML
- How to implement Devops with automatic tools
- Lambdaquerywrapper usage
- Solve the problem of data disorder caused by slow asynchronous interface
- QT - double buffer plot
- Learning breakout 3 - about energy
- Flutter 返回按钮的监听
- 淘宝商品评价api接口(item_review-获得淘宝商品评论API接口),天猫商品评论API接口
- QT - plot other problems
- 案例分享|金融业数据运营运维一体化建设
猜你喜欢
![[optimtool.unconstrained] unconstrained optimization toolbox](/img/ef/65379499df205c068ee9bc9df797ac.png)
[optimtool.unconstrained] unconstrained optimization toolbox

开源之夏专访|Apache IoTDB社区 新晋Committer谢其骏

【C語言】符號的深度理解
![Jerry added the process of turning off the touch module before turning it off [chapter]](/img/28/5e4eb39243a0c973d0b90f76571f9b.png)
Jerry added the process of turning off the touch module before turning it off [chapter]

解析互联网时代的创客教育技术

Redis has three methods for checking big keys, which are necessary for optimization

如何借助自动化工具落地DevOps
![[public class preview]: basis and practice of video quality evaluation](/img/fd/42b98a08b5a0fd89c119f1d1a8fe1b.png)
[public class preview]: basis and practice of video quality evaluation

What is business intelligence (BI), just look at this article is enough

TCP shakes hands three times and waves four times. Do you really understand?
随机推荐
奋斗正当时,城链科技战略峰会广州站圆满召开
minidom 模块写入和解析 XML
【LeetCode】17、电话号码的字母组合
Open3D 曲面法向量计算
Cadeus has never stopped innovating. Decentralized edge rendering technology makes the metauniverse no longer far away
Daily question-leetcode556-next larger element iii-string-double pointer-next_ permutation
旋变串判断
Delphi soap WebService server-side multiple soapdatamodules implement the same interface method, interface inheritance
关系型数据库
Go language loop statement (3 in Lesson 10)
gtest从一无所知到熟练使用(4)如何用gtest写单元测试
淘宝商品评价api接口(item_review-获得淘宝商品评论API接口),天猫商品评论API接口
QT—双缓冲绘图
Operation of adding material schedule in SolidWorks drawing
Jerry's ad series MIDI function description [chapter]
redis RDB AOF
OMS系统实战的三两事
Jerry's ad series MIDI function description [chapter]
案例分享|金融业数据运营运维一体化建设
如何使用ConcurrentLinkedQueue做一个缓存队列