Set minimum height or width for column FusionCharts - reactjs

If data is very lower than others, it's almost like zero, and the user can't click or hover because it's too small.
How can I set a minimum height or width for very small numbers?
I have this problem with ApexCharts too.
const chartConfigs = {
type: "column2d",
width: "100%",
height: 500,
dataFormat: "json",
dataSource: {
chart: {
caption: "Countries With Most Oil Reserves [2017-18]",
subCaption: "In MMbbl = One Million barrels",
xAxisName: "Country",
yAxisName: "Reserves (MMbbl)",
numberSuffix: "K",
theme: "fusion",
},
data: [
{
label: "Venezuela",
value: "290",
},
{
label: "Saudi",
value: "260",
},
{
label: "Canada",
value: "180",
},
{
label: "Iran",
value: "140",
},
{
label: "Russia",
value: "115",
},
{
label: "UAE",
value: "100",
},
{
label: "US",
value: "3000000",
},
{
label: "China",
value: "30",
},
],
},
};

This is normal since your y-axis scale is linear if one of your plots has a very large value & the other plot values are very low compared to the large plot value then the plot area of the smaller value plot will be very minimum.
To overcome this you can use logarithmic y-axis, here is an example -
FusionCharts.ready(function() {
var footfallChart = new FusionCharts({
type: 'logmscolumn2d',
renderAt: 'chart-container',
width: '500',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"theme": "fusion",
"caption": "Store footfall vs Online visitors ",
"subCaption": "Last Year",
"xAxisName": "Quarter",
"yAxisName": "No of visitors",
"showXAxisLine": "1",
"axisLineAlpha": "10"
},
"categories": [{
"category": [{
"label": "Q1"
},
{
"label": "Q2"
},
{
"label": "Q3"
},
{
"label": "Q4"
}
]
}],
"dataset": [{
"seriesname": "Total footfalls",
"data": [{
"value": "126734"
},
{
"value": "64"
},
{
"value": "34"
},
{
"value": "56"
},
{
"value": "78"
}
]
}]
}
}).render();
});
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script>
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script>
<div id="chart-container">FusionCharts will render here</div>

Related

I am struggling with managing the state of a react form

i have this json object which i use to map the form. I have a lot of nested questions. It is used for medical purposes. Here's an portion of the json
parts: [
{
title: "Surgery-related",
questions: [
{
type: "radio",
required: true,
label: "Timing of surgery",
name: "timing_of_surgery",
options: [
{
label: "Emergent non-cardiac surgery",
value: "emergent_non_cardiac_surgery",
},
{
label: "Urgent non-cardiac surgery",
value: "urgent_non_cardiac_surgery",
},
{
label: "Time-sensitive non-cardiac surgery",
value: "time_sensitive_non_cardiac_surgery",
},
{
label: "Elective non-cardiac surgery",
value: "elective_non_cardiac_surgery",
name: "elective_non_cardiac_surgery",
nestedQuestion: {
type: "radio",
options: [
{
label: "Possible to defer non-cardiac surgery",
value: "possible_to_defer_non_cardiac_surgery",
},
{
label: "Not possible to defer non-cardiac surgery",
value: "not_possible_to_defer_non_cardiac_surgery",
},
],
},
},
],
},
{
type: "select",
required: true,
label: "Type of surgery or intervention",
name: "type_of_surgery_or_intervention",
options: [
{
value: "Low surgical risk (<1%)",
titles: [
"Breast",
"Dental",
"Endocrine: thyroid",
"Eye",
"Gynaecological: minor",
"Orthopaedic minor (meniscectomy)",
"Reconstructive",
"Superficial surgery",
"Urological minor: (transurethral resection of the prostate)",
"Video assisted thoracic surgery minor lung resection",
],
},
{
value: "Intermediate surgical risk (1-5%)",
titles: [
"Carotid asymptomatic (coronary endarterectomy or coronary artery stenting)",
"Carotid symptomatic (coronary endarterectomy)",
"Endovascular aortic aneurysm repair",
"Head or neck surgery",
"Intraperitoneal: splenectomy, hiatal hernia repair, cholecystectomy",
"Intrathoracic: non-major",
"Neurological or orthopaedic: major (hip and spine surgery)",
"Peripheral arterial angioplasty",
"Renal transplants",
"Urological or gynaecological: major",
],
},
{
value: "High surgical risk (>5%)",
titles: [
"Adrenal resection",
"Aortic and major vascular surgery",
"Carotid symptomatic (Carotid artery stenting)",
"Duodenal-pancreatic surgery",
"Liver resection, bile duct surgery ",
"Oesophagectomy",
"Open lower limb revascularization for acute limb ischaemia or amputation",
"Pneumonectomy (video-assisted thoracic surgery or open surgery)",
"Pulmonary or liver transplant",
"Repair of perforated bowel",
"Total cystectomy",
],
},
],
},
{
type: "select",
required: true,
label: "Bleeding risk",
name: "bleeding_risk",
options: [
{
value: "Minor bleeding risk",
titles: [
"Cataract or glaucoma procedure",
"Dental procedures: extractions (1–3 teeth), periodontal surgery, implant positioning endodontic (root canal) procedures, subgingival scaling/cleaning",
"Endoscopy without biopsy or resection",
" Superficial surgery (e.g. abscess incision, small skin excisions/ biopsy)",
],
},
{
value: "Low bleeding risk",
titles: [
"Abdominal surgery: cholecystectomy, hernia repair, colon resection",
"Breast surgery",
"Complex dental procedures (multiple tooth extractions)",
"Endoscopy with simple biopsy",
"Gastroscopy or colonoscopy with simple biopsy",
"Large-bore needles procedures (e.g. bone marrow or lymph node biopsy)",
"Non-cataract ophthalmic surgery",
"Small orthopaedic surgery (foot, hand arthroscopy)",
],
},
{
value: "High bleeding risk",
titles: [
"Abdominal surgery with liver biopsy, extracorporeal shockwave lithotripsy",
"Extensive cancer surgery (e.g. pancreas, liver)",
"Neuraxial (spinal or epidural) anaesthesia",
"Neurosurgery (intracranial, spinal) ",
"Major orthopaedic surgery ",
"Procedures with vascular organ biopsy (kidney or prostate)",
"Reconstructive plastic surgery",
"Specific interventions (colon polypectomy, lumbar puncture, endovascular aneurysm repair)",
"Thoracic surgery, lung resection surgery",
" Urological surgery (prostatectomy, bladder tumour resection)",
"Vascular surgery (e.g. abdominal aortic aneuvrysm repair, vascular bypass)",
],
},
],
},
],
},
{
title: "Patient-related",
questions: [
{
type: "input",
input_type: "text",
placeholder: "Enter patient's name",
required: true,
label: "Patient's name",
name: "patient_name",
},
{
type: "checkbox",
required: false,
label: "Cardiovascular risk factor",
name: "cardiovascular_risk_factor",
options: [
{
label: "Hypertension",
value: "hypertension",
},
{
label: "Diabetes",
value: "diabetes",
},
{
label: "Dyslipidemia",
value: "dyslipidemia",
},
{
label: "Smoking",
value: "smoking",
},
{
label: "Age greater than or equal to 65 years",
value: "age_greater_than_65_years",
},
{
label: "Family history of cardiovascular disease",
value: "family_history_of_cardiovascular_disease",
required: true,
nestedQuestion: {
type: "checkbox",
options: [
{
label:
"Myocardial infarction or sudden death <55 years with father or brother",
value:
"myocardial_infarction_or_sudden_death_less_than_55_years_with_father_or_brother",
},
{
label:
"Myocardial infarction or sudden death <65 years with mother or sister",
value:
"myocardial_infarction_or_sudden_death_less_than_65_years_with_mother_or_sister",
},
{
label:
"Cerebrovascular accident <45 years with parents or brother/sister",
value:
"cerebrovascular_accident_less_than_45_years_with_parents_or_brother_sister",
},
],
},
},
],
},
{
type: "checkbox",
label: "Antecedents",
name: "antecedents",
sections: [
{
title: "Cardiovascular disease ",
options: [
{
label: "Heart failure",
value: "heart_failure",
namee: "heart_failure",
nestedQuestion: {
type: "radio",
options: [
{
label: "Stable heart failure",
value: "stable_heart_failure",
},
{
label: "Unstable heart failure",
value: "unstable_heart_failure",
},
],
},
},
{
label: "Coronary artery disease",
value: "coronary_artery_disease",
},
{
label: "Vasopastic angina",
value: "vasopastic_angina",
},
{
label: "Mechanical prosthetic valve",
value: "mechanical_prosthetic_valve",
name: "mechanical_prosthetic_valve",
nestedQuestion: {
type: "checkbox",
options: [
{
label:
"Mechanical aortic valve replacement(AVR), associated with ",
value:
"mechanical_aortic_valve_replacement_associated_with",
name: "mechanical_aortic_valve_replacement_associated_with",
nestedQuestion: {
type: "checkbox",
options: [
{
label: "Atrial fibrillation",
value: "atrial_fibrillation1",
},
{
label: "Previous thromboembolism, ",
value: "previous_thromboembolism",
},
{
label: "Severe left ventricular dysfunction ",
value: "severe_left_ventricular_dysfunction",
},
{
label: "Hypercoagulable state",
value: "hypercoagulable_state",
},
]
}
},
{
label:
"Older-generation mechanical aortic valve replacement ",
value:
"older_generation_mechanical_aortic_valve_replacement",
},
{
label: "Mechanical mitral valve replacement",
value: "mechanical_mitral_valve_replacement",
},
],
},
},
{
label: "Atrial fibrillation",
value: "atrial_fibrillation",
},
{
label: "Other rythmic antecedents",
value: "other_rythmic_antecedents",
},
{
label: "Venous thromboembolism",
value: "venous_thromboembolism",
},
],
},
{
title: "Non cardiovascular disease",
options: [
{
label: "Diabetes mellitus",
value: "diabetes_mellitus",
},
{
label: "Renal failure",
value: "renal_failure",
},
],
},
],
},
],
},
{
title: "Examination",
questions: [
{
type: "checkbox",
required: true,
label: "Examination",
name: "examination",
options: [
{
label: "Asymptomatic",
value: "asymptomatic",
default: true,
},
{
label: "Newly detected murmurs",
value: "newly_detected_murmurs",
},
{
label: "Chest pain",
value: "chest_pain",
},
{
label: "Symptoms/signs suggestive of cardio-vascular disease",
value: "symptoms_signs_suggestive_of_cardiovascular_disease",
},
{
label:
"Poor functional capacity (METs<4 –if the patient cannot climb two flights of stairs-)",
value: "poor_functional_capacity",
},
{
label: "High clinical risk factor : (RCRI >= 1)",
value: "high_clinical_risk_factor",
name: "high_clinical_risk_factor",
required: true,
nestedQuestion: {
type: "checkbox",
options: [
{
label: "Ischaemic heart disease",
value: "ischaemic_heart_disease",
},
{
label: "Cerebrovascular disease",
value: "cerebrovascular_disease",
},
{
label: "History of congestive heart failure",
value: "history_of_congestive_heart_failure",
},
{
label: "Insulin therapy for diabetes",
value: "insulin_therapy_for_diabetes",
},
{
label: "Serum creatinine level ≥2 mg/dL",
value:
"serum_creatinine_level_greater_than_or_equal_to_2_mg_per_dL",
},
{
label: "High-risk surgery",
value: "high_risk_surgery",
},
],
},
},
{
label: "Abnormal ECG",
value: "abnormal_ecg",
name: "abnormal_ecg",
required: true,
nestedQuestion: {
type: "checkbox",
options: [
{
label: "Pathological Q wave",
value: "pathological_q_wave",
},
{
label: "ST-T wave changes",
value: "st_t_wave_changes",
},
{
label: "Non-sinus rhythm",
value: "non_sinus_rhythm",
},
{
label: "Left bundle branch block",
value: "left_bundle_branch_block",
},
],
},
},
{
label: "High NT-pro-BNP/BNP",
value: "high_nt_pro_bnp_bnp",
},
{
label: "Acute coronary syndrome",
value: "acute_coronary_syndrome",
},
],
},
],
},
],
The way i render this form is using recursion. I have this jsx component named Question.jsx which i pass with it the question. Where i'm stuck is to manage the state of the hole form in one useState hook object. And espacialy when it comes to nested questions with levels of more the 2. As i need to update the parent. I realy need help please !

How to add a gradient color and solve the wrong cursor indicating issue in vega chart

Current mouse cursor is not working well.
It indicates wrong tooltip.
And I want to set item gradient color.
current code is like this
import React from "react";
import { Vega } from "react-vega";
function BubbleChart() {
const spec = {
$schema: "https://vega.github.io/schema/vega/v5.json",
width: 1960,
height: 800,
padding: { left: 5, right: 5, top: 20, bottom: 0 },
autosize: "none",
signals: [
{ name: "cx", update: "width / 2" },
{ name: "cy", update: "height / 2" },
{
name: "gravityX",
value: 0,
},
{
name: "gravityY",
value: 0.2,
},
],
data: [
{
name: "table",
values: [
{ category: "A", amount: 0.28 },
{ category: "B", amount: 0.55 },
{ category: "C", amount: 0.43 },
{ category: "D", amount: 0.31 },
{ category: "E", amount: 0.81 },
{ category: "F", amount: 0.53 },
{ category: "G", amount: 0.19 },
{ category: "H", amount: 0.87 },
{ category: "I", amount: 0.28 },
{ category: "J", amount: 0.55 },
{ category: "K", amount: 0.43 },
{ category: "L", amount: 0.91 },
{ category: "M", amount: 0.81 },
{ category: "Government", amount: 0.99 },
{ category: "Service", amount: 0.59 },
{ category: "Army", amount: 0.27 },
],
},
],
scales: [
{
name: "size",
domain: { data: "table", field: "amount" },
range: [5000, 20000],
},
{
name: "color",
type: "ordinal",
domain: { data: "table", field: "category" },
range: "ramp",
},
],
marks: [
{
name: "nodes",
type: "symbol",
from: { data: "table" },
encode: {
enter: {
fill: { scale: "color", field: "category" },
xfocus: { signal: "cx" },
yfocus: { signal: "cy" },
},
update: {
size: { signal: "pow(2 * datum.amount, 2)", scale: "size" },
stroke: { value: "#fff" },
strokeWidth: { value: 0 },
tooltip: { signal: "datum" },
},
},
transform: [
{
type: "force",
iterations: 100,
static: true,
forces: [
{
force: "collide",
iterations: 2,
radius: { expr: "sqrt(datum.size) / 1.5" },
},
{ force: "center", x: { signal: "cx" }, y: { signal: "cy" } },
{ force: "x", x: "xfocus", strength: { signal: "gravityX" } },
{ force: "y", y: "yfocus", strength: { signal: "gravityY" } },
],
},
],
},
{
type: "text",
from: { data: "nodes" },
encode: {
enter: {
align: { value: "center" },
baseline: { value: "middle" },
fontSize: { value: 30 },
fontFamily: { value: "Helvetica" },
fontWeight: { value: 400 },
fill: { value: "#fff" },
text: { field: "datum.category" },
},
update: { x: { field: "x" }, y: { field: "y" } },
},
},
],
};
return (
<>
<Vega spec={spec} actions={false} />
</>
);
}
export default BubbleChart;
Please check and let me know how add gradient color and solve incorrect cursor indicating issue.
I want to build this gradient item

Read array inside array into table Material UI

So i have an array of response from backend services as below (array inside an array), i try to figure it how to turn it into table but have some problem on the logic:
"data": [
{
"id": "63ad33c69acfa205d354256b",
"material": "1000000000",
"material_name": "SAMPEL",
"plant": "K111",
"type": "rm",
"current_price": 7718,
"price": []
},
{
"id": "63ad33c69acfa205d354256a",
"material": "1000000000",
"material_name": "SAMPEL",
"plant": "K109",
"type": "rm",
"current_price": 7718,
"price": []
},
{
"id": "63ad33c69acfa205d3542565",
"material": "1000000000",
"material_name": "SAMPEL",
"plant": "K103",
"type": "rm",
"current_price": 37259,
"price": [
{
"date": "januari",
"price": 37258.978184562315
},
{
"date": "februari",
"price": 37258.978184562315
},
{
"date": "maret",
"price": 37258.978184562315
},
{
"date": "april",
"price": 37258.978184562315
},
{
"date": "mei",
"price": 37258.978184562315
},
{
"date": "juni",
"price": 37258.978184562315
},
{
"date": "juli",
"price": 37258.978184562315
},
{
"date": "agustus",
"price": 37258.978184562315
},
{
"date": "september",
"price": 37258.978184562315
},
{
"date": "oktober",
"price": 37258.978184562315
},
{
"date": "november",
"price": 37258.978184562315
},
{
"date": "desember",
"price": 37258.978184562315
}
]
},
]
does it possible to turn it into table as below using material UI datagrid or similar table library?:
any help on this will be very helpful....
https://github.com/ChangeWithCode/datantable
Here I have implemented that you can have a look.
<div className="App">
<table>
<tr>
<th rowspan="2">material</th>
<th rowspan="2">material_name</th>
<th rowspan="2">plant</th>
<th rowspan="2">type</th>
<th rowspan="2">current_price</th>
<th colspan="12">Price</th>
</tr>
<tr>
<td>januari</td>
<td>februari</td>
<td>maret</td>
<td>april</td>
<td>mei</td>
<td>juni</td>
<td>juli</td>
<td>agustus</td>
<td>september</td>
<td>oktober</td>
<td>november</td>
<td>desember</td>
</tr>
{object.data.map((item) => {
return (
<tr>
<td>{item.material}</td>
<td>{item.material_name}</td>
<td>{item.plant}</td>
<td>{item.current_price}</td>
<td>{item.material_name}</td>
{item.price.map((obj) => {
return <td>{obj.price}</td>;
})}
</tr>
);
})}
</table>
</div>
The following solution using material table import MaterialTable from 'material-table';:
<MaterialTable
columns={[
{ title: 'material', field: 'material' },
{ title: 'material_name', field: 'material_name' },
{ title: 'plant', field: 'plant' },
{ title: 'type', field: 'type' },
{
title: 'current_price',
field: 'current_price',
},
{
title: 'price',
field: 'price',
render: (rowData) => (
<MaterialTable
columns={
rowData.price.length > 0
? rowData.price.map((el) => ({ title: el.date, field: 'price' }))
: [
{ title: 'januari', field: '' },
{ title: 'februari', field: '' },
{ title: 'maret', field: '' },
{ title: 'april', field: '' },
{ title: 'mei', field: '' },
{ title: 'juni', field: '' },
{ title: 'juli', field: '' },
{ title: 'agustus', field: '' },
{ title: 'september', field: '' },
{ title: 'oktober', field: '' },
{ title: 'november', field: '' },
{ title: 'desember', field: '' },
]
}
data={rowData.price}
options={{ toolbar: false }}
/>
),
},
]}
data={data}
title="Demo Title"
/>

How to remove drill down caption? and add expand and collapse arrow

I want remove caption and add expand and collapse arrow. I can't post image here so check my codesandbox. This I want look like https://codepen.io/webdatarocks/pen/dLeZvN
My codesandbox:
https://codesandbox.io/s/react-webdatarocks-react-functional-component-jh22w6?file=/src/components/useBalanceSheet.js
Hierarchies in WebDataRocks are always displayed with captions for the next level.
If you want the behavior as in the Codepen link you provided, you should replace the hierarchy with the separate data columns and then add them to slice.rows.
Here is the example snippet
var pivot = new WebDataRocks({
container: "#wdr-component",
toolbar: true,
width: "100%",
height: 600,
report: {
dataSource: {
dataSourceType: "json",
data: getData()
},
slice: {
rows: [{
uniqueName: "baseGroup",
caption: "Balance Sheet"
},
{
uniqueName: "group"
},
{
uniqueName: "accountName"
}
],
measures: [{
uniqueName: "value",
aggregation: "sum",
}],
expands: {
expandAll: true
},
drills: {
drillAll: true
},
},
tableSizes: {
columns: [
{
idx: 0,
width: 400
},
{
idx: 1,
width: 200
}
]
},
options: {
grid: {
showHeaders: false
}
},
}
}
);
function getData() {
return [{
baseGroup: "Asset",
group: "Current Asset",
accountName: "Cash Account",
value: 100
},
{
baseGroup: "Asset",
group: "Current Asset",
accountName: "SBI Bank Account",
value: 100
},
{
baseGroup: "Asset",
group: "Current Asset",
accountName: "SBI Loan",
value: 100
},
{
baseGroup: "Equity",
group: "Shareholbers Funds",
accountName: "Reserves and Surplus",
value: 100
},
{
baseGroup: "Equity",
group: "Shareholbers Funds",
accountName: "Reserves and Surplus",
value: 100
},
{
baseGroup: "Liabilities",
group: "Current liabilities",
accountName: "Short-term borrowings",
value: 100
},
{
baseGroup: "Liabilities",
group: "Current liabilities",
accountName: "Tax payable",
value: 100
},
{
baseGroup: "Liabilities",
group: "Non-current liabilities",
accountName: "Long-term borrowings",
value: 100
}
]
}
<link href="https://cdn.webdatarocks.com/latest/webdatarocks.min.css" rel="stylesheet"/>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.toolbar.min.js"></script>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.js"></script>
<div id="wdr-component"></div>

EXTJS 5.1 VERY SIMPLE TreeStore from JSON

I have looked around but I still don't understand how to create treestore properly.
I have this very simple json that I get from a server:
{
"Results": [
{
"name": "John",
"age": 23,
"cars": [
{
"name": "Clio",
"brand": "Renault"
},
{
"name": "Class S",
"brand": "Mercedes"
}
]
},
{
"name": "Michel",
"age": 42,
"cars": [
{
"name": "Qashqai",
"brand": "Nissan"
}
]
}
]
}
I have my two models:
Ext.define('Person', {
extend: 'Ext.data.Model',
fields: [ 'name', 'age']
});
Ext.define('Car', {
extend: 'Ext.data.Model',
fields: [ 'name', 'brand']
});
Now I know that I have to create a tree store, but in all example that I have seen, there is always a "children" property in the json, which I don't have.
How to create a tree store with the following json?
Thanks a lot in advance :) !!
You could always build the correct formatted object for the data like the following:
Ext.application({
name: 'Fiddle',
launch: function () {
var myTreeData = {
"Results": [{
"name": "John",
"age": 23,
"cars": [{
"name": "Clio",
"brand": "Renault"
}, {
"name": "Class S",
"brand": "Mercedes"
}]
}, {
"name": "Michel",
"age": 42,
"cars": [{
"name": "Qashqai",
"brand": "Nissan"
}]
}]
},
modifiedData = {
expanded: true,
children: []
};
myTreeData.Results.forEach(function (result) {
var newChildrenArray = [];
result.cars.forEach(function (car) {
var newChild = {
text: car.name,
leaf: true
};
newChildrenArray.push(newChild);
});
var person = {
text: result.name,
leaf: (newChildrenArray.length > 0 ? false : true),
children: newChildrenArray
};
modifiedData.children.push(person);
});
var store = Ext.create('Ext.data.TreeStore', {
root: modifiedData
});
Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody()
});
}
});
Demo here: https://fiddle.sencha.com/#fiddle/j05

Resources