I have a gantt chart which is created from a stacked bar chart. I am trying to make the h-axis titles look different from each others, like in the image below. I've look into the API and could not find any solution.
Does anyone know how to accomplish this?
Individual styling is not supported with Google API. So if you can handle risk of future code break you can 'manually' change text properties.
As a example I used Simple Example from google docs and change it to the stacked bar chart.
The following elements are created in DOM for labels on the left (2004 - 2007):
<g>
<text text-anchor="end" x="147" y="139.9" font-family="Arial" font-size="14" stroke="none" stroke-width="0" fill="#222222">2004</text>
</g>
<g>
<text text-anchor="end" x="147" y="216.9" font-family="Arial" font-size="14" stroke="none" stroke-width="0" fill="#222222">2005</text>
</g>
<g>
<text text-anchor="end" x="147" y="293.9" font-family="Arial" font-size="14" stroke="none" stroke-width="0" fill="#222222">2006</text>
</g>
<g>
<text text-anchor="end" x="147" y="370.9" font-family="Arial" font-size="14" stroke="none" stroke-width="0" fill="#222222">2007</text>
</g>
You can change them using for example:
var labels = document.querySelectorAll('text[text-anchor=end]');
for (var i = 0; i < labels.length; i++) {
if (labels[i].textContent == '2004') {
labels[i].setAttribute('font-weight', 'bold');
labels[i].setAttribute('font-size', '20');
}
if (labels[i].textContent == '2005') {
labels[i].setAttribute('font-style', 'italic');
labels[i].setAttribute('font-size', '20');
}
}
See whole example at jsbin.
Related
I want to create a grouped object with multiple lines and fill the object with a background color.
As you can see, however, the background does not respect the lines as a frame.
Is it possible to fill only the grouped object within the lines?
It's not possible using grouped lines (style will be applied to whole group which have shape of rectangle) , but you can create custom shape using Arrange > Insert > Shape. You can find description how to do that here or here. If you want to edit shape after inserting it, you can do that using Edit Shape from Style tab in format panel on right (it is also possible to edit some of draw.io shapes).
Example shape similar to your image:
<shape h="100" w="100" aspect="variable" strokewidth="inherit">
<foreground>
<path>
<move x="50" y="0" />
<line x="80" y="40" />
<line x="100" y="50" />
<line x="60" y="100" />
<line x="30" y="100" />
<line x="0" y="60" />
<close />
</path>
<fillstroke />
</foreground>
</shape>
Remeber to use <fillstroke /> or <fill /> if you want colored background.
I'm working on svg creating and loading in a project with Qt, the problem is where I want to create different elements with different elementIds and also load them back from file and identify them by their ids, a list of element ids also would be nice.
I've read Qt::Svg package documentation and tried to save and load svg files, also read the codes of Qt::Svg and found out behind the API of qtsvg it's a list of elements with their element id's but it's not ported to the API here:
https://github.com/qt/qtsvg/blob/347de1dd25366015e3fbbc39ccd1a16ecb18eb2e/src/svg/qsvgtinydocument_p.h#L131
I use the typical documented Qt procedure to save and load svg from/to QGraphicsScene with QSvgGenerator and QSvgRenderer
void MainWindow::saveClicked()
{
QString fileName = QFileDialog::getSaveFileName(this,
tr("Save as SVG"), QString(), tr("SVG Files (*.svg)"));
QSvgGenerator generator;
generator.setFileName(fileName);
generator.setSize(QSize(1000, 1000));
generator.setViewBox(QRect(0, 0, 1000, 1000));
generator.setTitle(tr("SVG Generator Example Drawing"));
generator.setDescription(tr("An SVG drawing created by the SVG Generator "));
QPainter painter;
painter.begin(&generator);
scene->render(&painter);
painter.end();
}
void MainWindow::on_loadBtn_clicked()
{
QString svgPath = QFileDialog::getOpenFileName(this, tr("Choose svg file"), QString(),
"SVGs (*.svg)");
QFile svgFile(svgPath);
if (!svgFile.exists())
return;
QSvgRenderer renderer(svgPath);
QGraphicsSvgItem *svgItem = new QGraphicsSvgItem(svgPath);
// svgItem->setElementId("rect10");
if (!svgItem->renderer()->isValid())
return;
svgItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
scene->addItem(svgItem);
}
the result is this(for example a simple circle):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="352.778mm" height="352.778mm"
viewBox="0 0 1000 1000"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.2" baseProfile="tiny">
<title>SVG Generator Example Drawing</title>
<desc>An SVG drawing created by the SVG Generator </desc>
<defs>
</defs>
<g fill="none" stroke="black" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel" >
<g fill="none" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="square" stroke-linejoin="bevel" transform="matrix(1,0,0,1,0,0)"
font-family="MS Shell Dlg 2" font-size="8.25" font-weight="400" font-style="normal"
>
</g>
<g fill="none" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="square" stroke-linejoin="bevel" transform="matrix(1,0,0,1,422,602)"
font-family="MS Shell Dlg 2" font-size="8.25" font-weight="400" font-style="normal"
>
<circle cx="37.5" cy="37.5" r="37.5"/>
</g>
<g fill="none" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="square" stroke-linejoin="bevel" transform="matrix(1,0,0,1,422,602)"
font-family="MS Shell Dlg 2" font-size="8.25" font-weight="400" font-style="normal"
>
</g>
<g fill="none" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="square" stroke-linejoin="bevel" transform="matrix(1,0,0,1,0,0)"
font-family="MS Shell Dlg 2" font-size="8.25" font-weight="400" font-style="normal"
>
</g>
</g>
</svg>
I wanted to know if there is no other alternative provided by Qt::Svg library or is there any third-party open source software that provide a better svg manipulation API in Qt?
or can you suggest a solution? xml-manipulation? subclass QSvgGenerator and QSvgRenderer? or Idk :))
the problem is that I can call to load just one element Id but how can I know the element Ids list to load them separately...
I have a very large form with hundreds of fields on it. Some are black and some are blue. I'm trying to parse the dxl using xsl to find the fields where they are set to the color blue.
i've found several xsl files to parse the dxl but I can'tfigure out how to find the field then find the previous font color='blue'
Can anyone help me with that syntax? Here is a sample of the dxl I am trying to parse:
<par def="100">
<run>
<font size="9pt" style="bold" name="Arial" pitch="variable" truetype="true" familyid="20" />
</run>
<run>
<font size="9pt" color="blue" style="bold" name="Arial" pitch="variable" truetype="true" familyid="20" />
<field type="text" kind="editable" name="DevComments">
<code event="inputtranslation">
<formula>#Trim( #ThisValue )</formula>
</code>
</field>
</run>
<compositedata type="98" prevtype="65418" nexttype="222" afterparcount="6" containertype="65418" aftercontainercount="1" afterbegincount="3">Yg4BAIQAAAAAAAAAAAA=</compositedata>
<run>
<font size="9pt" style="bold" name="Arial" pitch="variable" truetype="true" familyid="20" />
</run>
</par>
I have the following data which I need to display as a cluster of stacked chart for each month.
The chart should have two stacked bars for each month.
One would be a stacked bar chart of Historical_A and Historical_B
Other one would be for Monthly_A and Monthly_B.
I need to have the chart displayed as per this
Example Link.
I have been trying to manipulate the webchart XML as below but nothing has come out of it so far.
<elements action="" place="Stacked" drawOutline="false">
<morph morph="Grow"/>
<series place="default" index="0" shape="bar">
<paint color="#E48701"/>
</series>
<series index="1" place="stacked" shape="bar">
<paint color="#A5BC4E"/>
</series>
<series index="2" place="default" shape="bar">
<paint color="#1B95D9"/>
</series>
<series index="3" place="stacked" shape="bar">
<paint color="#CACA9E"/>
</series>
</elements>
Edit 1 : Found a similar chart in Highcharts. HighCharts Example
According to this page http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-792e.html you can use a dataLabelStyle which can be "none", "value", "rowLabel", "columnLabel" or "pattern". However whenever i use "rowLabel", "columnLabel" or "pattern" the image doesn't show. There is no error, just a blank canvas where the image should be. Does any one know how to work around this?
Thanks
I had the same problem, and I found that when I add the legend attribute placement, that is when the chart disappears. The legend shows with the placement indicated, but no chart.
I finally figured out what to do, I started from scratch with the bare minimum pie chart with examples from this page:
WebCharts3D Piecharts
And I discovered that the order of the elements in the XML file was the issue.
This is how my XML file is now and it works:
<?xml version="1.0" encoding="UTF-8"?>
<paint paint="Plain" />
<title>
<decoration style="None"/>
</title>
<dataLabels style="Pattern" font="Arial-16-bold">
<![CDATA[
$(value), $(colPercent)
]]>
</dataLabels>
<legend placement="Right" font="Arial-16">
<decoration style="None"/>
</legend>
<insets left="10" top="10" right="5" />
<elements action="" shape="Area" drawOutline="false">
<morph morph="Blur" /> <!-- other options: grow, none -->
<series index="0">
<paint color="#E48701" /> <!-- orange -->
</series>
<series index="1">
<paint color="#A5BC4E" /> <!-- lime -->
</series>
<!-- ...(etc) -->
</elements>
</pieChart>
This test of the five(5) styles works fine for me.
Maybe it is your code? Probably not a version problem as dataLabelStyle was introduced back in MX7 .
<cfloop list="value,rowLabel,columnLabel,pattern,none" index="style">
<cfchart format="png" scaleFrom="0" scaleto="30">
<cfchartseries type="bar" dataLabelStyle="#style#">
<cfchartdata item="bar" value="25">
<cfchartdata item="foo" value="10">
</cfchartseries>
</cfchart>
</cfloop>