I want to edit the default typography of vuetify 3, in which it's defined in a variables.scss file that is shown below inside the package itself.
$typography: map-deep-merge(
(
'h1': (
'size': 6rem,
'weight': 300,
'line-height': 6rem,
'letter-spacing': -.015625em,
'font-family': $heading-font-family,
'text-transform': none
),
'h2': (
'size': 3.75rem,
'weight': 300,
'line-height': 3.75rem,
'letter-spacing': -.0083333333em,
'font-family': $heading-font-family,
'text-transform': none
),
'h3': (
'size': 3rem,
'weight': 400,
'line-height': 3.125rem,
'letter-spacing': normal,
'font-family': $heading-font-family,
'text-transform': none
),
'h4': (
'size': 2.125rem,
'weight': 400,
'line-height': 2.5rem,
'letter-spacing': .0073529412em,
'font-family': $heading-font-family,
'text-transform': none
),
'h5': (
'size': 1.5rem,
'weight': 400,
'line-height': 2rem,
'letter-spacing': normal,
'font-family': $heading-font-family,
'text-transform': none
),
'h6': (
'size': 1.25rem,
'weight': 500,
'line-height': 2rem,
'letter-spacing': .0125em,
'font-family': $heading-font-family,
'text-transform': none
),
'subtitle-1': (
'size': 1rem,
'weight': normal,
'line-height': 1.75rem,
'letter-spacing': .009375em,
'font-family': $body-font-family,
'text-transform': none
),
'subtitle-2': (
'size': .875rem,
'weight': 500,
'line-height': 1.375rem,
'letter-spacing': .0071428571em,
'font-family': $body-font-family,
'text-transform': none
),
'body-1': (
'size': 1rem,
'weight': 400,
'line-height': 1.5rem,
'letter-spacing': .03125em,
'font-family': $body-font-family,
'text-transform': none
),
'body-2': (
'size': .875rem,
'weight': 400,
'line-height': 1.25rem,
'letter-spacing': .0178571429em,
'font-family': $body-font-family,
'text-transform': none
),
'button': (
'size': .875rem,
'weight': 500,
'line-height': 2.25rem,
'letter-spacing': .0892857143em,
'font-family': $body-font-family,
'text-transform': uppercase
),
'caption': (
'size': .75rem,
'weight': 400,
'line-height': 1.25rem,
'letter-spacing': .0333333333em,
'font-family': $body-font-family,
'text-transform': none
),
'overline': (
'size': .75rem,
'weight': 500,
'line-height': 2rem,
'letter-spacing': .1666666667em,
'font-family': $body-font-family,
'text-transform': uppercase
)
),
$typography
);
$flat-typography: () !default;
#each $type, $values in $typography {
$flat-typography: map-deep-merge(
$flat-typography,
(#{$type}: map.values($values))
);
}
What i want to achieve is for example change the h1 size to 32px, so that the default vuetify text-h1 class would automatically get the new 32px value.
I have tried overriding the vuetify classes themselves like (text-h1, text-h2 etc...) but it doesn't work since they all have !important property
create variables.scss in assets like bottom.
.v-application {
[class*= "-h1"] {
font-size: 32px !important;
}
}
and add this to vuetify plugin.
import "vuetify/styles";
import "#/assets/variables.scss" // add after vuetify default styles
Related
I'm using react-native-chart-kit to display and am trying to change the y-axis (see screen shot below). I tried filling the yLabels property with an array of strings. But that didn't work. Any help would be appreciated!
You can use the formatYLabel prop for this (https://github.com/indiespirit/react-native-chart-kit#line-chart):
/*
* Generator helper function that allows us to
* cleanly return a label from an array
* of labels for each segment of the y-axis
*/
function* yLabel() {
yield* ['None', 'Low', 'Med', 'High'];
}
function App() {
// Instantiate the iterator
const yLabelIterator = yLabel();
return (
<View>
<LineChart
data={{
labels: ['Mo', 'Tu', 'We', 'Fr', 'Sa', 'Su'],
datasets: [
{
data: [3, 2, 1, 4, 4],
},
{
data: [5, 1, 3, 2],
},
],
}}
segments={3}
width={320}
height={200}
formatYLabel={() => yLabelIterator.next().value}
chartConfig={{
backgroundColor: 'white',
backgroundGradientFrom: 'grey',
backgroundGradientTo: 'grey',
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
labelColor: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
}}
/>
</View>
);
}
export default App;
If you want to display 4 y-axis labels you need to set the segments prop of the LineChart to 3.
If you want to learn more about yield in Javascript you can read this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield*.
I am trying to create a multiline chart in simple react native mobile application.
I tried various libraries but the multiline chart is not working.
I am new to this. Please help.
you can use "react-native-char-kit"
just by providing multiple datasets, you can implement a multiline chart.
<LineChart
bezier
withHorizontalLabels={false}
withVerticalLabels={false}
data={{
labels: [' jan', ' feb', ' mar', ' apr', ' june', ' july'],
datasets: [
{
data: [10, -4, 6, -8, 80, 20],
strokeWidth: 2,
},
{
data: [5,8,6,9,8,2,-2],
strokeWidth: 2,
},
],
legend: ['car', 'bike'],
}}
width={Dimensions.get('window').width - 16}
height={200}
chartConfig={{
backgroundColor: '#1cc910',
backgroundGradientFrom: '#eff3ff',
backgroundGradientTo: '#efefef',
decimalPlaces: 2,
color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`,
style: {
borderRadius: 16,
},
}}
style={{
borderRadius: 16,
}}
/>
I am using react-native-chart-kit and I am trying to have a cbar chart with any color filling up the bars, as of now it is gray but I am trying to change it but i have tried adding color: {} within the datasets part, as well as svg. But to no success. Any suggestions will be greatly appreciated.
render() {
return (
<View>
<BarChart
data={{
labels: [
'1',
'2',
'3',
'4',
'5',
'6',
'7'
],
datasets: [
{
data: this.props.data,
},
],
}}
svg={{ fill: 'green' }}
width={Dimensions.get('window').width - 16}
height={220}
chartConfig={{
backgroundColor: '#fff',
backgroundGradientFrom: '#fff',
backgroundGradientTo: '#fff',
decimalPlaces: 2,
color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`,
style: {
borderRadius: 16,
},
propsForDots: {
r: "0",
strokeWidth: "2",
stroke: "#fff"
},
propsForBackgroundLines: {
strokeWidth: 0
},
}}
style={{
marginVertical: 8,
borderRadius: 16,
}}
/>
</View>
);
}
You can set fillShadowGradient and fillShadowGradientOpacity in your chartConfig.
More info here: https://github.com/indiespirit/react-native-chart-kit#chart-style-object
You can add below lines in the
chartConfig:{{
fillShadowGradient:'skyblue',
fillShadowGradientOpacity:1,
}}
Its works fine
<BarChart
data={{
labels: this.state.bLabel,
datasets: [
{
data: this.state.bData,
}
]
}}
width={(Dimensions.get("window").width/100)*98}
height={300}
yAxisLabel=""
chartConfig={this.state.chartConfig}
verticalLabelRotation={0}
showValuesOnTopOfBars={true}
fromZero={true}
withCustomBarColorFromData={true}//FOR CUSTOM BAR COLORS
withHorizontalLabels ={false}
style={{alignSelf:"flex-start"}}
/>
//Go to
//node_modules->react-native-chart-kit->dist->BarChart.js
//Change this-> from line no-38 to 50
_this.renderBars = function (_a) {
var colorC=["#8000FF80","#0000ff80","#00FFFF80","#00ff0080","#ffff0080","#FFA50080","#ff000080","#2e000080","#00000080","#000000dd"];/////////AYUSH KHADE
var data = _a.data, width = _a.width, height = _a.height, paddingTop = _a.paddingTop, paddingRight = _a.paddingRight, barRadius = _a.barRadius, withCustomBarColorFromData = _a.withCustomBarColorFromData;
var baseHeight = _this.calcBaseHeight(data, height);
return data.map(function (x, i) {
var barHeight = _this.calcHeight(x, data, height);
var barWidth = 32 * _this.getBarPercentage();
return (<Rect key={Math.random()} x={0 +
(i * (width - 0)) / data.length +
barWidth / 2} y={((barHeight > 0 ? baseHeight - barHeight : baseHeight) / 4) * 3 +
paddingTop} rx={barRadius} width={barWidth} height={(Math.abs(barHeight) / 4) * 3} fill={colorC[i]}/>);//AYUSH KHADE
});
};
I tried to make a custom geofencing, to do this, I display an Url of googlemap and I add a stack with a circle, I had adjust the size with a coefficient to have the good representation. problem my coefficient isn't dynamic with any screen device
Container ( padding: const EdgeInsets.only(top :160.0),
child : new Card(
elevation: 2.0,
child: new Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
new Container(
child: new Image.network(statichomeMapUri.toString()),
),
FractionalTranslation(
translation: Offset(0.0, 0.0),
child: new Container(
alignment: new FractionalOffset(0.0, 0.0),
decoration: new BoxDecoration(
border: new Border.all(
color: Colors.orangeAccent.withOpacity(0.5),
width: perimetre/3.4, // need to be dynamic
),
shape: BoxShape.circle,
),
),
),
new Container(
//padding: const EdgeInsets.only(bottom:10.0),
margin: new EdgeInsets.all(140.0),
child : Icon(Icons.home, color: Colors.white, size: 25.0),
),
],
),
),
)
Get width of the mobile screen using
MediaQuery.of(context).size.width
And set whatever ratio you want to set
I want to create bar chart having each bar different color with x-axis values. I have tried barChart from react-native-svg-charts.
You can create the bar chart having each bar with different color using the react-native-svg-charts module using the BarChart. I have just created a bar chart with different color using the code below:-
you can provide the data with each different svg colors as below:-
const data1 = [ 14, -1, 100, -95, -94, -24, -8, 85, -91, 35, -53, 53, -78, 66, 96, 33, -26, -32, 73, 8 ]
.map((value) => ({ value }))
const data2 = [ 24, 28, 93, 77, -42, -62, 52, -87, 21, 53, -78, -62, -72, -6, 89, -70, -94, 10, 86, 84 ]
.map((value) => ({ value }))
const barData = [
{
data: data1,
svg: {
fill: 'rgb(134, 65, 244)',
},
},
{
data: data2,
svg: {
fill: 'red',
},
},
]
Then you can use this bar data inside the bar chart so that you get 2 bars with different colors as red and blue.
<BarChart
yAccessor={({ item }) => item.value}
style={{ height: 200 }}
data={ barData }
svg={{ fill: 'green' }}
contentInset={{ top: 30, bottom: 30 }}
>
<Grid/>
</BarChart>
Let me know if you still have any problem.
You can even find this example on the examples of the react-native-svg-charts on this link.