Vertical grouped bar chart of dynamic columns using react-vis - reactjs

vertical grouped bar chart of dynamic columns using react-vis
the output using react-vis vertical bar
Expected output
<XYPlot
xType={chartData['type']}
width={width}
height={height}>
<VerticalGridLines style={gridLineStyle} />
<HorizontalGridLines style={gridLineStyle} />
<XAxis tickLabelAngle={xAxisAngle} style={tickStyle} tickFormat={chartData['type'] == 'linear' ? tick => this.formatNumber(tick) : null} />
<YAxis tickLabelAngle={yAxisAngle} style={tickStyle} tickFormat={tick => this.formatNumber(tick)} />
<ChartLabel
text={chartData['name']}
className="alt-x-label"
includeMargin={false}
xPercent={0.5}
yPercent={1.18}
style={{
fontWeight: 'bold',
textAnchor: 'middle',
fontSize: "12px",
fill: "#6b6b76",
fontFamily: "sans-serif"
}}
/>
<ChartLabel
text={'No. of variants'}
className="alt-y-label"
includeMargin={false}
xPercent={-0.02}
yPercent={0.5}
style={{
transform: 'rotate(-90)',
fontWeight: 'bold',
textAnchor: 'middle',
fontSize: "12px",
fill: "#6b6b76",
fontFamily: "sans-serif"
}}
/>
{hoveredNode && (
<Hint value={hoveredNode}>
<div style={{ background: '#000000' }}>
<p style={{ fontSize: "10px", padding: "3px", color: '#ffffff' }}>{`${hoveredNode.y} variants with ${chartData['name']} of ${hoveredNode.x}`}</p>
</div>
</Hint>
)}
<BarSeries data={A} />
<BarSeries data={C} />
<BarSeries data={G} />
<BarSeries data={T} />
</XYPlot>
I get three 3 bars but there is always one fourth empty bar. Which is not needed. Any suggestion would be helpful. Thanks

Related

TouchableHighlight: React.Children.only expected to receive a single React element child. (React Native)

So I already know that <TouchableHighlight> can have specifically 1 child, but when I do that, I STILL get the error: React.Children.only expected to receive a single React element child.
What is going on? Is it a bug?
I literally took this example from somewhere online and it is supposed to work:
<View>
<Text>Tony Stark is Ironman</Text>
<TouchableHighlight>
<View
style={{
width: "50px",
height: "50px",
backgroundColor: "yellow",
}}
/>
</TouchableHighlight>
</View>
Yet, I still get the error.
This is the entire code:
<Form onSubmit={onSubmit}>
<KeyboardAwareScrollView>
<Button title={props.title} onPress={toggleModal} color="#006600" />
<Modal
isVisible={isModalVisible}
backdropColor="white"
style={{ marginTop: 55 }}
>
<KeyboardAwareScrollView
style={{
backgroundColor: "white",
borderBottomColor: "#000000",
borderBottomWidth: 2,
padding: 15,
}}
>
<Button title="Cancel" onPress={toggleModal} color="red" />
<TextInput
placeholder="Name of park/launch"
multiline
style={{ height: 60, borderColor: "gray", borderWidth: 1 }}
onChangeText={(t) => setName(t)}
value={name}
/>
<View>
<Text>Tony Stark is Ironman</Text>
<TouchableHighlight>
<View
style={{
width: "50px",
height: "50px",
backgroundColor: "yellow",
}}
/>
</TouchableHighlight>
</View>
{/* <TextInput
placeholder="Comments"
multiline
style={{ height: 60, borderColor: "gray", borderWidth: 1 }}
onChangeText={(t) => setComments(t)}
value={comments}
/> */}
<TextInput
placeholder="Tags (separate each tag by a comma)"
multiline
style={{ height: 60, borderColor: "gray", borderWidth: 1 }}
onChangeText={(t) => setTags(t)}
value={tags}
/>
<Text>Rate the difficulty of this location</Text>
<Slider
step={1}
minimumValue={0}
maximumValue={10}
value={difficulty}
onValueChange={(slideValue) => setDifficultyValue(slideValue)}
minimumTrackTintColor="#1fb28a"
maximumTrackTintColor="#d3d3d3"
thumbTintColor="#b9e4c9"
/>
<Text>Difficulty value: {difficulty}</Text>
<ImagePickerExample></ImagePickerExample>
<Button
raised
icon={{ name: "check" }}
title="Submit"
name="submit"
color="green"
onPress={onSubmit}
/>
</KeyboardAwareScrollView>
</Modal>
</KeyboardAwareScrollView>
</Form>
Check for whitespaces or something like that inside <TouchableHighlight />

Native Base Tabs Bar styling

Any solution for styling the bar container in Native base ?
The offered vars are not enough, Like I need to change TabsContainer height, remove the bottom border and do some side padding before the tabs
Before I ask I checked all the related topics and nothing suitable for my situation
import React, { Component } from 'react';
import { Container, Tab, Tabs, ScrollableTab, Icon, Text } from 'native-base';
import Tab1 from './tabOne';
import Tab2 from './tabTwo';
import Tab3 from './tabThree';
import Tab4 from './tabFour';
import Tab5 from './tabFive';
export default class ProdList extends Component {
render() {
return (
<Container>
<Tabs tabContainerStyle={{ height: 30, borderWidth: 0 }} tabBarUnderlineStyle = {{ width: 0, borderWidth: 0}} tabBarBackgroundColor='#fff' tabStyle={{backgroundColor: '#fff'}} renderTabBar={()=> <ScrollableTab />}>
<Tab tabStyle={{backgroundColor: '#fff',marginLeft: 30, marginRight: 30, paddingLeft: 30 }} textStyle={{fontFamily: 'Poppins', color: '#aeaeb1'}} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Main Course">
<Tab1 />
</Tab>
<Tab tabStyle={{backgroundColor: '#fff', }} textStyle={{color: '#aeaeb1',fontFamily: 'Poppins', }} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Appetizers">
<Tab2 />
</Tab>
<Tab tabStyle={{backgroundColor: '#fff', }} textStyle={{fontFamily: 'Poppins', color: '#aeaeb1'}} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Desserts">
<Tab3 />
</Tab>
<Tab tabStyle={{backgroundColor: '#fff', }} textStyle={{fontFamily: 'Poppins', color: '#aeaeb1'}} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Soups">
<Tab4 />
</Tab>
<Tab tabStyle={{backgroundColor: '#fff', }} textStyle={{fontFamily: 'Poppins', color: '#aeaeb1'}} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Salads">
<Tab5 />
</Tab>
</Tabs>
</Container>
);
}
}
Here is the Result
need to change TabsContainer height, remove the bottom border and do some side padding before the tabs .. Any solution ?

ReactJS Ionic cannot remove padding from Grid Col element

I'm using React-Ionic and I am not able to reduce the top/bottom padding from the Col element of my Grid.
This is the code I'm using
<IonGrid fixed={true} >
<IonRow >
{
categories.map(l => {
return (
<IonCol key={l.name} size="6" size-md >
<IonCard style={{ backgroundColor: '#444' }}>
<IonCardHeader >
<IonIcon style={{ display: 'flex', fontSize: '30px', marginBottom: 10 }} icon={l.icon} />
<IonCardTitle style={{ fontSize: 18 }}>{l.name}</IonCardTitle>
</IonCardHeader>
</IonCard>
</IonCol>
)
})
}
</IonRow>
</IonGrid>
and below you can see the result, but I wanted to have vertically closer the cards.
I also tried to change the code to
<IonCard style={{ backgroundColor: '#444', paddingTop:0, paddingBottom:0 }}>
without results.
Thanks for the help.
it is a combination of padding and margin, i reduced it to zero so you can adjust accordingly
<IonCol key={l} size="6" size-md style={{ padding : 0}}>
<IonCard style={{ backgroundColor: '#444', padding :0 , margin :0 }}>
<IonCardHeader >
<IonIcon style={{ display: 'flex', fontSize: '30px', marginBottom: 10 }} icon={homeOutline} />
<IonCardTitle style={{ fontSize: 18 }}>{l + " THIS IS TITLE"}</IonCardTitle>
</IonCardHeader>
</IonCard>
</IonCol>

How to stretch the card according to the content displayed in reactjs?

I'm new to material UI framework, i want to stretch the grid accordingly displayed in the content. I couldn't able to do that. Can anyone help me in this?
<Card>
<CardHeader
avatar={<Avatar aria-label="recipe">S</Avatar>}
title={
<>
<InputBase placeholder="Search Google Maps" margin="normal" />
<IconButton type="submit" aria-label="search">
<SearchIcon />
</IconButton>
</>
}
/>
<Divider />
<CardContent
style={{ overflow: "scroll" }}
className={classes.contentHeight}
id="chatList"
>
<div>
<Message isSender content="Hello" />
{this.state.data.map(item => {
if (item.isSender) {
return (
<Message isSender name="Sanjana" content={item.content} />
);
}
return <Message name="Sanjana" content={item.content} />;
})}
</div>
</CardContent>
<Divider />
<CardActions>
<Paper className={classes.contentPaper}>
<Input
margin="dense"
className={classes.input}
placeholder="Enter a Message"
disableUnderline
/>
</Paper>
</CardActions>
</Card>
Can anyone help me in this query?
Thanks in advance!
Remove width: 100
<Card
style={{
backgroundColor: "#eee",
float: isSender ? "right" : "left",
padding: 16,
minHeight: 40,
width: 100,
display: "flex",
alignItems: "center",
textAlign: "center"
}}
>
{content}
</Card>
should be
<Card
style={{
backgroundColor: "#eee",
float: isSender ? "right" : "left",
padding: 16,
minHeight: 40,
display: "flex",
alignItems: "center",
textAlign: "center"
}}
>
{content}
</Card>
because the width: 100 gives it a width of 100px.
To make the content to stretch full width, you can use width: "fit-content" and assign your width value of 100 to minWidth: 100.
So your card will look like,
<Card
style={{
backgroundColor: "#eee",
float: isSender ? "right" : "left",
padding: 16,
diaplay: "block",
minHeight: 40,
width: "fit-content",
minWidth: 100,
display: "flex",
alignItems: "center",
textAlign: "center"
}}
>
To make the content left align inside card, you can assign style to Grid like,
<Grid style={{ paddingBottom: 8, textAlign: "left" }} item xs={12}>
<span>{name}</span>
</Grid>
Forked sandbox

KeyboardAvoidingView is not adjusting height

Im trying to get my text view and button to center when the Keyboard is summoned.
I tried wrapping my SafeArea with KeyboardAvoidingView but that did not seem to work.
I also tried setting the KeyBoardAvoidingView behavior to position which also did not work.
Any guidance would be appreciated.
KeyboardAvoidingView does not seem to work as expected.
**Whats happening : **
**Heres my code : **
<SafeAreaView style={{ flex: 1, backgroundColor: '#376772' }}>
<KeyboardAvoidingView
style={{ flex: 1 }}
behavior={Platform.Os == 'ios' ? 'padding' : null}
>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={{ flex: 1 }}>
<MapView
style={{ flex: 0.6 }}
showsMyLocationButton={true}
showsUserLocation={true}
followsUserLocation={lock}
onTouchStart={() => {
set(false)
}}
onPress={(loc) => {
setLocation(loc.nativeEvent.coordinate)
}}
>
<Marker coordinate={location} />
</MapView>
<Fragment>
<View
style={{
alignSelf: 'center',
alignContent: 'center',
backgroundColor: '#202B35',
padding: 10,
paddingHorizontal: 35,
margin: 5,
borderRadius: 5,
alignItems: 'center',
position: 'absolute',
}}
>
<View style={{ flexDirection: 'row' }}>
<Badge
status="error"
containerStyle={{ padding: 5 }}
/>
<Text
style={{
color: '#fff',
fontSize: 16,
marginBottom: 5,
}}
>
New Crossing
</Text>
<Text
style={{
color: '#fff',
fontSize: 10,
padding: 5,
}}
>
(Tap to add)
</Text>
</View>
<View style={{ flexDirection: 'row' }}>
<Badge
status="primary"
containerStyle={{ padding: 5 }}
/>
<Text
style={{
color: '#fff',
fontSize: 16,
}}
>
{'Existing Crossings'}
</Text>
</View>
</View>
</Fragment>
<View
style={{
flex: 0.4,
backgroundColor: '#376772',
margin: 5,
borderRadius: 5,
}}
>
<Input
placeholder="Enter Crossing name here"
inputStyle={{ color: 'orange' }}
rightIcon={
<Icon
name="edit"
size={25}
color="orange"
/>
}
placeholderTextColor={'orange'}
errorStyle={{ color: 'red' }}
/>
<Button
buttonStyle={{
margin: 10,
top: scale(10),
padding: 15,
backgroundColor: '#5cb85c',
borderRadius: 4,
}}
icon={
<Icon name="send" size={15} color="white" />
}
iconRight
titleStyle={{ fontWeight: 'bold' }}
title="Submit "
/>
</View>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
</SafeAreaView>
Setting behavior to "position" worked for me by removing flex: 1 from styles, like
<KeyboardAvoidingView behavior="position">
{children}
</KeyboardAvoidingView>
Cheers!

Resources