How to change the document content's width? - react-styleguidist

The default max-width of 'main' element is 1000px, I want to make it wider. I tried the customize style instruction but cannot locate the 'main' element or the 'rsg--content-xx' class by below config in 'styleguide.config.js'
styles: {
StyleGuide: {
'rsg--content': {
maxWidth: 1300,
width: 1300
},
'#global main': {
maxWidth: 1300,
width: 1300
}
}
}
Any help would be very appreciate.

The styles function in the StyleGuideRenderer component takes the theme as the argument. maxWidth is set in the theme. You can override theme properties in styleguide.config.js:
module.exports = {
theme: {
maxWidth: 1300
}
}

According to the docs it should be something like this:
styles: {
StyleGuide: {
content: {
maxWidth: 1300
}
}
}

Related

Highcharts | Label width control in bar charts

I am trying to find a way to control width of the x-axis labels container in bar charts in styled mode. I want to have preset values and depending on the preset have labels to take 20, 30, 40, 50% of the graphic. Is there a property for that?
Thank you!
If you want to set labels' width depending on their length and relative to chart width, you can use chart.event.render to achieve that. It will allow you to find the number of characters and set dynamically the percentage width.
var allowChartUpdate = true;
Highcharts.chart('container', {
chart: {
type: 'bar',
styledMode: true,
events: {
render: function() {
if (allowChartUpdate) {
this.xAxis[0].categories.forEach(category => {
if (category.length > 10) {
var dynamicMargin = this.chartWidth * 50 / 100;
allowChartUpdate = false;
this.update({
chart: {
marginLeft: dynamicMargin
}
}, true, true, false);
allowChartUpdate = true;
}
})
}
}
}
},
...
Demo:
https://jsfiddle.net/BlackLabel/59xjq4du/
API Reference:
https://api.highcharts.com/highcharts/chart.events.render

highcharts responsive method in Highcharts.net wrapper

I would like to know the ASP.net wrapper implementation of this JavaScript code
responsive: {
rules
rules: [{
condition: {
maxWidth: 370
},
chartOptions: {
chart: {
width: 250,
height: 400,
marginLeft: 40,
marginTop:-120
},
legend: {
x: -20,
y: 260,
floating: true,
align: 'left',
verticalAlign: 'top',
layout: 'horizontal',
width: 300
}
}
}]
}
I tried it this way , but not getting proper namespaces for Condition and ChartOptions
Responsive = new Responsive()
{
Rules= new List<ResponsiveRules>{
Condition = new ResponsiveRulesCondition()
{
MaxWidth = 375
},
ChartOptions
{
}
}
chartOptions is of object type
Responsive responsive = new Responsive()
{
Rules = new List<Highsoft.Web.Mvc.Charts.ResponsiveRules>()
{
new Highsoft.Web.Mvc.Charts.ResponsiveRules
{
ChartOptions = new { chart = new { className = "small-chart" } },
Condition = new ResponsiveRulesCondition() { MaxWidth = 500 }
}
}
};

How to show the container in a nested treemap?

I have a treemap made of
a big container
with an element
with an element
with an element which is itself made of
an element
an element
another big container
Highcharts.chart('container', {
series: [{
type: "treemap",
animation: false,
data: [
// first big category
{
id: 'B',
name: 'B'
},
{
name: 'Anne',
parent: 'B',
value: 4
}, {
name: 'Peter',
parent: 'B',
value: 1
},
// below is a member of forst big category, but with sub-categories
{
name: 'aaa container',
parent: 'B',
id: 'aaa'
}, {
name: 'Anneinaaa',
parent: 'aaa',
value: 1
}, {
name: 'Rickinaaa',
parent: 'aaa',
value: 3
},
// second big category
{
name: 'Susanne',
parent: 'Kiwi',
value: 2,
color: '#9EDE00'
}
]
}],
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/treemap.js"></script>
<div id="container"></div>
I would like to highlight the fact that there is a container for Rickinaaa and Anneinaaa, with a description.
Right now Rickinaaa and Anneinaaa are at the same level as Anne and Peter, despite the fact that it is their container (the one I do not know how to show) which should be at their level.
An example from ZingCharts which shows this multilayer presentation:
It is much easier to see the box-in-a-box structure.
Is there a way to achieve this in Highcharts? Specifically, how could I have a visible container labelled aaa container which would encompass the rectangles Rickinaaa and Anneinaaa
It can be done by using custom positioning algorithm for treemap. The process is described here: https://www.highcharts.com/docs/chart-and-series-types/treemap (ADD YOUR OWN ALGORITHM section).
I created simplified algorithm for demo purposes (some values are hardcoded):
// Custom positioning algorithm
function myFunction(parent, children) {
childrenAreas = [];
Highcharts.each(children, function(child) {
// Do some calculations
var newLeaf = null;
if (child.id === 'A') {
newLeaf = {
x: 0,
y: 0,
width: 50,
height: 50
};
} else if (child.id === 'B') {
newLeaf = {
x: 50,
y: 0,
width: 50,
height: 50
};
} else if (child.name === 'Rick') {
newLeaf = {
x: parent.x + 10,
y: parent.y + 10,
width: parent.width - 20,
height: (parent.height - 20) / 2
}
} else if (child.name === 'Peter') {
newLeaf = {
x: parent.x + 10,
y: parent.y + 30,
width: parent.width - 20,
height: (parent.height - 20) / 2
}
} else if (child.name === 'Anne') {
newLeaf = {
x: parent.x + 10,
y: 10,
width: parent.width - 20,
height: parent.height - 20
}
}
if (newLeaf) {
childrenAreas.push(newLeaf);
}
});
return childrenAreas;
};
Highcharts.seriesTypes.treemap.prototype.myCustomAlgorithm = myFunction;
By default Highcharts assigns color fill attribute only for the nodes of the Highest level - all other nodes have it set to none. It can be changed manually via CSS:
.highcharts-internal-node {
fill: #bada55
}
I also did a small change in the core code so that parent levels are drawn underneath the child ones:
(function(H) {
var grep = H.grep,
each = H.each,
seriesTypes = H.seriesTypes;
H.seriesTypes.treemap.prototype.drawPoints = function() {
var series = this,
points = grep(series.points, function(n) {
return n.node.visible;
});
each(points, function(point) {
var groupKey = 'level-group-' + point.node.levelDynamic;
if (!series[groupKey]) {
series[groupKey] = series.chart.renderer.g(groupKey)
.attr({
// CHANGED FROM: zIndex: 1000 - point.node.levelDynamic
zIndex: 1000 + point.node.levelDynamic // #todo Set the zIndex based upon the number of levels, instead of using 1000
})
.add(series.group);
}
point.group = series[groupKey];
});
// Call standard drawPoints
seriesTypes.column.prototype.drawPoints.call(this);
// If drillToNode is allowed, set a point cursor on clickables & add drillId to point
if (series.options.allowDrillToNode) {
each(points, function(point) {
if (point.graphic) {
point.drillId = series.options.interactByLeaf ? series.drillToByLeaf(point) : series.drillToByGroup(point);
}
});
}
}
})(Highcharts);
Live demo: https://jsfiddle.net/BlackLabel/wfed4jeo/

resize label width according to window size using extjs

I am using extjs 6.0.2. I want to adjust label width according to the size of the window. how can I do that please help. I have tried this following code but no use.
{
xtype : 'label',
itemId: 'recordNumberShowItem',
style: 'color: #707070; font-family: VegurMedium,sans-serif; font-size: 12px;',
// text: Ext.String.format(me.displayRecordNumberMsg, 0, 0, 0, me.recordName),
scope: me,
listeners : {
show : function ( label , eOpts ){
// width: (window.outerWidth < 1350) ? 70 : 140,
if(window.outerWidth < 1350){
label.setWidth(70);
}
else{
label.setWidth(null);
}
}
}
}
Ext.create({
xtype:'window',
width:200,
height:200,
resizable:true,
items:[
{
xtype:'label',
width:'100%',
style:' word-wrap: break-word;',
text:'dawbnduiawbndawbduibdwuiabduiw'
}]
}).show();
here is a fiddle for you: https://fiddle.sencha.com/#view/editor&fiddle/1lv3

How to create a grid with back and forth navigation in QML for IOS

I'm new to QML Development. I would like to create a grid 10x2. When an element inside the grid is clicked, it takes me to the next page and show a back arrow button on toolbar to bring me back to the main grid page.
The result I'm searching for is something like this.
You can you the visible poperty of the element as follows:
Item {
id: menu
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: parent.bottom
}
Component {
id: delegate
Rectangle {
id: wrapper
width:
height:
MouseArea {
anchors.fill: parent
onClicked: {
gView.currentIndex = index;
goAway();
}
}
}
}
GridView {
id: gView
anchors.fill: parent
model: model // your model
delegate: delegate
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
focus: true
clip: true
}
function goAway() {
gView.visible = false;
arrow.visible = true;
}
function comeBack() {
gView.visible = true;
arrow.visible = false;
}
Image {
id: arrow
source: //your arrow image source
visible:false
anchors {
top: parent.top
left: parent.left
leftMargin: 20
}
MouseArea {
anchors.fill: parent
onClicked: comeBack()
}
}
You can edit it according to your needs.

Resources